Skip to content

Commit 67d69e9

Browse files
rgbriggspcmoore
authored andcommitted
audit: move put_tree() to avoid trim_trees refcount underflow and UAF
AUDIT_TRIM is expected to be idempotent, but multiple executions resulted in a refcount underflow and use-after-free. git bisect fingered commit fb041bb ("locking/refcount: Consolidate implementations of refcount_t") but this patch with its more thorough checking that wasn't in the x86 assembly code merely exposed a previously existing tree refcount imbalance in the case of tree trimming code that was refactored with prune_one() to remove a tree introduced in commit 8432c70 ("audit: Simplify locking around untag_chunk()") Move the put_tree() to cover only the prune_one() case. Passes audit-testsuite and 3 passes of "auditctl -t" with at least one directory watch. Cc: Jan Kara <[email protected]> Cc: Will Deacon <[email protected]> Cc: Alexander Viro <[email protected]> Cc: Seiji Nishikawa <[email protected]> Cc: [email protected] Fixes: 8432c70 ("audit: Simplify locking around untag_chunk()") Signed-off-by: Richard Guy Briggs <[email protected]> Reviewed-by: Jan Kara <[email protected]> [PM: reformatted/cleaned-up the commit description] Signed-off-by: Paul Moore <[email protected]>
1 parent d97e993 commit 67d69e9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/audit_tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ static void prune_tree_chunks(struct audit_tree *victim, bool tagged)
593593
spin_lock(&hash_lock);
594594
}
595595
spin_unlock(&hash_lock);
596-
put_tree(victim);
597596
}
598597

599598
/*
@@ -602,6 +601,7 @@ static void prune_tree_chunks(struct audit_tree *victim, bool tagged)
602601
static void prune_one(struct audit_tree *victim)
603602
{
604603
prune_tree_chunks(victim, false);
604+
put_tree(victim);
605605
}
606606

607607
/* trim the uncommitted chunks from tree */

0 commit comments

Comments
 (0)