selinux: replace BUG_ONs with WARN_ONs in avc.c
PATCH v2 1/1 selinux: replace BUG_ONs with WARN_ONs in avc.c
These checks are only guarding against programming errors that could silently grant too many permissions. These cases are better handled with WARN_ON(), since it doesn't really help much to crash the machine in this case.
Signed-off-by Ondrej Mosnacek <[email protected]>
--- security/selinux/avc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
security/selinux/avc.c +4 -2
@@ -1059,7 +1059,8 @@ int avc_has_extended_perms(struct selinux_state *state,int rc =0 , rc2; xp_node = &local_xp_node; -BUG_ON (!requested); +if (WARN_ON (!requested)) +return -EACCES ;rcu_read_lock ();
@@ -1149,7 +1150,8 @@ inline int avc_has_perm_noaudit(struct selinux_state *state,int rc =0 ;u32 denied; -BUG_ON (!requested); +if (WARN_ON (!requested)) +return -EACCES ;rcu_read_lock ();
Signature · 1 line
2.20.1
Quoted 6 lines · Ondrej Mosnacek
These checks are only guarding against programming errors that could silently grant too many permissions. These cases are better handled with
WARN_ON(), since it doesn't really help much to crash the machine in this case.Signed-off-by Ondrej Mosnacek <[email protected]>
Reviewed-by Stephen Smalley <[email protected]>
Quoted 29 lines
--- security/selinux/avc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)security/selinux/avc.c +4
-2@@ -1059,7 +1059,8 @@ int avc_has_extended_perms(struct selinux_state *state,int rc =0 , rc2; xp_node = &local_xp_node; -BUG_ON (!requested); +if (WARN_ON (!requested)) +return -EACCES ;rcu_read_lock ();@@ -1149,7 +1150,8 @@ inline int avc_has_perm_noaudit(struct selinux_state *state,int rc =0 ;u32 denied; -BUG_ON (!requested); +if (WARN_ON (!requested)) +return -EACCES ;rcu_read_lock ();
Quoted 9 lines · Ondrej Mosnacek
These checks are only guarding against programming errors that could silently grant too many permissions. These cases are better handled with
WARN_ON(), since it doesn't really help much to crash the machine in this case.Signed-off-by Ondrej Mosnacek <[email protected]>--- security/selinux/avc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Merged, thanks.
Quoted 27 lines
security/selinux/avc.c +4
-3@@ -1059,7 +1059,8 @@ int avc_has_extended_perms(struct selinux_state *state,int rc =0 , rc2; xp_node = &local_xp_node; -BUG_ON (!requested); +if (WARN_ON (!requested)) +return -EACCES ;rcu_read_lock ();@@ -1149,7 +1150,8 @@ inline int avc_has_perm_noaudit(struct selinux_state *state,int rc =0 ;u32 denied; -BUG_ON (!requested); +if (WARN_ON (!requested)) +return -EACCES ;rcu_read_lock (); --2.20.1
Signature · 2 lines
paul moore www.paul-moore.com