]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
audit: fix removal of dangling executable rules
authorRicardo Robaina <rrobaina@redhat.com>
Wed, 13 May 2026 21:47:59 +0000 (18:47 -0300)
committerPaul Moore <paul@paul-moore.com>
Tue, 26 May 2026 23:00:15 +0000 (19:00 -0400)
When an audited executable is deleted from the disk, its dentry
becomes negative. Any later attempt to delete the associated audit
rule will lead to audit_alloc_mark() encountering this negative
dentry and immediately aborting, returning -ENOENT.

This early abort prevents the subsystem from allocating the temporary
fsnotify mark needed to construct the search key, meaning the kernel
cannot find the existing rule in its own lists to delete it. This
leaves a dangling rule in memory, resulting in the following error
while attempting to delete the rule:

 # ./audit-dupe-exe-deadlock.sh
 No rules
 Error deleting rule (No such file or directory)
 There was an error while processing parameters

 # auditctl -l
 -a always,exit -S all -F exe=/tmp/file -F path=/tmp/file -F key=dr

 # auditctl -D
 Error deleting rule (No such file or directory)
 There was an error while processing parameters

This patch fixes this issue by removing the d_really_is_negative()
check. By doing so, a dummy mark can be successfully generated for
the deleted path, which allows the audit subsystem to properly match
and flush the dangling rule.

Cc: stable@kernel.org
Fixes: 76a53de6f7ff ("VFS/audit: introduce kern_path_parent() for audit")
Acked-by: Waiman Long <longman@redhat.com>
Acked-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Ricardo Robaina <rrobaina@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
kernel/audit_fsnotify.c

index 711454f9f7242847f78e7eeed92db7a66be265e6..ae0e75403f7689237da3f9a0396d85903049f2a7 100644 (file)
@@ -84,10 +84,6 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
        dentry = kern_path_parent(pathname, &path);
        if (IS_ERR(dentry))
                return ERR_CAST(dentry); /* returning an error */
-       if (d_really_is_negative(dentry)) {
-               audit_mark = ERR_PTR(-ENOENT);
-               goto out;
-       }
 
        audit_mark = kzalloc_obj(*audit_mark);
        if (unlikely(!audit_mark)) {