]> Git Repo - J-linux.git/commitdiff
audit: return early if the filter rule has a lower priority
authorGaosheng Cui <[email protected]>
Sat, 16 Oct 2021 07:23:51 +0000 (15:23 +0800)
committerPaul Moore <[email protected]>
Mon, 18 Oct 2021 22:34:37 +0000 (18:34 -0400)
It is not necessary for audit_filter_rules() functions to check
audit fileds of the rule with a lower priority, and if we did,
there might be some unintended effects, such as the ctx->ppid
may be changed unexpectedly, so return early if the rule has
a lower priority.

Signed-off-by: Gaosheng Cui <[email protected]>
[PM: slight tweak to the subject line]
Signed-off-by: Paul Moore <[email protected]>
kernel/auditsc.c

index a4ba53f5354ea189217f9278f8ae2c4df073d5c7..6efb0bb909d09ed40eaf63037cdda36587e12677 100644 (file)
@@ -470,6 +470,9 @@ static int audit_filter_rules(struct task_struct *tsk,
        u32 sid;
        unsigned int sessionid;
 
+       if (ctx && rule->prio <= ctx->prio)
+               return 0;
+
        cred = rcu_dereference_check(tsk->cred, tsk == current || task_creation);
 
        for (i = 0; i < rule->field_count; i++) {
@@ -737,8 +740,6 @@ static int audit_filter_rules(struct task_struct *tsk,
        }
 
        if (ctx) {
-               if (rule->prio <= ctx->prio)
-                       return 0;
                if (rule->filterkey) {
                        kfree(ctx->filterkey);
                        ctx->filterkey = kstrdup(rule->filterkey, GFP_ATOMIC);
This page took 0.055447 seconds and 4 git commands to generate.