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=1796380911; b=mDD0zc3yDJKbBRGxNvmGd/K4I4d3+ZaESBxxePDnBG35njcRpf5t+0UbgllqE75K7/PI TR//wpDScfseXG0rMGNeOMl8VkqwzWJUuPZwhMyUn8rJ/ZSiOATU6axAlVkjEbjGAQ6V0 Iw+RgYlk0r9tCUry0Z/pUwNa0NbRzD6gRMTksyOoZlbl8azohcMgrICEsiB27LhF+bGib A6U9c5oh1vdKRVJmMp/chYbRuhLBkeIW1gXlRngZIAKyVXGgcrjhW4pzYKk991WVnFbE/ FNNP6LXMFtkaGOHaqtUu6YB7IotCiMMkIK262wlQB2x38JfCAx5ARUcrF2psa0hPa8A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380911; 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=cp93mZRCIotHiuyfUc/3QLEaD3FTwgMB2A0477dF/1c=; b=uoKfXC2zTDc9NzSUel1QIJqxB8AKfXbDBcveuMs04xfYkEpAw0K0K34f19LdOuAm4UwZ dnuBDaDF+A56JoRA0M5fD0ds/zImtg7R9Njji8bck5zGIbQWKsqAO9VA4mzXbFq/HRHPd AhogDeH/kHG/GjD8vNsb6AVjf8jfSHfsN5H9l7xEEfDbR3kDnILqJfRgo2iyFnf3CSdg9 +C9rXtaoA2k/+dKvMsUy7R9PQX7PQn1KtT+RkQ18PfTHGXojDVzMpWgUhSCs4BzW/viwa zw1+72oMitvyL341wSUvGExH7tLVrv8acBNOaBmFXWytUISyXNqsHP4OexSv7eku9FA== 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=blmnv6x5; 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 8D2EE606A32C; Fri, 4 Dec 2026 10:41:51 +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=blmnv6x5 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E74981F000CE; Fri, 4 Dec 2026 10:41:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380911; bh=cp93mZRCIotHiuyfUc/3QLEaD3FTwgMB2A0477dF/1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=blmnv6x5twW9o6gTkYA88AMxY9zZu1ygm+FFXlaT1rew/cUQ38WaVcIHO9FJ5IN1R 5AwOlpcvrDR8oX3PZ6XQheN9j03ev0GU2o4lm9aOWOFXDG419YywRK6mhx3V3BRJTI EjJj43RzKkQTDKvzCdkkeztGc7lgXClMBb3QP2us= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , Miklos Szeredi Subject: [PATCH 7.3 476/742] fuse: fix possible UAF in fuse_direntplus_link() Date: Fri, 4 Dec 2026 19:05:40 +0900 Message-ID: <20261204100647.793888668@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-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 @@ -238,9 +238,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) { @@ -248,15 +252,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);