Skip to content

Commit d9516f3

Browse files
gscuipcmoore
authored andcommitted
audit: return early if the filter rule has a lower priority
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]>
1 parent 571e5c0 commit d9516f3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/auditsc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ static int audit_filter_rules(struct task_struct *tsk,
470470
u32 sid;
471471
unsigned int sessionid;
472472

473+
if (ctx && rule->prio <= ctx->prio)
474+
return 0;
475+
473476
cred = rcu_dereference_check(tsk->cred, tsk == current || task_creation);
474477

475478
for (i = 0; i < rule->field_count; i++) {
@@ -737,8 +740,6 @@ static int audit_filter_rules(struct task_struct *tsk,
737740
}
738741

739742
if (ctx) {
740-
if (rule->prio <= ctx->prio)
741-
return 0;
742743
if (rule->filterkey) {
743744
kfree(ctx->filterkey);
744745
ctx->filterkey = kstrdup(rule->filterkey, GFP_ATOMIC);

0 commit comments

Comments
 (0)