From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796221081; b=K4nm4gfqIHAQv43RkvoA75tkTgeOhpdhI1eLikLfsfrZYgL8JTrEZYyHIdamVzeB9zLd YJ+Qki/Kd2x2pm3O1kJFg/GxSHGFJC8k6NXp0YelI4ODDu/sg8mbU5+SyqkRy9N21jjgq zC3it3ifCetxoBgS9Ynt/9bqGaZlfqYhuDUBEv2fzPt9ef7g5uC/wZbBSJXvcu1sFIZ6W 2CO2cVgr0y6gPHUP3R5aRcYQbSzIitzHUE18g/Hgj2V10yWRTVMN/Z2QZ7lF7m0qyBHf1 PDXSi7MB6kDFf6tZ9/rXFSOXf/Eb8Fb9qGB3EzwDuoWjXOaBkvIK9JX0JFyLcdmZNfA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796221081; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=q/mDbcS2utd7yhi/Pn9fi3vAnQe+ui9n2bgXI7yl2kY=; b=LBNiDUml24fxBUWxz2UftuHD7LIMB6TcF2+fy1akPr8GeQk47nnKRQIekCqAzi6vYfjx 8HA+InIP8Sfp0eZgpxYx06fHDImQWIaDVQpzutfESVInrnXPy2WX4JnTQZi9iNQaxXthb msIKgt6IxTxPyldE/ue2/iKwl+T9z1kvuFsMzpXDCdaVEhhO0qrSgfXQFgmcpY0ziq7nx ykfDuMAHfBicKKMbvPuyxAOvfaHohDuBrUU1r6vREdhWOfbtQzKt5fGNqpMAthYEtsjnQ Yy/xqocMRXPBB+aMs208XUTHa9iZ6ecpMYMod5kF7Ar2Z1yuPp0dw9cDv4Qp17E4m6w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=TEVKhkpw; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (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 A6C64606A31A for ; Wed, 2 Dec 2026 14:18:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=TEVKhkpw Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47EA41F0089A; Wed, 2 Dec 2026 14:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796221080; bh=q/mDbcS2utd7yhi/Pn9fi3vAnQe+ui9n2bgXI7yl2kY=; h=Subject:To:Cc:From:Date; b=TEVKhkpw2iedQ/q/VN+QMCwfHsHDelL1cns8hEGWSgAThhfWHNISsSDR7UNYwN9B8 7aH7heq+PMZdkYs3Y0cw0g5nne/nfoBxY3/Dc+xLkmqXRNou95P2YQtzjPG21CDXWF zkzQR3MObw36UjTYdueFT3lhAjBw3gq39f6ATzBI= Subject: FAILED: patch "[PATCH] fuse: set dentry epoch before making the dentry visible" failed to apply to 6.18-stable tree To: leonming@meta.com,mszeredi@redhat.com Cc: From: Date: Wed, 02 Dec 2026 14:03:39 +0100 Message-ID: <2026120239-hypnotic-spectacle-6177@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.18-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y git checkout FETCH_HEAD git cherry-pick -x fea42fae07822cd717ba4b3082834bb5908bf911 # git commit -s git send-email --to '' --in-reply-to '2026120239-hypnotic-spectacle-6177@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From fea42fae07822cd717ba4b3082834bb5908bf911 Mon Sep 17 00:00:00 2001 From: Leon Ming Date: Wed, 28 Oct 2026 20:37:00 -0700 Subject: [PATCH] fuse: set dentry epoch before making the dentry visible fuse_lookup(), create_new_entry(), fuse_create_open() and fuse_direntplus_link() set the dentry epoch only after d_splice_alias() or d_instantiate() has made the dentry visible. A new dentry starts at epoch 0 and the connection at epoch 1, so in that window a concurrent lookup can find the dentry, fail fuse_dentry_revalidate() and d_invalidate() it. The original lookup then returns an unhashed dentry, and readlink() of /proc/self/fd/N on an O_PATH fd for it says " (deleted)" for a file that exists. Anything that resolves real paths with open(O_PATH) + readlink() can pick up the bogus path; TypeScript's native compiler (tsgo) intermittently fails to find installed packages this way. It got much more common after commit 5a6baf204610 ("fuse: fix uninit-value in fuse_dentry_revalidate()") zeroed the initial epoch; before that, slab garbage usually passed the check. Set the epoch before the dentry is published, and keep setting it on any alias that d_splice_alias() returns; the dentry that loses to an alias is dropped without ever being visible, so setting it too is harmless. With 32 processes making concurrent first lookups of 6000 files on a fresh squashfuse_ll mount (UML, 16 CPUs), 1652 of 10.75M lookups came back "(deleted)" before this patch and none after. Fixes: 2396356a945b ("fuse: add more control over cache invalidation behaviour") Cc: stable@vger.kernel.org Signed-off-by: Leon Ming Signed-off-by: Miklos Szeredi diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index da23ccd8685c..a04d93d5fc44 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -644,13 +644,17 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, if (inode && get_node_id(inode) == FUSE_ROOT_ID) goto out_iput; + /* Set before the dentry is visible, or a racing lookup invalidates it */ + fuse_dentry_set_epoch(entry, epoch); newent = d_splice_alias(inode, entry); err = PTR_ERR(newent); if (IS_ERR(newent)) goto out_err; - entry = newent ? newent : entry; - fuse_dentry_set_epoch(entry, epoch); + if (newent) { + entry = newent; + fuse_dentry_set_epoch(entry, epoch); + } if (outarg_valid) fuse_change_entry_timeout(entry, &outarg); else @@ -907,8 +911,8 @@ static int fuse_create_open(const struct mnt_idmap *idmap, struct inode *dir, goto out_err; } kfree(forget); - d_instantiate(entry, inode); fuse_dentry_set_epoch(entry, epoch); + d_instantiate(entry, inode); fuse_change_entry_timeout(entry, &outentry); fuse_dir_changed(dir); err = generic_file_open(inode, file); @@ -1030,6 +1034,7 @@ static struct dentry *create_new_entry(const struct mnt_idmap *idmap, struct fus fuse_chan_queue_forget(fm->fc->chan, forget, outarg.nodeid, 1); return ERR_PTR(-ENOMEM); } + fuse_dentry_set_epoch(entry, epoch); kfree(forget); d = d_splice_alias(inode, entry); @@ -1040,7 +1045,6 @@ static struct dentry *create_new_entry(const struct mnt_idmap *idmap, struct fus fuse_dentry_set_epoch(d, epoch); fuse_change_entry_timeout(d, &outarg); } else { - fuse_dentry_set_epoch(entry, epoch); fuse_change_entry_timeout(entry, &outarg); } fuse_dir_changed(dir); diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c index f4f9590f8ae5..e56cdd88513a 100644 --- a/fs/fuse/readdir.c +++ b/fs/fuse/readdir.c @@ -228,6 +228,7 @@ static int fuse_direntplus_link(struct file *file, fuse_change_attributes(inode, &o->attr, NULL, ATTR_TIMEOUT(o), attr_version); + fuse_dentry_set_epoch(dentry, epoch); /* * The other branch comes via fuse_iget() * which bumps nlookup inside @@ -242,6 +243,7 @@ static int fuse_direntplus_link(struct file *file, return -ENOMEM; } + fuse_dentry_set_epoch(dentry, epoch); ihold(inode); /* d_splice_alias() eats a reference */ alias = d_splice_alias(inode, dentry); d_lookup_done(dentry); @@ -258,11 +260,12 @@ static int fuse_direntplus_link(struct file *file, iput(inode); return PTR_ERR(dentry); } + if (alias) + fuse_dentry_set_epoch(dentry, epoch); iput(inode); } if (fc->readdirplus_auto) set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state); - fuse_dentry_set_epoch(dentry, epoch); fuse_change_entry_timeout(dentry, o); dput(dentry);