Skip to content

Commit 7f4f229

Browse files
committed
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/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 9b0240b commit 7f4f229

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

fs/namespace.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6203,9 +6203,11 @@ static void __init init_mount_tree(void)
62036203
if (IS_ERR(mnt))
62046204
panic("Can't create rootfs");
62056205

6206-
ns = alloc_mnt_ns(&init_user_ns, false);
6206+
ns = alloc_mnt_ns(&init_user_ns, true);
62076207
if (IS_ERR(ns))
62086208
panic("Can't allocate initial namespace");
6209+
ns->seq = atomic64_inc_return(&mnt_ns_seq);
6210+
ns->ns.inum = PROC_MNT_INIT_INO;
62096211
m = real_mount(mnt);
62106212
ns->root = m;
62116213
ns->nr_mounts = 1;

include/linux/proc_ns.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ enum {
4848
PROC_CGROUP_INIT_INO = CGROUP_NS_INIT_INO,
4949
PROC_TIME_INIT_INO = TIME_NS_INIT_INO,
5050
PROC_NET_INIT_INO = NET_NS_INIT_INO,
51+
PROC_MNT_INIT_INO = MNT_NS_INIT_INO,
5152
};
5253

5354
#ifdef CONFIG_PROC_FS

include/uapi/linux/nsfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ enum init_ns_ino {
5050
CGROUP_NS_INIT_INO = 0xEFFFFFFBU,
5151
TIME_NS_INIT_INO = 0xEFFFFFFAU,
5252
NET_NS_INIT_INO = 0xEFFFFFF9U,
53+
MNT_NS_INIT_INO = 0xEFFFFFF8U,
5354
};
5455

5556
#endif /* __LINUX_NSFS_H */

0 commit comments

Comments
 (0)