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=1796382382; b=hxf16IQLLBUkaduoFyp/lIN/Vp3bQGv7iH2ofMkTL7A8QOKlc+HCyeIPpbU3PQxJf8ab ExHliMaI5qL9LVEUaqdPhdTZw5NE4ps3TLuoNoVOybf5C7Uu1/bZ2hyvzjnOS9knKcKTS vbISdTVY/opzqaJas+ZOPgGCwuUSWtE1bWh5QQygsam7LSUD3hE7ILK32c968W2q5Z00t 0D+mpRTL9eOPmfPG21CwscuseByKToznVyYRBjsyuwPjyZUGXVjwIvlKhHjW4Ag6mK9YC gW5Og6gyssUFAfhpwmh3PW3Jt19nATc6+u0nlvGe5Pwwq9vFLG0jo18DyNMUOJDeprw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382382; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=Qon0qMyOax4Tq8eBvdc/vER9G7+kppm20EHTJy/XWR4=; b=0AvB+j261sZZYkTK8XJAyL5IfuACpnnFFtvgxrS3Y0QP1jdM94C42++pikB1wercy4LG SlHVaB8bECYYgHHv/OYbwmgHlPMo1U+x1+G7gnmcLU5GUEbqfTDKh73/PYphF5p2qomdj LzRwKJ2GcrzUqnN9EO8iU07kfK6SVjavKwANzlqKygZ7Xfu9NLvBJvX6z6KPLO7gIxdEP zgjUqd9dL3kuxy0K1Iavu9jo+B4ogbXBB6PIUpMOn+Qfb32h78GoE20dWT1RFhVEWpyMK FULojclt2gJtUEjBO1LKkUx7nfmIRgTA51UpjQ0PQzetrryW6vqRVR+DrV5DkAF/XWQ== 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=Y3hj4Mrx; 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 07FF4606A330; Fri, 4 Dec 2026 11:06:21 +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=Y3hj4Mrx Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B3B41F000C2; Fri, 4 Dec 2026 11:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382381; bh=Qon0qMyOax4Tq8eBvdc/vER9G7+kppm20EHTJy/XWR4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Y3hj4Mrxp1Q3OBGtC0DBpdqZEk7iWj10mICRclm94CgKafjWIayp8rfKzFqbuv2EV ngFLqDotIOGeNsxhkwOiKIV37TS6EkKJUzVikd8ukvfZI0a1n5febVnprGHOQT8GtI AzZKEGgQ3O3WDtNnwP0xUOXREPoJJEca0sVxSaOk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , Miklos Szeredi Subject: [PATCH 6.18 429/703] fuse: fix possible UAF in fuse_direntplus_link() Date: Fri, 4 Dec 2026 19:05:28 +0900 Message-ID: <20261204100639.235004395@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore 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-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miklos Szeredi commit 9191c2c1a76a759ac97be72481fdd4f9e920c902 upstream. In fuse_direntplus_link() a use-after-free occurs on struct fuse_inode when linking a newly allocated in-lookup dentry during FUSE_READDIRPLUS processing fails inside d_splice_alias(). When d_in_lookup(dentry) is true, fuse_iget() returns an inode with an incremented reference count and fi->nlookup, which is then passed to d_splice_alias(). Inside d_splice_alias_ops(), if the directory inode has an existing alias and splicing fails with -ELOOP in d_ancestor() or -ESTALE in __d_unalias(), the function drops the alias reference via dput(new) and unconditionally consumes the caller's inode reference via iput(inode) before returning the error pointer. If the existing alias is concurrently unhashed and dropped, iput(inode) drops the final inode reference and evicts the inode immediately via fuse_evict_inode(), sending a FUSE_FORGET request for fi->nlookup and freeing struct fuse_inode via RCU. Because fuse_direntplus_link() subsequently checks !IS_ERR(inode) outside an RCU read-side critical section, it dereferences the freed inode to acquire fi->lock and decrement fi->nlookup, and its caller parse_dirplusfile() then invokes fuse_force_forget() on the error return, issuing a duplicate FUSE_FORGET request to the server. Fixes: b8bd342d50cb ("fuse: nlookup missing decrement in fuse_direntplus_link") Cc: stable@vger.kernel.org #v6.6+ Reported-by: Sashiko Closes: https://sashiko.dev/#/bug/linux-0a00a32c-3732-46fe-9cdb-3c67a11903cc Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/fuse/readdir.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) --- a/fs/fuse/readdir.c +++ b/fs/fuse/readdir.c @@ -241,9 +241,13 @@ retry: inode = fuse_iget(dir->i_sb, o->nodeid, o->generation, &o->attr, ATTR_TIMEOUT(o), attr_version, evict_ctr); - if (!inode) - inode = ERR_PTR(-ENOMEM); + if (!inode) { + d_lookup_done(dentry); + dput(dentry); + return -ENOMEM; + } + ihold(inode); /* d_splice_alias() eats a reference */ alias = d_splice_alias(inode, dentry); d_lookup_done(dentry); if (alias) { @@ -251,15 +255,15 @@ retry: dentry = alias; } if (IS_ERR(dentry)) { - if (!IS_ERR(inode)) { - struct fuse_inode *fi = get_fuse_inode(inode); + struct fuse_inode *fi = get_fuse_inode(inode); - spin_lock(&fi->lock); - fi->nlookup--; - spin_unlock(&fi->lock); - } + spin_lock(&fi->lock); + fi->nlookup--; + spin_unlock(&fi->lock); + iput(inode); return PTR_ERR(dentry); } + iput(inode); } if (fc->readdirplus_auto) set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state);