From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.152 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796256557; b=UZMvtB5uCB/b0mZb12wj8kx99j9iiGrmksM2stue6RcPg+inWCjYPTq8iWtYuaDSK8jV WwkwRBwYCrXEnASw6mZyxOAyhXz2ooNHUxwU2S9VpcDkn61Ia9iT4DVp5TzD8tdV+ejjn QvswrPEGOrJ/+qd3dY2hfgIxmHrHP2mAnZJhuVyz1DjY8caLjQalZJrFikW4e8Y4iw9jP LJ222l2ZQ49L4L4hm0b8c+BXuSVOACAsTXCML4/KOIbLs0Z96zZ1+wFfzwIxNW9Ik8DJ/ dreQF5aRCJ0jJtoaUFPNVRGdUZ3hxcDOlZtJp8NBrCh2G+9gi/gCL5/GASvlceIeXjQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796256557; 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=Hazse95cZy/796XqWRKBynPLOo7yz85QrJk2yrP/J+M=; b=YJDEW6DLuimkVS6/2pvrs+pQLJybG9z3uhO7HXJ1cGnK7hqXc63HGySEqqf+cYrzlr4s 8jrVBClIDWWR/mbdupeYpjgF84FgRpa86Qx2Yml1//Xx+eCpVpNPHzAFn+e5WKAUXF2Xk X+ev05ECTouInho7qIuRFkfA2um4vHk96KcKI3qW2YOQZklqUhbadjs7QQTO7mIvZBrzL EPH9OJgoLlVUI9B8R+0YtCeb0qld01eVrd97UOa9ken0z/k6TL5inyNAY7+464UZiuFmZ S4sBMu0zG97MpNlNckJ78iQNAN50W0EpRFK7O38dBAd2zDNXJVzMjcDcT8QaepmNi1A== 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=UlUkVFvz; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=jwNeMWHo; arc=none smtp.remote-ip=202.12.124.152 Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F523606A32C for ; Thu, 3 Dec 2026 00:09:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0F523606A32C 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=UlUkVFvz; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=jwNeMWHo Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.stl.internal (Postfix) with ESMTP id 7822A7A01FC for ; Wed, 2 Dec 2026 19:09:16 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Wed, 02 Dec 2026 19:09:16 -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=1796256556; x=1796342956; bh=Hazse95cZy/796XqWRKBynPLOo7yz85QrJk2yrP/J+M=; b= UlUkVFvzcy1jnGq8zinRdAUyGq731g90CkLWGuWdBFAeDhQ9YPESaUUb9O5F3Lu9 9846eCN2DD8ugNwykdteCNMIvLPWV6yw7A09s1C5jonBs25uPkXkvdkaAeB2IRnU s8Uud2ZkqmeL7JdvSKETctmkIAYhwKdTw9Tu4xDw6sWlnG/ELKqatcJ3dkX8Nl5D IsvGfCzwLi6laqKXmJ5akueqjvNa86Qz5qyaMw4RcbXyK3aaI4gfhPHaOngo5RDr h/JKSeMSuNrmF88OQjt9FRU9Gyjl58upfsaDJZOdGZtHjwHVBrXjLYcF4bJAWGTu nEK/rZPZq2BTZs/hcBlu3A== 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=1796256556; x=1796342956; bh=H azse95cZy/796XqWRKBynPLOo7yz85QrJk2yrP/J+M=; b=jwNeMWHohoJnxnbxH rt6sFcnan/oc7IbhOy87OP8rlp7PceZmNt22gJW4K7/eqbL2u/oTgHj8QwSyvRmf RrLCdM1ejXQa4XtVRdQaWrxx9LeMSlh87ymekNr4XwQXEKy24rPsPYDc59gxjEnr MIpeyDQNt2uTIwgKYtbdqd1qnJVqbbf/0BgLLo67stW91qTwuRf6+n7Lm+usYJBs gVLACcafS/mtoiLxeZwN+UzeIyYaPmXcjaZzncpQFePHfEVBBDCv+R0HF0CO+Veb oQyfe+hFm4bz3LskZDMYoWeLge54pJD13HdIIONQr97kGKlyV2Lrusrt9mdp5i/L giOPA== 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=1796256556; d=ownmail.net; mf=PG5laWxiQG93bm1haWwubmV0Pg==; rt=PGxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:l5xU376qkf8cv2P72t2MQpqZJHQVJqQS7p3UjSO1SRkkTRJ bJPdZxdl58UvQvEvv51/E86Iwwa2RlL8PsJENnhL1nMug2pmcpJiBsbYMoIRvVkl /hHN6dYj3zsT7muyP/OJJgcVwZia05uITWn0ONhV1mbj+08lNS5GbQVeb30OWovk 1SsVJalO7Phj6r6k9us9pdtrztwxBr6POhRspP3nopvk8VlKqMgf61JsS//7zIkr p86SHOKqit1Mu10DC6vQdn6dtFS1eHPP91k7ze/ImXJC7lfFqcjmKHE6mtSppG93 DiC6ADhFV802UIHdrjU2iHJye69F0Ly1oq3rWDw==; 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:yHYx3HQHV6WXu8TsX1VQ568pWsJ4lfJiCHcGRAtr7xI=:7K6CkWn7TSu0hchaNAhwweAnjN2OXu4oztDe4uJCjDE=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEk7W2urxng3XGtsqgBSAihcmhsvNGvgXw20nbGEMVLbua2VpqSQVrQQ/bg3x9oHI 2U248MaPJhG1HzmtvnLR7bUOngaQ85sTLwQMHyZTX2+3WJ49HqLEx3VpN0ufoRwVheXDP9 1D+etNYMr6+5PlweDNJSWG483gtmONAADgd5K0nT21v2vfFhL8m4RTj+eg7dQ3ozUH7HQg MgdWvFgOGeSEuZmAnXMq9gn/Vv+Xdk6tiYB/+BCyjeg3w53kPBpMn3UVSHc5luDO87vMyU TngMqapyON7sXN+NdQktZie+TxW/kvzHrC5wvPlLBxT34IdTsnDVjZEExUIc0lXeC+WCYN toZTFipS6iAVbgXJT44fbOy3eJad/JNl9mFWnkvAcjtE+Sakpb3rGHQPNbYZWv2o2FRZxB +YRRKYep0ZdgT1flHhiVWDqx6FRvpToFoZtHL5G3Km1L5ddK7cigd/CQsKCUFIuEI6Xniv 24ugDHb/97ExE1ViUqM2KZIFgk7ls3x6hOXk+SMj859GpBwpsPUq8aRA5dE7cruqffO9M5 kidSKvJHqyM7zdvjC81so/OChkTFCgdTljKXVj9eR6TkipnFZ2Tg1a/tVYHv5JfSYEyxhq 7XumedfcO0/7gROkge8rAGaFMdDHmPNDxkCKaI1mHWwosOoNuKaCQj/8Mh0A X-ME-Proxy: Feedback-ID: i9d664b8f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 2 Dec 2026 19:09:15 -0500 (EST) From: NeilBrown To: linux-kernel@vger.kernel.org Subject: [PATCH 4/9] vfs: don't call ->atomic_open with hashed negative in non-O_CREAT case. Date: Thu, 3 Dec 2026 11:07:59 +1100 Message-ID: <20261203000848.2986775-5-neilb@ownmail.net> X-Mailer: git-send-email 2.50.0.107.gf914562f5916.dirty In-Reply-To: <20261203000848.2986775-1-neilb@ownmail.net> References: <20261203000848.2986775-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 f292d140c31f..87be2fe561f3 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