From: Jun Yao <yaojun8558363@gmail.com>
To: miklos@szeredi.hu
Cc: fuse-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
security@kernel.org, Jun Yao <yaojun8558363@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH] fuse: hold inode reference across d_splice_alias()
Date: Mon, 9 Nov 2026 17:40:06 +0800 [thread overview]
Message-ID: <20261109094006.205170-1-yaojun8558363@gmail.com> (raw)
When fuse_direntplus_link() calls d_splice_alias() with an inode
returned by fuse_iget(), d_splice_alias() can drop that reference
before returning an error. In particular, __d_unalias() can return
-ESTALE when it cannot move the old directory alias. The caller then
decrements nlookup through the inode pointer. A concurrent
FUSE_NOTIFY_INVAL_ENTRY can drop the last alias and let RCU free the
fuse_inode before that access.
Take an extra inode reference before d_splice_alias() and release it after
the nlookup rollback or after a successful splice.
Fixes: b8bd342d50cb ("fuse: nlookup missing decrement in fuse_direntplus_link")
Cc: stable@vger.kernel.org
Signed-off-by: Jun Yao <yaojun8558363@gmail.com>
---
fs/fuse/readdir.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c
index 1f6cf5654..aca25e5db 100644
--- a/fs/fuse/readdir.c
+++ b/fs/fuse/readdir.c
@@ -238,8 +238,11 @@ static int fuse_direntplus_link(struct file *file,
inode = fuse_iget(dir->i_sb, o->nodeid, o->generation,
&o->attr, ATTR_TIMEOUT(o),
attr_version, evict_ctr);
+ /* Keep inode alive if d_splice_alias() drops its reference. */
if (!inode)
inode = ERR_PTR(-ENOMEM);
+ else
+ ihold(inode);
alias = d_splice_alias(inode, dentry);
d_lookup_done(dentry);
@@ -254,9 +257,12 @@ static int fuse_direntplus_link(struct file *file,
spin_lock(&fi->lock);
fi->nlookup--;
spin_unlock(&fi->lock);
+ iput(inode);
}
return PTR_ERR(dentry);
}
+ if (!IS_ERR(inode))
+ iput(inode);
}
if (fc->readdirplus_auto)
set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state);
reply other threads:[~2026-11-09 9:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261109094006.205170-1-yaojun8558363@gmail.com \
--to=yaojun8558363@gmail.com \
--cc=fuse-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=security@kernel.org \
--cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®