Unverified Commit 7f4f2291 authored by Christian Brauner's avatar Christian Brauner
Browse files

mntns: use stable inode number for initial mount ns

Apart from the network and mount namespace all other namespaces expose a
stable inode number and userspace has been relying on that for a very
long time now. It's very much heavily used API. Align the mount
namespace and use a stable inode number from the reserved procfs inode
number space so this is consistent across all namespaces.

Link: https://lore.kernel.org/20250606-work-nsfs-v1-3-b8749c9a8844@kernel.org


Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 9b0240b3
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -6203,9 +6203,11 @@ static void __init init_mount_tree(void)
	if (IS_ERR(mnt))
		panic("Can't create rootfs");

	ns = alloc_mnt_ns(&init_user_ns, false);
	ns = alloc_mnt_ns(&init_user_ns, true);
	if (IS_ERR(ns))
		panic("Can't allocate initial namespace");
	ns->seq = atomic64_inc_return(&mnt_ns_seq);
	ns->ns.inum = PROC_MNT_INIT_INO;
	m = real_mount(mnt);
	ns->root = m;
	ns->nr_mounts = 1;
+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ enum {
	PROC_CGROUP_INIT_INO	= CGROUP_NS_INIT_INO,
	PROC_TIME_INIT_INO	= TIME_NS_INIT_INO,
	PROC_NET_INIT_INO	= NET_NS_INIT_INO,
	PROC_MNT_INIT_INO	= MNT_NS_INIT_INO,
};

#ifdef CONFIG_PROC_FS
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ enum init_ns_ino {
	CGROUP_NS_INIT_INO	= 0xEFFFFFFBU,
	TIME_NS_INIT_INO	= 0xEFFFFFFAU,
	NET_NS_INIT_INO		= 0xEFFFFFF9U,
	MNT_NS_INIT_INO		= 0xEFFFFFF8U,
};

#endif /* __LINUX_NSFS_H */