From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.150 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796191585; b=WrtqWcUWZhr3J+/cJHYIuuhItpR+TRSNTxbutvxfWUAcTBMJqBTpU8oAPXlJWgJ9S2bg q6gS1hruhbCfaFD7HGuTfWc76XyL2bw3TkLAbueWI6B0oT8l3D8QbdLI1GRBi4XQPOVsB MIlkMktEQJsjyO/sWiPkaBzkxzgxDkD8tliDEpukLqOFt/6p5dz1DDSNJT8EVEG9lBV6j EblyZuFhe9yS9vYcx5CZa6rY5MTbiqzMDZwls5ul4GbWnjgJ6sT9gdd1Gy9/T76yU8AZm wssuU99PMBqxr79EhpWyE71lHEeukrODXXR/8N41K3O/GAKLGCZPcDeHtVTGaMym3Eg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796191585; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:From:To:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:Reply-To:MIME-Version:Content-Transfer-Encoding; bh=mdm4iwdlIquoZtsgU/81JPlDvAbiH+5iRyEwwG38f9s=; b=0l96DWBP+YzoRAqKXGivR/l8Q2ngAUOFMJSKy3UiS9XFssh+fnbAgUH3KANOKLskI9ay Oc8lptDfJLcNXZ65gidFV8dIox58ykBnp7W8m4ERgQBQUKe4TQ/OWfni10XP+UwZZOy2T YCnr2P6T81r/m63sGRfgRwIn95lYvs5Cr53hiCRspRM1o/8iGcnw93Gw4ilgrJLPBU4CO VkmbWY3kuIC1fHMIsmkff8/MgV2j1eVaoLesXPoghgJ0xxJmTgtMVpugTXJOSrEbnLs8l ss7rnoDx0i1J0+EoTvpTYlXgJmxfmDKgbn//031nlJEnhYVHbNHUIAJa/qlzuQZwwPw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=ownmail.net; spf=pass smtp.mailfrom=ownmail.net; dkim=pass header.d=ownmail.net header.i=@ownmail.net header.a=rsa-sha256 header.s=fm3 header.b=eDS7S8ir; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=nwt5udbV; arc=none smtp.remote-ip=103.168.172.150 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A60A7606A31A for ; Wed, 2 Dec 2026 06:06:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A60A7606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ownmail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ownmail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=ownmail.net header.i=@ownmail.net header.a=rsa-sha256 header.s=fm3 header.b=eDS7S8ir; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=nwt5udbV Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id ABEE2EC053E for ; Wed, 2 Dec 2026 01:06:23 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Wed, 02 Dec 2026 01:06:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ownmail.net; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:subject:subject:to:to; s=fm3; t=1796191583; x=1796277983; bh=mdm4iwdlIquoZtsgU/81JPlDvAbiH+5iRyEwwG38f9s=; b= eDS7S8irNri8eOI4HshSu7nzSOzREUZgCM0x3AS9ksglxcd60yTe+B/Mitoyv/6I ZB9ZkFFJr4NFGV34D7a1MMoefPjrI4YrMl5VgwoumSLwuYT7fif4cfP2eTlduTaR patCIkcmwQghncjyLQmTvykYm3ineo/LxA4MYjY177+ivxyLKiYzMxgGOI+m3NQm sEhqmuCazvYAudDzqya3w6G9AoTi+VDs6j2WH5LUXbYx0XpSBIKlaPBJ5jiJHePR kD9Mdx28EkqpC1pt23E0ojgthmrvJfIScHioQBcH6+RLVGvrk9Shf0MG7QGcVm4e cLrYoPIqLxfZBUGEeeY+Gw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1796191583; x=1796277983; bh=m dm4iwdlIquoZtsgU/81JPlDvAbiH+5iRyEwwG38f9s=; b=nwt5udbVXIvMEnPi4 eAgfXeR/J2LTeuysup/WGFV7JZhmIy1OGNHWDVq00ctPxpSAzMgvzZW5dYsgR9jA luKxqOPulZd+uOcUctAAev9N8g94YMSLEGQPFmzsd6IJHax7QFBAKfY9YNm8vbcb 3nl+i50RkWUyX/wGXrZpjrIJduBbtPnPsmKpE6FISBNXCy/Hv6ivx5Q4jQTHNT98 wFpM8T4ddPjgLsEburJSGomjoMPjCeRKQ8TWiFqceJ7uxGmi0H5IbfxPvguwJXGj grOLY8N8sFzuRAKBgtTeB17j/Qqrvv6XuUGxy4Dj3bIchenbQgNl46+MxMb/myUq d9+Sg== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=ownmail.net a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796191583; d=ownmail.net; mf=PG5laWxiQG93bm1haWwubmV0Pg==; rt=PGxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:lAboxEWkNn3g3eIXm3ZLBjg4gf3pGVMOG9keBuHzgYnnntc lFFM2stlCrNLxIkeDWc018zNQtRkV+qPY2xQMBQS8o/2YZgxLIOaZcXEoge/MPBq VHFLXSa8HTNdoe9CiaBS+5ovVIu9X5DB/mK0pe8Rm5g90yCMnjzx0Rihm1cAyRYy YOCCMoxu85+c88rtmMQop3LWwyrqcaeBJhWVs8YxJBPTTboNPlNeLW2s65EalijX 0bCXIGvMEPa0jfU0EFrbTcFLe8edo5of2vNMa5tmgE7cOwmKDJPvW9tzNrhAhNaf OFkgIoTk+GsDQL/lZErMNGPRPsjDkwkQLpoYZ6Q==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=11; hn=content-transfer-encoding,date,feedback-id,from,in-reply-to, message-id,mime-version,references,reply-to,subject,to; Message-Instance: m=1; h=sha256:OAXBvMJUhHFS1vF4YV4hpnvpWLLgagKuzkT4mDfEyfE=:gw2SkGseJ8m0GagTlEeLc7r/lpmdRn6Oxmz2xa2GzDY=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGZ3lt220K/B4n2r84XqZOqOjVfjC/YTKUm3PBvRK7lHae6tL5fhHPHqOXOYZPhMx /CyrBlhnirgDB1v+8DG8+3MZ6HToRvryBePyE8sd/h2caSjeMd5Bj0vfE6I2UA395yhbDK K5Ex3mPebPF2KDGBdM8VRomyEs6i0wTgPFUZf3awS4z2M9FBhvblJaG2+PhphO8Id8vJVU epSEfSqKRfLtbmjL+gxk74WgAFdZ88349h6hNwQxbncbnqAPMCQR9BGOIPPKlBZk9qltW4 usHRAZJbigydiaeRVMl2yvguN3n2FDoec3/xoXbJZzPvXi36hcro39EdD1ESqLLzLmjBNu LuUNCXbW0BS8GKBTuu3DI86PNtgZt5jCrx58P6U1jriV2ThaxKQQPNdDkaDcnWR/u47ZKf qMiV/enLK1sDe+sEgGc7Bz7DsARNBkmVd8Z224WBM44mCkY3A4fyCcjasvKTRiLeel4O/J 9QgT5m5yUjCWiGpewHujuwtEISFk/Cu1wcJqnH/ZxTyNS9yvhVziLTg58bFGaBttuD7LJb /bzZW8Xemzp9CmhR9gzcsvjm2gNAkOFGtIpUk49C2ZQewwu+8jWwE0slUBg0a706pO1D1h sCVMclcR3P82vjBGRZJ3C2EZRBq/mf6pXuHk2QmgKF25b0U6Uh4kSqKhY98Q X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 2 Dec 2026 01:06:22 -0500 (EST) From: NeilBrown To: linux-kernel@vger.kernel.org Subject: [PATCH 3/8] vfs: don't call ->atomic_open with hashed negative in non-O_CREAT case. Date: Wed, 2 Dec 2026 17:05:03 +1100 Message-ID: <20261202060607.2627366-4-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20261202060607.2627366-1-neilb@ownmail.net> References: <20261202060607.2627366-1-neilb@ownmail.net> Reply-To: NeilBrown X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: NeilBrown If lookup_fast_for_open() finds a hashed-negative dentry and O_CREAT wasn't requested, it will be returned to open_last_lookups() which will bypass lookup_open() and no call to nfs_atomic_open() will be attempted. However if it doesn't find a hashed dentry, but lookup_open() does find a hashed-negative, then that dentry *will* be passed to ->atomic_open. This is inconsistent and somewhat problematic. When O_CREAT was requested (even if it isn't passed to ->atomic_create due to permission issues), ->atomic_open will have exclusive access to the dentry. When the dentry is d_in_lookup(), ->atomic_open again has exclusive access. The dentry cannot be positive (that case is handled in lookup_open()) but if it is negative but O_CREAT wasn't requested then ->atomic_open will not have exclusive access. NFS currently has code to handle this which should not be necessary. To provide a more consistent context for ->atomic_open handle the hashed-negative-without-O_CREAT case in lookup_open(). Signed-off-by: NeilBrown --- Documentation/filesystems/vfs.rst | 13 +++++-------- fs/namei.c | 4 ++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst index c1f3ea7aad67..d1d32540e85f 100644 --- a/Documentation/filesystems/vfs.rst +++ b/Documentation/filesystems/vfs.rst @@ -648,14 +648,11 @@ otherwise noted. needs lookup. Cached positive dentries are still handled by f_op->open(). - If the dentry provided is negative (not in-lookup) and O_CREAT - isn't set, then there is no guarantee of exclusive access to the - dentry - another thread might call ->atomic_open() on the same - dentry at the same time. If needed, a filesystem can ensure this - doesn't happen by returning 0 from ->d_revalidate when that is - called with LOOKUP_OPEN on a negative dentry. This will ensure - that ->atomic_open() only receives an in-lookup dentry, which - always ensures exclusive access. + It is guaranteed that this method has exclusive access to the + dentry. If it is not in-lookup, then O_CREAT was requested + and the parent is locked exclusively. This will be the case + even if O_CREAT isn't still set in open_flag (it may be cleared + if permissions checks show that creation is not permitted). ``tmpfile`` called in the end of O_TMPFILE open(). Optional, equivalent to diff --git a/fs/namei.c b/fs/namei.c index bff4dfaf6721..441560ba755a 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4608,6 +4608,10 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, if (dentry->d_inode) { /* Cached positive dentry: will open in do_open(). */ goto out; + } else if (!d_in_lookup(dentry) && !(open_flag & O_CREAT)) { + /* Cached negative dentry without O_CREAT */ + error = -ENOENT; + goto out_dput; } if (open_flag & O_CREAT) -- 2.50.0.107.gf914562f5916.dirty