From: Eric Paris Date: Tue, 11 Mar 2008 18:19:34 +0000 (-0400) Subject: SELinux: requesting no permissions in avc_has_perm_noaudit is a BUG() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=eda4f69ca5a532b425db5a6c2c6bc50717b9b5fe;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git SELinux: requesting no permissions in avc_has_perm_noaudit is a BUG() This patch turns the case where we have a call into avc_has_perm with no requested permissions into a BUG_ON. All callers to this should be in the kernel and thus should be a function we need to fix if we ever hit this. The /selinux/access permission checking it done directly in the security server and not through the avc, so those requests which we cannot control from userspace should not be able to trigger this BUG_ON. Signed-off-by: Eric Paris Acked-by: Stephen D. Smalley Signed-off-by: James Morris --- diff --git a/security/selinux/avc.c b/security/selinux/avc.c index 187964e88af1..cb3f0ce0b00a 100644 --- a/security/selinux/avc.c +++ b/security/selinux/avc.c @@ -871,6 +871,8 @@ int avc_has_perm_noaudit(u32 ssid, u32 tsid, int rc = 0; u32 denied; + BUG_ON(!requested); + rcu_read_lock(); node = avc_lookup(ssid, tsid, tclass, requested); @@ -890,7 +892,7 @@ int avc_has_perm_noaudit(u32 ssid, u32 tsid, denied = requested & ~(p_ae->avd.allowed); - if (!requested || denied) { + if (denied) { if (selinux_enforcing || (flags & AVC_STRICT)) rc = -EACCES; else