Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nstree: allow lookup solely based on inode

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.

Link: https://patch.msgid.link/20251029-work-namespace-nstree-listns-v4-14-2e6f823ebdc0@kernel.org
Tested-by: syzbot@syzkaller.appspotmail.com
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+9 -2
+9 -2
fs/nsfs.c
··· 496 496 return NULL; 497 497 } 498 498 499 + if (!fid->ns_id) 500 + return NULL; 501 + /* Either both are set or both are unset. */ 502 + if (!fid->ns_inum != !fid->ns_type) 503 + return NULL; 504 + 499 505 scoped_guard(rcu) { 500 506 ns = ns_tree_lookup_rcu(fid->ns_id, fid->ns_type); 501 507 if (!ns) 502 508 return NULL; 503 509 504 510 VFS_WARN_ON_ONCE(ns->ns_id != fid->ns_id); 505 - VFS_WARN_ON_ONCE(ns->ns_type != fid->ns_type); 506 511 507 - if (ns->inum != fid->ns_inum) 512 + if (fid->ns_inum && (fid->ns_inum != ns->inum)) 513 + return NULL; 514 + if (fid->ns_type && (fid->ns_type != ns->ns_type)) 508 515 return NULL; 509 516 510 517 /*