Skip to contentSkip to conversation

selinux: always fill AVC decision in avc_has_perm_noaudit()

PATCH In review Christian Göttsche 4 participants 4 messages Sep 3 – Sep 15 SELinux security module

lore
Share & tools
lore
#0 lore raw

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
index a9401d6c2e5f..560a82c6d682 100644
@@ -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
#1 lore raw
Sashiko 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 to avc_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.

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
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Christian Göttsche
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 to avc_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.

Fixes e6f2f381e4015386 ("selinux: replace BUG_ONs with WARN_ONs in avc.c")
maintainer
#3 lore raw
In reply to Christian Göttsche
Quoted 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 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.

Quoted 6 lines
Fixes e6f2f381e4015386 ("selinux: replace BUG_ONs with WARN_ONs in avc.c")
---
 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