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 102183321B3; Tue, 21 Oct 2025 11:44:53 +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=1761047093; cv=none; b=GmUtrHMSPg8Ee88v1GV8I/aZWByeylj0+b+SAh49Oe9eXvUfA/8/oNQ7ePWSFcBnDqZj2wRDiYJlKRbGfV9hbBUp5L+6UJyqIece7mQnT50RVdnw/em07wK84LZRgrIkwIN1uk4QNaWISNyJoh1py2dw1pDn4VYmObLchC045Ds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761047093; c=relaxed/simple; bh=eWr4sp3ZFxiKmdi2bQvM/V/b89IuZ5Yj6h5wRkppsEI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H5VpitGPhsAbYoY8/LFvyIT2bf+smOxlq4GtCsCbCFyGB2MTvegVWQIBz5XkJv54tZdlLASM16rN3WwUMTvCeL2Xu2Ywxd3yzYxSbWgDPmLDP3Pc2EjykUjjGj9ELGfUgpX6ip2bkDkglhz2+tKKVlBWJVYv+mlmxnlHLLx4IYI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JYJboOxS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JYJboOxS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0121BC4CEF1; Tue, 21 Oct 2025 11:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761047092; bh=eWr4sp3ZFxiKmdi2bQvM/V/b89IuZ5Yj6h5wRkppsEI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JYJboOxSdjvgZ72iFp79ep7mtAlNBvWehcuffbFyhLCGqjmqEdiB1uXDSS4Xp8+Z9 2w91e6Vjl2WDorjBQI5+IjlpJwYIwsIlIspjbS0Sve398GNcLurAY/UqxJs73mlLZK 6izkD33g4iuZ8Tnncrrw0kkboPpI9XhTwnOxNyaC0XYFZstVba/uWLwEVgIm7fFJyn uAqbYyfsWGCY/5ZxIGDrGMUdVEjJ24/PP7mNqA2Q7r4UVOfnaH/Iu2Wbdce7NAcE3S EiMv950HoBaMRtimjoX+w+5GoB834LKRi3eF2U6rBGegU4CDqmUpDqIDmLPUZr6ZGc 8QCBA5S25IyAg== From: Christian Brauner Date: Tue, 21 Oct 2025 13:43:18 +0200 Subject: [PATCH RFC DRAFT 12/50] nstree: allow lookup solely based on inode Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20251021-work-namespace-nstree-listns-v1-12-ad44261a8a5b@kernel.org> References: <20251021-work-namespace-nstree-listns-v1-0-ad44261a8a5b@kernel.org> In-Reply-To: <20251021-work-namespace-nstree-listns-v1-0-ad44261a8a5b@kernel.org> To: linux-fsdevel@vger.kernel.org, Josef Bacik , Jeff Layton Cc: Jann Horn , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Amir Goldstein , Tejun Heo , Johannes Weiner , Thomas Gleixner , Alexander Viro , Jan Kara , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, bpf@vger.kernel.org, Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org, Arnd Bergmann , Christian Brauner X-Mailer: b4 0.15-dev-96507 X-Developer-Signature: v=1; a=openpgp-sha256; l=1215; i=brauner@kernel.org; h=from:subject:message-id; bh=eWr4sp3ZFxiKmdi2bQvM/V/b89IuZ5Yj6h5wRkppsEI=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWR8L3z7wVL2f3n670Bxkc6KRlWndfMjz51+nyhYKy+w7 q++3o3EjlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgIk8PcXwh/O43b0f68z6I2v+ 3ZpuzXPTJkywqWtlm/AlBTXzr462jxgZ1lXJzlW5yXD5iKNEzQSlq0fkvhu36LuoddfpHnz/xUi RGwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 The namespace file handle struct nsfs_file_handle is uapi and userspace is expressly allowed to generate file handles without going through name_to_handle_at(). Allow userspace to generate a file handle where both the inode number and the namespace type are zero and just pass in the unique namespace id. The kernel uses the unified namespace tree to find the namespace and open the file handle. When the kernel creates a file handle via name_to_handle_at() it will always fill in the type and the inode number allowing userspace to retrieve core information. Signed-off-by: Christian Brauner --- fs/nsfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nsfs.c b/fs/nsfs.c index a190e1e38442..ba5863ee4150 100644 --- a/fs/nsfs.c +++ b/fs/nsfs.c @@ -496,8 +496,8 @@ static struct dentry *nsfs_fh_to_dentry(struct super_block *sb, struct fid *fh, return NULL; VFS_WARN_ON_ONCE(ns->ns_id != fid->ns_id); - VFS_WARN_ON_ONCE(ns->ns_type != fid->ns_type); - VFS_WARN_ON_ONCE(ns->inum != fid->ns_inum); + if (fid->ns_inum && (fid->ns_inum != ns->inum)) + return NULL; if (!ns_get(ns)) return NULL; -- 2.47.3