Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 063EF3D9DC0; Sat, 12 Sep 2026 11:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789211670; cv=none; b=RWUXISQL/zab0hPiu8RqXamEyeJ/k47ogHFqomn0oJt6vIdtMGRngTrm4NFOzu17NN1rMFz2YykGQZUL0SXK8Z0o5GMVwTL5jsrETjQ95shMP3yI0z9UpS7NP7sNQxmVguvVuMMbNznK3n74OCYo4sMIJgqop9ePm92s/u/wNfU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789211670; c=relaxed/simple; bh=cAxXMlbyyerG460ETBNKbLYHO2lZz2hbJ5DFbmTawZU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kURR91Oi8hs9r6AWrABvZy9ZlB6I/romfgk/hbaQx1x+eEugN26xn09qVrBJTNSOv84eaxxBPy40IB/G5F1uKlIvY8cQrdQbnm3NoUqMzWKucspMJlbbLuD0KYXnHkxygBtqf1OEdaBvun+UeNsaWe5RtnWsaQD+TKykbVP4yTc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=waXg4O5U; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="waXg4O5U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12BA21F00893; Sat, 12 Sep 2026 11:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789211667; bh=+UuK2yrhr4fAJItzm+HHjQdHhUtPN2rRv7hc+kH400s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=waXg4O5UTmQb77YdBUJSk8M5EI0V6C6AkaSuR5SIoTo930/jFBHDFJTQGqxDPoK5b 264PHyYNYnqhdbblez8ODmvk9wiaLnfXS2Y0F/PF03fPAeRQsWhW3lN9x2FnCt0Ekc IzqZMs9ZPZOOocmmcjGzLRh+E/UmttM5JU2iIgWQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Baokun Li , Jingbo Xu , Miklos Szeredi , Sasha Levin Subject: [PATCH 6.18 1277/1518] fuse: check for NULL root inode in fuse_fill_super_submount Date: Sat, 12 Sep 2026 08:57:26 +0200 Message-ID: <20260912065652.400796169@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065623.398859879@linuxfoundation.org> References: <20260912065623.398859879@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Baokun Li [ Upstream commit 928f659a3e3650978a5b4829cc982324f72b474b ] fuse_iget() can return NULL when its inode allocation fails, but fuse_fill_super_submount() passed the result straight to get_fuse_inode() and decremented fi->nlookup without checking it: root = fuse_iget(sb, parent_fi->nodeid, ...); fi = get_fuse_inode(root); fi->nlookup--; Inside fuse_iget() the inode allocation can fail and return NULL. The submount root takes the iget5_locked() path, whose alloc_inode() can fail under memory pressure (the auto-submount branch can fail the same way in new_inode() or fuse_alloc_submount_lookup()): inode = iget5_locked(sb, nodeid, fuse_inode_eq, fuse_inode_set, &nodeid); if (!inode) return NULL; A NULL root makes get_fuse_inode() a container_of() on NULL and the nlookup decrement a write to a bogus address, oopsing the mount. With CONFIG_KASAN the following null pointer dereference is reported when the root inode allocation of an auto-submount fails (e.g. under memory pressure): ================================================================== BUG: KASAN: null-ptr-deref in fuse_get_tree_submount+0x656/0x8b0 Read of size 8 at addr 00000000000002b0 by task ls/942 CPU: 0 PID: 942 Comm: ls Tainted: G W 6.6 #15 Call Trace: fuse_get_tree_submount+0x656/0x8b0 vfs_get_tree+0x48/0x140 fc_mount+0x13/0x50 fuse_dentry_automount+0x7a/0xb0 __traverse_mounts+0xca/0x330 step_into+0x339/0xac0 path_lookupat+0xc5/0x2f0 filename_lookup+0x163/0x2a0 vfs_statx+0xd5/0x200 do_statx+0x83/0xd0 __x64_sys_statx+0xa0/0xc0 do_syscall_64+0x37/0x90 entry_SYSCALL_64_after_hwframe+0x78/0xe2 ================================================================== Return -ENOMEM instead; the caller tears down the partially built superblock on error, matching the other error returns in this function. Fixes: 1866d779d5d2 ("fuse: Allow fuse_fill_super_common() for submounts") Signed-off-by: Baokun Li Reviewed-by: Jingbo Xu Signed-off-by: Miklos Szeredi Signed-off-by: Sasha Levin --- fs/fuse/inode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index ae520c7388218..a0a64dfffb759 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1743,6 +1743,8 @@ static int fuse_fill_super_submount(struct super_block *sb, fuse_fill_attr_from_inode(&root_attr, parent_fi); root = fuse_iget(sb, parent_fi->nodeid, 0, &root_attr, 0, 0, fuse_get_evict_ctr(fm->fc)); + if (!root) + return -ENOMEM; /* * This inode is just a duplicate, so it is not looked up and * its nlookup should not be incremented. fuse_iget() does -- 2.53.0