diff options
author | Ondrej Mosnacek <omosnace@redhat.com> | 2019-01-25 05:06:49 -0500 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2019-01-25 17:25:02 -0500 |
commit | 994fb0651d02e49567e7550eb574981b387fc06f (patch) | |
tree | 2093a65b36429491a7b55f6ddcd5e5b508db907d /security/selinux | |
parent | a2c513835bb6c6ca660ae4ecda8ff9f676e47e55 (diff) |
selinux: replace some BUG_ON()s with a WARN_ON()
We don't need to crash the machine in these cases. Let's just detect the
buggy state early and error out with a warning.
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Reviewed-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux')
-rw-r--r-- | security/selinux/avc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/security/selinux/avc.c b/security/selinux/avc.c index 502162eeb3a0..5ebad47391c9 100644 --- a/security/selinux/avc.c +++ b/security/selinux/avc.c | |||
@@ -678,7 +678,6 @@ static void avc_audit_pre_callback(struct audit_buffer *ab, void *a) | |||
678 | return; | 678 | return; |
679 | } | 679 | } |
680 | 680 | ||
681 | BUG_ON(!sad->tclass || sad->tclass >= ARRAY_SIZE(secclass_map)); | ||
682 | perms = secclass_map[sad->tclass-1].perms; | 681 | perms = secclass_map[sad->tclass-1].perms; |
683 | 682 | ||
684 | audit_log_string(ab, " {"); | 683 | audit_log_string(ab, " {"); |
@@ -731,7 +730,6 @@ static void avc_audit_post_callback(struct audit_buffer *ab, void *a) | |||
731 | kfree(scontext); | 730 | kfree(scontext); |
732 | } | 731 | } |
733 | 732 | ||
734 | BUG_ON(!sad->tclass || sad->tclass >= ARRAY_SIZE(secclass_map)); | ||
735 | audit_log_format(ab, " tclass=%s", secclass_map[sad->tclass-1].name); | 733 | audit_log_format(ab, " tclass=%s", secclass_map[sad->tclass-1].name); |
736 | 734 | ||
737 | if (sad->denied) | 735 | if (sad->denied) |
@@ -748,6 +746,9 @@ noinline int slow_avc_audit(struct selinux_state *state, | |||
748 | struct common_audit_data stack_data; | 746 | struct common_audit_data stack_data; |
749 | struct selinux_audit_data sad; | 747 | struct selinux_audit_data sad; |
750 | 748 | ||
749 | if (WARN_ON(!tclass || tclass >= ARRAY_SIZE(secclass_map))) | ||
750 | return -EINVAL; | ||
751 | |||
751 | if (!a) { | 752 | if (!a) { |
752 | a = &stack_data; | 753 | a = &stack_data; |
753 | a->type = LSM_AUDIT_DATA_NONE; | 754 | a->type = LSM_AUDIT_DATA_NONE; |