From: Daehyeon Ko <4ncienth@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Amir Goldstein <amir73il@gmail.com>,
Miklos Szeredi <mszeredi@redhat.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [BUG] fanotify: destroy/add race leaves a mark on a detached connector
Date: Fri, 28 Aug 2026 13:24:19 +0900 [thread overview]
Message-ID: <20260828042421.964822-1-4ncienth@gmail.com> (raw)
In-Reply-To: <yjfqzckumtd32dgqidi5sndvth2t67mjwah4kt4jiahlx2a5uf@if55sinfv5o7>
Hi Honza,
You are right that an fd-held dentry cannot satisfy the count == 1 check. I
was imprecise in the report: the fd and the final unlink refer to two
different hard-link dentries for the same inode.
The setup is:
1. create A/x and link it as B/y;
2. open B/y, add the old-group inode mark through that fd, then unlink
B/y, leaving i_nlink == 1 while the fd retains the B/y dentry;
3. race these two calls:
unlink("A/x")
fanotify_mark(racer_group, FAN_MARK_ADD, FAN_MODIFY,
victim_fd, NULL)
where victim_fd still refers to the already unlinked B/y dentry.
So the A/x dentry checked by d_delete() is not held by the fd and can have
d_lockref.count == 1. Its unlink drops the inode's last link and reaches
dentry_unlink_inode() -> fsnotify_inoderemove(). At the same time,
fanotify_find_path() gets the same inode through the fd-held B/y dentry and
adds the racer mark.
Your suspicion matches this topology: __fsnotify_inode_delete() from
fsnotify_inoderemove() is running while the inode is still live and reachable
through the other, fd-held dentry. Deferring mark cleanup until
__destroy_inode() would avoid this particular add-versus-cleanup race. I have
not audited the broader consequences of that change yet.
I can send the exact reproducer privately if that would be useful.
Thanks,
Daehyeon
next prev parent reply other threads:[~2026-08-28 4:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 4:50 Daehyeon Ko
2026-08-27 12:45 ` Amir Goldstein
2026-08-27 16:30 ` Jan Kara
2026-08-28 4:24 ` Daehyeon Ko [this message]
2026-08-28 9:05 ` Jan Kara
2026-08-28 10:18 ` Amir Goldstein
2026-08-28 17:36 ` Jan Kara
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=20260828042421.964822-1-4ncienth@gmail.com \
--to=4ncienth@gmail.com \
--cc=amir73il@gmail.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mszeredi@redhat.com \
/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®