From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754151AbbILA2b (ORCPT ); Fri, 11 Sep 2015 20:28:31 -0400 Received: from mail2.vodafone.ie ([213.233.128.44]:23032 "EHLO mail2.vodafone.ie" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752691AbbILA2a (ORCPT ); Fri, 11 Sep 2015 20:28:30 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsMFAHJw81VtTIH4/2dsb2JhbABdglFSgwSBFU7CCIE5TAEBAQEBAYELhE0ECwFGKA0CBSECEQJMDQEHAQGILgG3TYVvjiQsgSKEVosFgnCBQwWMd4hfjkaHRwyRWmOEAj2KUAEBAQ Message-ID: <55F371AB.20805@draigBrady.com> Date: Sat, 12 Sep 2015 01:28:27 +0100 From: =?UTF-8?B?UMOhZHJhaWcgQnJhZHk=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Linux Kernel Mailing List CC: avagin@openvz.org, =?UTF-8?B?THVkb3ZpYyBDb3VydMOocw==?= Subject: query re unlink() ... inotify ... open() race Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.