]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ns: drop custom reference count initialization for initial namespaces
authorChristian Brauner <brauner@kernel.org>
Mon, 10 Nov 2025 15:08:28 +0000 (16:08 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 11 Nov 2025 09:01:32 +0000 (10:01 +0100)
Initial namespaces don't modify their reference count anymore.
They remain fixed at one so drop the custom refcount initializations.

Link: https://patch.msgid.link/20251110-work-namespace-nstree-fixes-v1-16-e8a9264e0fb9@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/namespace.c
include/linux/ns_common.h
init/version-timestamp.c
ipc/msgutil.c
kernel/cgroup/cgroup.c
kernel/pid.c
kernel/time/namespace.c
kernel/user.c

index efaff8680eafbd9542c5034e5753f4e5b3eadfad..25289b869be15e6912e05f6d07464eb5b5870a34 100644 (file)
@@ -5986,7 +5986,7 @@ SYSCALL_DEFINE4(listmount, const struct mnt_id_req __user *, req,
 }
 
 struct mnt_namespace init_mnt_ns = {
-       .ns             = NS_COMMON_INIT(init_mnt_ns, 1),
+       .ns             = NS_COMMON_INIT(init_mnt_ns),
        .user_ns        = &init_user_ns,
        .passive        = REFCOUNT_INIT(1),
        .mounts         = RB_ROOT,
index 43f709ab846a72f82edbc806d6b59a0a7d34c1b0..136f6a322e53692be6b0b9acc461681ec1f0e3ad 100644 (file)
@@ -26,14 +26,14 @@ static __always_inline bool is_ns_init_id(const struct ns_common *ns)
        return ns->ns_id <= NS_LAST_INIT_ID;
 }
 
-#define NS_COMMON_INIT(nsname, refs)                                                                   \
+#define NS_COMMON_INIT(nsname)                                                                         \
 {                                                                                                      \
        .ns_type                        = ns_common_type(&nsname),                                      \
        .ns_id                          = ns_init_id(&nsname),                                          \
        .inum                           = ns_init_inum(&nsname),                                        \
        .ops                            = to_ns_operations(&nsname),                                    \
        .stashed                        = NULL,                                                         \
-       .__ns_ref                       = REFCOUNT_INIT(refs),                                          \
+       .__ns_ref                       = REFCOUNT_INIT(1),                                             \
        .__ns_ref_active                = ATOMIC_INIT(1),                                               \
        .ns_unified_node.ns_list_entry  = LIST_HEAD_INIT(nsname.ns.ns_unified_node.ns_list_entry),      \
        .ns_tree_node.ns_list_entry     = LIST_HEAD_INIT(nsname.ns.ns_tree_node.ns_list_entry),         \
index 56ded64fdfe4092b6a3f87be7c93bf056e6f7e77..375726e05f690fea975a6781499b8e181cef4269 100644 (file)
@@ -8,7 +8,7 @@
 #include <linux/utsname.h>
 
 struct uts_namespace init_uts_ns = {
-       .ns = NS_COMMON_INIT(init_uts_ns, 2),
+       .ns = NS_COMMON_INIT(init_uts_ns),
        .name = {
                .sysname        = UTS_SYSNAME,
                .nodename       = UTS_NODENAME,
index 55a908ec0674c678a92eb3011ce5587a85e39c8b..e28f0cecb2ec942a4f6ee93df8384716bd026011 100644 (file)
@@ -27,7 +27,7 @@ DEFINE_SPINLOCK(mq_lock);
  * and not CONFIG_IPC_NS.
  */
 struct ipc_namespace init_ipc_ns = {
-       .ns = NS_COMMON_INIT(init_ipc_ns, 1),
+       .ns = NS_COMMON_INIT(init_ipc_ns),
        .user_ns = &init_user_ns,
 };
 
index 20ab84b2cf4e08fc5c73f55e35a8f29d3fda5dcc..2bf3951ca88f63313512aeb5348a15d9290dfb66 100644 (file)
@@ -250,7 +250,7 @@ bool cgroup_enable_per_threadgroup_rwsem __read_mostly;
 
 /* cgroup namespace for init task */
 struct cgroup_namespace init_cgroup_ns = {
-       .ns             = NS_COMMON_INIT(init_cgroup_ns, 2),
+       .ns             = NS_COMMON_INIT(init_cgroup_ns),
        .user_ns        = &init_user_ns,
        .root_cset      = &init_css_set,
 };
index a5a63dc0a49171e5003c86d797cc9f3423180a85..a31771bc89c1a3ef7c9b4b3e28467b608975fbc4 100644 (file)
@@ -71,7 +71,7 @@ static int pid_max_max = PID_MAX_LIMIT;
  * the scheme scales to up to 4 million PIDs, runtime.
  */
 struct pid_namespace init_pid_ns = {
-       .ns = NS_COMMON_INIT(init_pid_ns, 2),
+       .ns = NS_COMMON_INIT(init_pid_ns),
        .idr = IDR_INIT(init_pid_ns.idr),
        .pid_allocated = PIDNS_ADDING,
        .level = 0,
index 19911f88e2b88dd90c30ef83aa33b2570449e3fe..e76be24b132cf50ec98c2399bfe0b857478789b6 100644 (file)
@@ -478,7 +478,7 @@ const struct proc_ns_operations timens_for_children_operations = {
 };
 
 struct time_namespace init_time_ns = {
-       .ns             = NS_COMMON_INIT(init_time_ns, 3),
+       .ns             = NS_COMMON_INIT(init_time_ns),
        .user_ns        = &init_user_ns,
        .frozen_offsets = true,
 };
index 4b3132e786d9433514433087773196bee52e1b86..7aef4e679a6a0cc65872cab1b190f4541455f6e1 100644 (file)
@@ -35,7 +35,7 @@ EXPORT_SYMBOL_GPL(init_binfmt_misc);
  * and 1 for... ?
  */
 struct user_namespace init_user_ns = {
-       .ns = NS_COMMON_INIT(init_user_ns, 3),
+       .ns = NS_COMMON_INIT(init_user_ns),
        .uid_map = {
                {
                        .extent[0] = {