aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorRichard Guy Briggs <rgb@redhat.com>2013-11-21 13:31:40 -0500
committerEric Paris <eparis@redhat.com>2014-01-13 22:32:00 -0500
commit9ad42a79247d5e16d26f7d1531a68f20a889c5af (patch)
tree3d0af9e44b66f8738b4be24ac82b560612b68ece /security
parent4440e8548153e9e6d56db9abe6f3bc0e5b9eb74f (diff)
selinux: call WARN_ONCE() instead of calling audit_log_start()
Two of the conditions in selinux_audit_rule_match() should never happen and the third indicates a race that should be retried. Remove the calls to audit_log() (which call audit_log_start()) and deal with the errors in the caller, logging only once if the condition is met. Calling audit_log_start() in this location makes buffer allocation and locking more complicated in the calling tree (audit_filter_user()). Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'security')
-rw-r--r--security/selinux/ss/services.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index b4feecc3fe01..f4dda05d7db0 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -2938,25 +2938,21 @@ int selinux_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule,
2938 struct selinux_audit_rule *rule = vrule; 2938 struct selinux_audit_rule *rule = vrule;
2939 int match = 0; 2939 int match = 0;
2940 2940
2941 if (!rule) { 2941 if (unlikely(!rule)) {
2942 audit_log(actx, GFP_ATOMIC, AUDIT_SELINUX_ERR, 2942 WARN_ONCE(1, "selinux_audit_rule_match: missing rule\n");
2943 "selinux_audit_rule_match: missing rule\n");
2944 return -ENOENT; 2943 return -ENOENT;
2945 } 2944 }
2946 2945
2947 read_lock(&policy_rwlock); 2946 read_lock(&policy_rwlock);
2948 2947
2949 if (rule->au_seqno < latest_granting) { 2948 if (rule->au_seqno < latest_granting) {
2950 audit_log(actx, GFP_ATOMIC, AUDIT_SELINUX_ERR,
2951 "selinux_audit_rule_match: stale rule\n");
2952 match = -ESTALE; 2949 match = -ESTALE;
2953 goto out; 2950 goto out;
2954 } 2951 }
2955 2952
2956 ctxt = sidtab_search(&sidtab, sid); 2953 ctxt = sidtab_search(&sidtab, sid);
2957 if (!ctxt) { 2954 if (unlikely(!ctxt)) {
2958 audit_log(actx, GFP_ATOMIC, AUDIT_SELINUX_ERR, 2955 WARN_ONCE(1, "selinux_audit_rule_match: unrecognized SID %d\n",
2959 "selinux_audit_rule_match: unrecognized SID %d\n",
2960 sid); 2956 sid);
2961 match = -ENOENT; 2957 match = -ENOENT;
2962 goto out; 2958 goto out;