summaryrefslogtreecommitdiff
path: root/kernel/nscommon.c
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2025-11-09 22:11:23 +0100
committerChristian Brauner <brauner@kernel.org>2025-11-10 10:20:53 +0100
commit7cd3d204412b0584df38fd7be20002137f34721a (patch)
tree845eb7be0f559772a9ae58c6bfb8944459c3fd9d /kernel/nscommon.c
parent0355dcae2d157d95f234a56b540ab110350fd022 (diff)
ns: don't increment or decrement initial namespaces
There's no need to bump the active reference counts of initial namespaces as they're always active and can simply remain at 1. Link: https://patch.msgid.link/20251109-namespace-6-19-fixes-v1-2-ae8a4ad5a3b3@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'kernel/nscommon.c')
-rw-r--r--kernel/nscommon.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/nscommon.c b/kernel/nscommon.c
index d67ae7ad7759..70cb66232e4c 100644
--- a/kernel/nscommon.c
+++ b/kernel/nscommon.c
@@ -177,6 +177,7 @@ void __ns_ref_active_put_owner(struct ns_common *ns)
ns = ns_owner(ns);
if (!ns)
return;
+ VFS_WARN_ON_ONCE(is_ns_init_id(ns));
if (!atomic_dec_and_test(&ns->__ns_ref_active))
return;
}
@@ -276,6 +277,10 @@ void __ns_ref_active_put_owner(struct ns_common *ns)
*/
void __ns_ref_active_resurrect(struct ns_common *ns)
{
+ /* Initial namespaces are always active. */
+ if (is_ns_init_id(ns))
+ return;
+
/* If we didn't resurrect the namespace we're done. */
if (atomic_fetch_add(1, &ns->__ns_ref_active))
return;
@@ -289,6 +294,7 @@ void __ns_ref_active_resurrect(struct ns_common *ns)
if (!ns)
return;
+ VFS_WARN_ON_ONCE(is_ns_init_id(ns));
if (atomic_fetch_add(1, &ns->__ns_ref_active))
return;
}