[Devel] [PATCH RHEL7 COMMIT] userns: initiallize user_init_ns earlier

Konstantin Khorenko khorenko at virtuozzo.com
Thu Nov 2 20:57:54 MSK 2023


The commit is pushed to "branch-rh7-3.10.0-1160.99.1.vz7.211.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.99.1.vz7.211.2
------>
commit 4f78bc06660340f3ca76ce9e5f5b247ce363e837
Author: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Date:   Thu Sep 28 21:19:48 2023 +0300

    userns: initiallize user_init_ns earlier
    
    user_namespaces_init was converted from module_init
    to subsys_initcall which is called at later point.
    init_user_ns is used before that call in sget(...).
    So move the initialization of ucount_max into the
    declaration of init_user_ns.
    
    https://jira.vzint.dev/browse/PSBM-150648
    Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
 kernel/user.c           | 4 ++++
 kernel/user_namespace.c | 4 ----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/user.c b/kernel/user.c
index de59631d163b..fdcf675b809d 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -59,6 +59,10 @@ struct user_namespace init_user_ns = {
 	.persistent_keyring_register_sem =
 	__RWSEM_INITIALIZER(init_user_ns.persistent_keyring_register_sem),
 #endif
+        /* To make user namespaces something to opt in to for existing
+         * RHEL users default ucount_max to 0.
+         */
+	.ucount_max[UCOUNT_USER_NAMESPACES] = 0,
 };
 EXPORT_SYMBOL_GPL(init_user_ns);
 
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 1759671e62ad..a76d0a796aa9 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -1119,10 +1119,6 @@ const struct proc_ns_operations userns_operations = {
 static __init int user_namespaces_init(void)
 {
 	user_ns_cachep = KMEM_CACHE(user_namespace, SLAB_PANIC | SLAB_ACCOUNT);
-	/* To make user namespaces something to opt in to for existing
-	 * RHEL users default ucount_max to 0.
-	 */
-	init_user_ns.ucount_max[UCOUNT_USER_NAMESPACES] = 0;
 	return 0;
 }
 subsys_initcall(user_namespaces_init);


More information about the Devel mailing list