From: "Pádraig Brady" <P@draigBrady.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: avagin@openvz.org, "Ludovic Courtès" <ludo@gnu.org>
Subject: query re unlink() ... inotify ... open() race
Date: Sat, 12 Sep 2015 01:28:27 +0100 [thread overview]
Message-ID: <55F371AB.20805@draigBrady.com> (raw)
Hi,
We're noticing a rare race here with open() in tail(1), where this happens:
tail --follow=name "file"
/* "file" is unlinked() by another process */
read(IN_ATTRIB from inotify); /* for st_nlink-- */
open("file") /* Done to check if deleted, but this succeeds! */
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);
}
thanks,
Pádraig.
next reply other threads:[~2015-09-12 0:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-12 0:28 Pádraig Brady [this message]
2015-09-12 1:14 ` query re unlink() ... inotify ... open() race Al Viro
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=55F371AB.20805@draigBrady.com \
--to=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 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.