From: Al Viro <viro@ZenIV.linux.org.uk>
To: "Pádraig Brady" <P@draigBrady.com>
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
avagin@openvz.org, "Ludovic Courtès" <ludo@gnu.org>
Subject: Re: query re unlink() ... inotify ... open() race
Date: Sat, 12 Sep 2015 02:14:51 +0100 [thread overview]
Message-ID: <20150912011449.GP22011@ZenIV.linux.org.uk> (raw)
In-Reply-To: <55F371AB.20805@draigBrady.com>
On Sat, Sep 12, 2015 at 01:28:27AM +0100, Pádraig Brady wrote:
> The open() succeeding is surprising. Is that allowed?
> The summary of the sequence in the kernel is:
>
> vfs_unlink() {
> mutex_lock(&(dentry->d_inode->i_mutex));
> security_inode_unlink(dir, dentry);
> try_break_deleg(target, delegated_inode);
> dir->i_op->unlink(dir, dentry);
> dont_mount(dentry);
> detach_mounts(dentry);
> mutex_unlock(&(dentry->d_inode->i_mutex));
>
> fsnotify_link_count(target)
> d_delete(dentry);
> }
... and ->unlink() is the one to decrement the link count. With lookup
via dcache coming at some point after that. idiotify is a red herring
here - stat(2) will report decremented link count just as well.
prev parent reply other threads:[~2015-09-12 1:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-12 0:28 Pádraig Brady
2015-09-12 1:14 ` Al Viro [this message]
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=20150912011449.GP22011@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=P@draigBrady.com \
--cc=avagin@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ludo@gnu.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
Powered by JetHome