From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Bryam Vargas <hexlabsecurity@proton.me>,
Stephen Smalley <stephen.smalley.work@gmail.com>,
Paul Moore <paul@paul-moore.com>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.6.y 8/9] selinux: reject a permission value exceeding the class permission count
Date: Tue, 25 Aug 2026 07:24:39 -0400 [thread overview]
Message-ID: <20260825112440.3543785-8-sashal@kernel.org> (raw)
In-Reply-To: <20260825112440.3543785-1-sashal@kernel.org>
From: Bryam Vargas <hexlabsecurity@proton.me>
[ Upstream commit d14b5d0e97fccd27974fedc03b903408872907fd ]
perm_read() bounds a permission value by SEL_VEC_MAX but never by the
nprim of the owning class or common, which is taken verbatim from the
policy image. security_get_permissions() then writes perms[value - 1]
into an nprim-sized kcalloc() array, so a class declaring fewer
permissions than its largest permission value drives an out-of-bounds
heap write. The top-level symbol tables are validated this way; the
nested per-class permission table is not.
Reject a permission whose value exceeds nprim, which is already set when
perm_read() runs. Well-formed policies are unaffected.
Cc: stable@vger.kernel.org
Fixes: 55fcf09b3fe4 ("selinux: add support for querying object classes and permissions from the running policy")
Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
[PM: tweak comment for line length]
Signed-off-by: Paul Moore <paul@paul-moore.com>
Stable-dep-of: b98a8ac50775 ("selinux: require a class's permission values to cover its permission count")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
security/selinux/ss/policydb.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index 6f27c0ccb3468..9bf9327fae365 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -1120,6 +1120,9 @@ static int perm_read(struct policydb *p, struct symtab *s, struct policy_file *f
rc = -EINVAL;
if (perdatum->value < 1 || perdatum->value > SEL_VEC_MAX)
goto bad;
+ /* indexes an nprim-sized array in security_get_permissions() */
+ if (perdatum->value > s->nprim)
+ goto bad;
rc = str_read(&key, GFP_KERNEL, fp, len);
if (rc)
--
2.53.0
next prev parent reply other threads:[~2026-08-25 11:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 10:41 FAILED: patch "[PATCH] selinux: require a class's permission values to cover its" failed to apply to 6.6-stable tree gregkh
2026-08-25 11:24 ` [PATCH 6.6.y 1/9] selinux: fix style issues in security/selinux/ss/policydb.h Sasha Levin
2026-08-25 11:24 ` [PATCH 6.6.y 2/9] selinux: fix style issues in security/selinux/ss/policydb.c Sasha Levin
2026-08-25 11:24 ` [PATCH 6.6.y 3/9] selinux: use known type instead of void pointer Sasha Levin
2026-08-25 11:24 ` [PATCH 6.6.y 4/9] selinux: avoid unnecessary indirection in struct level_datum Sasha Levin
2026-08-25 11:24 ` [PATCH 6.6.y 5/9] selinux: make more use of str_read() when loading the policy Sasha Levin
2026-08-25 11:24 ` [PATCH 6.6.y 6/9] selinux: use u16 for security classes Sasha Levin
2026-08-25 11:24 ` [PATCH 6.6.y 7/9] selinux: more strict policy parsing Sasha Levin
2026-08-25 11:24 ` Sasha Levin [this message]
2026-08-25 11:24 ` [PATCH 6.6.y 9/9] selinux: require a class's permission values to cover its permission count Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260825112440.3543785-8-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=hexlabsecurity@proton.me \
--cc=paul@paul-moore.com \
--cc=stable@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox