From: sashiko-bot@kernel.org
Cc: audit@vger.kernel.org
Subject: Re: [PATCH] audit: fix exe mark UAF in kill_rules()
Date: Mon, 21 Sep 2026 20:15:05 +0000 [thread overview]
Message-ID: <20260921201505.A121F1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921195921.4174830-2-Jeremy.Jean@oss.cyber.gouv.fr>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] audit: O(N) synchronize_rcu() inside kill_rules() loop
--
commit b7d5542dc56408775e37d42010c82f61694ec4f9
Author: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
audit: fix exe mark UAF in kill_rules()
This commit addresses a use-after-free when an audit tree is pruned by
reordering the removal of the executable mark after the rule is removed
from the rcu-visible list. It introduces a synchronize_rcu() call before
dropping the executable mark.
> diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
> index 1ed19b7759129..864a58b6e2caf 100644
> --- a/kernel/audit_tree.c
> +++ b/kernel/audit_tree.c
> @@ -553,11 +553,12 @@ static void kill_rules(struct audit_context *context, struct audit_tree *tree)
> if (rule->tree) {
> /* not a half-baked one */
> audit_tree_log_remove_rule(context, rule);
> - if (entry->rule.exe)
> - audit_remove_mark(entry->rule.exe);
> rule->tree = NULL;
> list_del_rcu(&entry->list);
> list_del(&entry->rule.list);
> + synchronize_rcu();
[Severity: High]
Does this code introduce a regression by calling synchronize_rcu() inside
the list_for_each_entry_safe() loop in kill_rules()?
Executing synchronize_rcu() inside a list iteration loop causes sequential
grace period waits for every rule being removed. Each wait typically takes
10 to 30 milliseconds. If an audit tree has many rules, this loop could
block the executing thread for seconds or even minutes.
Since kill_rules() is called with the global audit_filter_mutex held (and
often audit_cmd_mutex via audit_ctl_lock()), this prolonged lock-holding
blocks any other process attempting to acquire audit mutexes.
Because unprivileged users can trigger the deletion of watched directories,
could this result in a local denial of service and hung task panics?
Would it be safer to batch this operation by removing all rules from the
rcu list into a local list first, executing a single synchronize_rcu()
outside the loop, and then iterating the local list to remove the marks
and schedule freeing?
> + if (entry->rule.exe)
> + audit_remove_mark(entry->rule.exe);
> call_rcu(&entry->rcu, audit_free_rule_rcu);
> }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260921195921.4174830-2-Jeremy.Jean@oss.cyber.gouv.fr?part=1
next prev parent reply other threads:[~2026-09-21 20:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 19:59 [PATCH] audit: fix exe mark UAF in kill_rules() Jérémy Jean
2026-09-21 20:15 ` sashiko-bot [this message]
2026-09-22 6:38 ` Bradley Morgan
2026-09-22 11:26 ` Ricardo Robaina
2026-09-22 13:46 ` Jérémy Jean
2026-09-22 15:08 ` Bradley Morgan
2026-09-22 20:07 ` Ricardo Robaina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260921201505.A121F1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=audit@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.