Commit 2424b0eb authored by Richard Guy Briggs's avatar Richard Guy Briggs Committed by Greg Kroah-Hartman
Browse files

audit: move put_tree() to avoid trim_trees refcount underflow and UAF

commit 67d69e9d upstream.

AUDIT_TRIM is expected to be idempotent, but multiple executions resulted
in a refcount underflow and use-after-free.

git bisect fingered commit fb041bb7	("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 8432c700 ("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 <>
Cc: Will Deacon <>
Cc: Alexander Viro <>
Cc: Seiji Nishikawa <>
Fixes: 8432c700

 ("audit: Simplify locking around untag_chunk()")
Signed-off-by: default avatarRichard Guy Briggs <>
Reviewed-by: default avatarJan Kara <>
[PM: reformatted/cleaned-up the commit description]
Signed-off-by: default avatarPaul Moore <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 7bf99c75
......@@ -593,7 +593,6 @@ static void prune_tree_chunks(struct audit_tree *victim, bool tagged)
......@@ -602,6 +601,7 @@ static void prune_tree_chunks(struct audit_tree *victim, bool tagged)
static void prune_one(struct audit_tree *victim)
prune_tree_chunks(victim, false);
/* trim the uncommitted chunks from tree */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment