mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: "Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>, audit@vger.kernel.org
Cc: "Eric Paris" <eparis@redhat.com>,
	linux-kernel@vger.kernel.org,
	"Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>
Subject: Re: [PATCH] audit: avoid dropping live tree ref on fsnotify rule  autoremove
Date: Wed, 12 Aug 2026 16:46:53 -0400	[thread overview]
Message-ID: <ab0a41e0c2a549f8d684706c02b671c1@paul-moore.com> (raw)
In-Reply-To: <20260811220128.275783-1-Jeremy.Jean@oss.cyber.gouv.fr>

On Aug 11, 2026 =?UTF-8?q?J=C3=A9r=C3=A9my=20Jean?= <Jeremy.Jean@oss.cyber.gouv.fr> wrote:
> 
> audit_del_rule() is used for both netlink deletion templates and internal
> fsnotify autoremove.  The former passes a parsed template which owns a
> temporary tree reference; the latter passes the installed entry itself.
> 
> The unconditional audit_put_tree() at the end of audit_del_rule() assumes
> the template case.  For mixed AUDIT_DIR plus AUDIT_EXE rules, an fsnotify
> autoremove event therefore drops the installed rule's live tree reference.
> Repeating this across rules sharing the same tree can free the tree while
> another rule still references it, and a later autoremove dereferences the
> freed pathname while comparing rules.
> 
> Move the temporary-tree put to audit_rule_change(), the caller that owns
> deletion templates.  Keep it in the AUDIT_DEL_RULE cleanup so both
> successful deletion and -ENOENT still release the parser-owned tree.
> 
> Fixes: 34d99af52ad4 ("audit: implement audit by executable")
> Assisted-by: Codex:gpt-5
> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> Reviewed-by: Ricardo Robaina <rrobaina@redhat.com>
> Tested-by: Ricardo Robaina <rrobaina@redhat.com>
> ---
>  kernel/auditfilter.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

Thanks for finding this and submitting a fix!

This looks good to me too, so I'm going to merge this, but instead of the
normal audit/stable-7.2 branch, I'm going to merge this into the audit/dev
branch since we are likely only a few days away from a v7.2 release and I
think it would be good to get some additional testing.  I am going to tag
this commit with a stable tag so it will/should get backported once it
lands in Linus' tree.

--
paul-moore.com

  parent reply	other threads:[~2026-08-12 20:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11 22:01 Jérémy Jean
2026-08-12 15:59 ` Ricardo Robaina
2026-08-12 20:46 ` Paul Moore [this message]
2026-08-13 18:38 ` Richard Guy Briggs

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=ab0a41e0c2a549f8d684706c02b671c1@paul-moore.com \
    --to=paul@paul-moore.com \
    --cc=Jeremy.Jean@oss.cyber.gouv.fr \
    --cc=audit@vger.kernel.org \
    --cc=eparis@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®