]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mntns: use stable inode number for initial mount ns
authorChristian Brauner <brauner@kernel.org>
Fri, 6 Jun 2025 09:45:09 +0000 (11:45 +0200)
committerChristian Brauner <brauner@kernel.org>
Wed, 11 Jun 2025 09:59:08 +0000 (11:59 +0200)
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: Christian Brauner <brauner@kernel.org>
fs/namespace.c
include/linux/proc_ns.h
include/uapi/linux/nsfs.h

index e13d9ab4f56496060ea3d967d42ef9b7318b9a1a..7ca4612c7ae929d3117a9aafbee597ba4eab9250 100644 (file)
@@ -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;
index 3ff0bd381704b7c18de9e37265b4a32933ce6d58..6258455e49a4601ede15d092c5f2fee2732ae001 100644 (file)
@@ -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
index 393778489d85e56ba10ddcf9a12b65617171cdf8..97d8d80d139fc4afb8adabe4e94b15ca3ff08aa6 100644 (file)
@@ -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 */