From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 96F9447A64; Mon, 1 Apr 2024 16:15:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711988109; cv=none; b=kX896XUaIBFk1e0u1lX+FX5cwb4oYqs6uJNEP3CIvEUlbOMq7GEUngdxxbPov8HABNXHblHKf1s6N4EyxdZOpkQQC3nUcVirPaU5FgGMWfxI8yC4wnpRFMUCbH2oQR9k+b1U2sH5vwG8eImtJVmHXspUBBPG1zuuwgVH+Tb5NLE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711988109; c=relaxed/simple; bh=KHPlz6CO99bpub2DEukpROMlRduugUchkT4YRPgJ+R4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YFNi0Nb7/fDd/TgJ5iUXVtBgDi2szvcig5GwwrFJOw+KlbodGG+hdPt/UbbX3QbvkLggW7nR2BSnQQjMa9zhJIT//d6hiOS00LQrrWpgBy17TvYOJbeEFG+wSndHj3ANoChPnsunV5Nyx6eExl2CPndfvufoojaFHHB6mrUCark= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VquovX6j; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="VquovX6j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4038BC433C7; Mon, 1 Apr 2024 16:15:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711988108; bh=KHPlz6CO99bpub2DEukpROMlRduugUchkT4YRPgJ+R4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VquovX6jZ61UeL6iU10NAP0n2DeViH8gj3orl0IBvVxu5DohfEtL8QPHv5M3QYFv1 hBSw6XbmPnMfXxXmAfNscGpWILuVCgpRs0djS6M9HeqYpyEtLO/urgT4kjfOS7e2El MQE3uMPGBqYqukgVaWTjwvMVxT+eLrHnPb3mGeus= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Antonio SJ Musumeci , Miklos Szeredi , Sasha Levin Subject: [PATCH 6.7 087/432] fuse: fix root lookup with nonzero generation Date: Mon, 1 Apr 2024 17:41:14 +0200 Message-ID: <20240401152555.720023084@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152553.125349965@linuxfoundation.org> References: <20240401152553.125349965@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.7-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miklos Szeredi [ Upstream commit 68ca1b49e430f6534d0774a94147a823e3b8b26e ] The root inode has a fixed nodeid and generation (1, 0). Prior to the commit 15db16837a35 ("fuse: fix illegal access to inode with reused nodeid") generation number on lookup was ignored. After this commit lookup with the wrong generation number resulted in the inode being unhashed. This is correct for non-root inodes, but replacing the root inode is wrong and results in weird behavior. Fix by reverting to the old behavior if ignoring the generation for the root inode, but issuing a warning in dmesg. Reported-by: Antonio SJ Musumeci Closes: https://lore.kernel.org/all/CAOQ4uxhek5ytdN8Yz2tNEOg5ea4NkBb4nk0FGPjPk_9nz-VG3g@mail.gmail.com/ Fixes: 15db16837a35 ("fuse: fix illegal access to inode with reused nodeid") Cc: # v5.14 Signed-off-by: Miklos Szeredi Signed-off-by: Sasha Levin --- fs/fuse/dir.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index d3bc463d9da76..9307bb4393b8f 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -391,6 +391,10 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name err = -EIO; if (fuse_invalid_attr(&outarg->attr)) goto out_put_forget; + if (outarg->nodeid == FUSE_ROOT_ID && outarg->generation != 0) { + pr_warn_once("root generation should be zero\n"); + outarg->generation = 0; + } *inode = fuse_iget(sb, outarg->nodeid, outarg->generation, &outarg->attr, ATTR_TIMEOUT(outarg), -- 2.43.0