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=1796383820; b=B2ojZkTyJxuzTsImFM396y1BoFKse8wBiw0noJ5xjj7/HkUI5uP7fSun6SMoelPjISsU Df9rpFgFU+ro2HflY8igQLC5OvUEcGGsZEf00G0U22DYGN91dh1DHvZ9GCMIj3d8telId rAdw526ZM+B362WSm4beBziCkMZz5VLNJ+KMsNuE4fk0SQyGSIrl6nxeYeU2KU6rn3ZC1 yBi0eyj2AgGxmOHwXqoNVEvVhc7616XHyZsowb2MYowTblWyYes27K7CK+bNS5s3176La kqkoQ1kLFdb8ish0PyRGH69AuG3NtTEGyN1FLmZJCFNRFQD9N5AntjNdI3FEGtZXOjA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383820; 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=BjygNJGIUfEJHOsvpaAw9fJxCSm69Zq0V2E1DWxO2eY=; b=wB+w/fvlVAlwRkB5lUUd8PZVzUXj1TtDLN+yQdet4uk5fZeiiuMjIwoBQWaqtU+vGX+S dx7wy3Fs6aSfX7STNfUNw62pSD7WnA+rxQ7H0J0QS5oraqnKpZo2YjUdrQUZcC9v8944k cxQ8Qv9C8Vu5G9qsLcjfVa0HLCfYAC9opJessQSXEI8bJbPlFzVOhtefxDt08Ct+9MbZ7 fygRnHvHSfmItOBNgmZuaUrUnnXauqiXSAASpF9TKVBlD2+IoTFIIQSPuAENCa9RUs+k8 141J93SYoA58tw4nEU+EoIaUm4BCHH/AXyBIbRxhgcgCVJO0H4eNzgdiv4QwyxVe6mw== 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=Lrg46OO6; 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 B8720606A32C; Fri, 4 Dec 2026 11:30:20 +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=Lrg46OO6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2C721F000CE; Fri, 4 Dec 2026 11:30:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383820; bh=BjygNJGIUfEJHOsvpaAw9fJxCSm69Zq0V2E1DWxO2eY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Lrg46OO6rAbNqBLixZB9i8UywDgIUQ7vG+UdR5IQ3VSAu2a5VmFDDmSIVyo/WnZ6k ZWuQxmY+XAbK3TVzEU4097eUGZmKkB/V4xMIShgW7dhBjVbjSR2wESx9kW+m1+PqEp isOhpzwW9/vTQrJa6QmZ5QXloSLW8DHFXsaO7oEk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , Miklos Szeredi Subject: [PATCH 6.12 382/555] fuse: fix possible UAF in fuse_direntplus_link() Date: Fri, 4 Dec 2026 19:07:05 +0900 Message-ID: <20261204100624.358447984@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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 6.12-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);