libsepol: bound category values in mls_semantic_level_expand - #528
Closed
netliomax25-code wants to merge 1 commit into
Closed
libsepol: bound category values in mls_semantic_level_expand#528netliomax25-code wants to merge 1 commit into
netliomax25-code wants to merge 1 commit into
Conversation
Member
|
You need to amend your git config; once again I had to pull the description into the commit, reformat it, and fix the Signed-off-by. Posted at https://lore.kernel.org/selinux/20260617124609.65706-1-stephen.smalley.work@gmail.com/T/#u |
mls_semantic_level_expand() checks the sensitivity against p_levels.nprim but never bounds the per-category low/high values against p_cats.nprim. For a base module the user MLS range and default level are read in semantic form with no bounds check, and policydb_read() expands them through policydb_index_others() -> policydb_user_cache() before policydb_validate() runs, so a crafted base policy with a category value past the declared count reads p_cat_val_to_name[] out of bounds, both in the "Category range is not valid" message and in the p_cat_val_to_name[i] reference inside the loop. Reject cat->high > p_cats.nprim and guard the error-message indices with the same upper bound, matching the existing sensitivity check just above. Signed-off-by: Kartik Kenchi <netliomax25@gmail.com>
netliomax25-code
force-pushed
the
mls-semantic-cat-bounds
branch
from
June 17, 2026 13:38
cf0e094 to
bf637c8
Compare
Contributor
Author
|
Sorry for the repeat hassle. I've fixed my git config so the author and Signed-off-by use my real name (Kartik Kenchi, same email), and amended the branch to fold the full description into the commit body, word-wrapped at 72 columns to match what you had to do by hand. It should come through clean on my future submissions. Thanks for pulling it onto the list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Confirmed under ASAN: a semantic level with a category low/high beyond the declared category count reports a heap-buffer-overflow read in mls_semantic_level_expand before the patch, and is rejected cleanly with an error after it.