selinux: always fill AVC decision in avc_has_perm_noaudit()
PATCH 1/1 selinux: always fill AVC decision in avc_has_perm_noaudit()
From: Christian Göttsche <[email protected]>
avc_has_perm_noaudit() is documented to return a copy of the access decision in @avd, but its early return for an empty requested permission set leaves the buffer untouched. All callers pass an uninitialized stack variable and afterwards feed it to avc_audit(), and the inode hook even stores it in the per-task decision cache.
Fill in a deny-all, audit-all decision, similar to avd_init(), so every caller receives a defined value at no cost on the hot path.
--- security/selinux/avc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
security/selinux/avc.c +4 -1
@@ -1149,8 +1149,11 @@ inline int avc_has_perm_noaudit(u32 ssid, u32 tsid,u32 denied;struct avc_node *node; -if (WARN_ON (!requested)) +if (WARN_ON (!requested)) { +/* Provide a deny-all, audit-all decision to the caller. */ + *avd = (struct av_decision ){ .auditdeny =0xffffffff };return -EACCES ; + }rcu_read_lock (); node =avc_lookup (ssid, tsid, tclass);
Signature · 1 line
2.55.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines
From: Christian Göttsche <[email protected]>
avc_has_perm_noaudit()is documented to return a copy of the access decision in @avd, but its early return for an empty requested permission set leaves the buffer untouched. All callers pass an uninitialized stack variable and afterwards feed it toavc_audit(), and the inode hook even stores it in the per-task decision cache.
Quoted 4 lines
Fill in a deny-all, audit-all decision, similar to
avd_init(), so every caller receives a defined value at no cost on the hot path.Signed-off-by Christian Göttsche <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 9 lines · Christian Göttsche
From: Christian Göttsche <[email protected]>
avc_has_perm_noaudit()is documented to return a copy of the access decision in @avd, but its early return for an empty requested permission set leaves the buffer untouched. All callers pass an uninitialized stack variable and afterwards feed it toavc_audit(), and the inode hook even stores it in the per-task decision cache.
Quoted 4 lines
Fill in a deny-all, audit-all decision, similar to
avd_init(), so every caller receives a defined value at no cost on the hot path.Signed-off-by Christian Göttsche <[email protected]>
Paul Moore
maintainerQuoted 10 lines · On Sep 3, 2026 =?UTF-8?q?Christian=20G=C3=B6ttsche?=…
avc_has_perm_noaudit()is documented to return a copy of the access decision in @avd, but its early return for an empty requested permission set leaves the buffer untouched. All callers pass an uninitialized stack variable and afterwards feed it toavc_audit(), and the inode hook even stores it in the per-task decision cache.Fill in a deny-all, audit-all decision, similar to
avd_init(), so every caller receives a defined value at no cost on the hot path.
Quoted 6 lines
Signed-off-by Christian Göttsche <[email protected]>Fixes e6f2f381e4015386 ("selinux: replace BUG_ONs with WARN_ONs in avc.c")Reviewed-by Stephen Smalley <[email protected]>--- security/selinux/avc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Good catch, thanks Christian. I'm going to mark this for stable and merge it via selinux/stable-7.3, if anyone would rather see this go via the traditional selinux/dev branch please speak up in the next few days.
--
paul-moore.com