selinux: replace BUG_ONs with WARN_ONs in avc.c
PATCH 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.
--- security/selinux/avc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/selinux/avc.c +2 -2
@@ -1059,7 +1059,7 @@ int avc_has_extended_perms(struct selinux_state *state,int rc =0 , rc2; xp_node = &local_xp_node; -BUG_ON (!requested); +WARN_ON (!requested);rcu_read_lock ();
@@ -1149,7 +1149,7 @@ inline int avc_has_perm_noaudit(struct selinux_state *state,int rc =0 ;u32 denied; -BUG_ON (!requested); +WARN_ON (!requested);rcu_read_lock ();
Signature · 1 line
2.20.1
Quoted 15 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)security/selinux/avc.c +0
-0
security/selinux/avc.c int avc_has_extended_perms(struct selinux_state *state, · line 1062
Quoted 5 lines
security/selinux/avc.c +1
-1@@ -1059,7 +1059,7 @@ int avc_has_extended_perms(struct selinux_state *state,int rc =0 , rc2; xp_node = &local_xp_node; -BUG_ON (!requested); +WARN_ON (!requested);
Should this be:
if (WARN_ON(!requested)) return -EACCES;
security/selinux/avc.c inline int avc_has_perm_noaudit(struct selinux_state *state, · line 1152
Quoted 9 lines
security/selinux/avc.c +1
-1rcu_read_lock ();@@ -1149,7 +1149,7 @@ inline int avc_has_perm_noaudit(struct selinux_state *state,int rc =0 ;u32 denied; -BUG_ON (!requested); +WARN_ON (!requested);
And likewise
Quoted 4 lines
security/selinux/avc.c +0
-0rcu_read_lock ();
Paul Moore
maintainerQuoted 18 lines · Stephen Smalley
Quoted 17 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)security/selinux/avc.c +0
-0@@ -1059,7 +1059,7 @@ int avc_has_extended_perms(struct selinux_state *state,int rc =0 , rc2;
Quoted 7 lines
security/selinux/avc.c int avc_has_extended_perms(struct selinux_state *state, · line 1062
Quoted 3 lines
security/selinux/avc.c +1
-1xp_node = &local_xp_node; -BUG_ON (!requested); +WARN_ON (!requested);Should this be:
if (WARN_ON(!requested)) return -EACCES;
I think so, it would be bad not to return an error in this case (and the similar one below).
Quoted 16 lines
security/selinux/avc.c inline int avc_has_perm_noaudit(struct selinux_state *state, · line 1152
Quoted 9 lines
security/selinux/avc.c +1
-1rcu_read_lock ();@@ -1149,7 +1149,7 @@ inline int avc_has_perm_noaudit(struct selinux_state *state,int rc =0 ;u32 denied; -BUG_ON (!requested); +WARN_ON (!requested);And likewise
Quoted 4 lines
security/selinux/avc.c +0
-0rcu_read_lock ();
Signature · 2 lines
paul moore www.paul-moore.com
Quoted 27 lines · Paul Moore
Quoted 18 lines · Stephen Smalley
Quoted 17 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)security/selinux/avc.c +0
-0@@ -1059,7 +1059,7 @@ int avc_has_extended_perms(struct selinux_state *state,int rc =0 , rc2;Quoted 7 lines
security/selinux/avc.c int avc_has_extended_perms(struct selinux_state *state, · line 1062
Quoted 3 lines
security/selinux/avc.c +1
-1xp_node = &local_xp_node; -BUG_ON (!requested); +WARN_ON (!requested);Should this be:
if (WARN_ON(!requested)) return -EACCES;
Quoted 2 lines
I think so, it would be bad not to return an error in this case (and the similar one below).
Makes sense... will send a v2 right away.
Quoted 21 lines
Quoted 4 lines
Quoted 4 lines
security/selinux/avc.c +0
-0rcu_read_lock ();Quoted 13 lines
security/selinux/avc.c inline int avc_has_perm_noaudit(struct selinux_state *state, · line 1152
Quoted 6 lines
security/selinux/avc.c +1
-1@@ -1149,7 +1149,7 @@ inline int avc_has_perm_noaudit(struct selinux_state *state,int rc =0 ;u32 denied; -BUG_ON (!requested); +WARN_ON (!requested);And likewise
Quoted 4 lines
security/selinux/avc.c +0
-0rcu_read_lock ();--
paul moore
www.paul-moore.com
Signature · 3 lines
Ondrej Mosnacek <omosnace at redhat dot com> Associate Software Engineer, Security Technologies Red Hat, Inc.