[Devel] [PATCH RHEL7 COMMIT] ub: init ub0 bound css early

Konstantin Khorenko khorenko at virtuozzo.com
Tue May 17 07:50:45 PDT 2016


The commit is pushed to "branch-rh7-3.10.0-327.18.2.vz7.14.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.18.2.vz7.14.3
------>
commit 00b1829072b2a10146867208a38e7ac2cadc73ae
Author: Vladimir Davydov <vdavydov at virtuozzo.com>
Date:   Tue May 17 18:50:45 2016 +0400

    ub: init ub0 bound css early
    
    It may occur that a usermodehelper is scheduled before ub0 bound css is
    initialized during late init. If this happens, the system will crash in
    ub_enough_memory, which needs to dereference bound css.
    
    To fix that let's initialize bound css right after cgroup_init.
    
    https://jira.sw.ru/browse/PSBM-47147
    
    Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 init/main.c             | 2 +-
 kernel/bc/beancounter.c | 8 +++-----
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/init/main.c b/init/main.c
index 0f35339..ad443be 100644
--- a/init/main.c
+++ b/init/main.c
@@ -623,7 +623,6 @@ asmlinkage void __init start_kernel(void)
 	cred_init();
 	fork_init(totalram_pages);
 	proc_caches_init();
-	ub_init_late();
 	buffer_init();
 	key_init();
 	security_init();
@@ -636,6 +635,7 @@ asmlinkage void __init start_kernel(void)
 	proc_root_init();
 #endif
 	cgroup_init();
+	ub_init_late();
 	cpuset_init();
 	taskstats_init_early();
 	delayacct_init();
diff --git a/kernel/bc/beancounter.c b/kernel/bc/beancounter.c
index 18188f7..b26d292 100644
--- a/kernel/bc/beancounter.c
+++ b/kernel/bc/beancounter.c
@@ -1172,6 +1172,9 @@ static ctl_table ub_sysctl_root[] = {
 
 void __init ub_init_late(void)
 {
+	ub_set_mem_css(&ub0, task_subsys_state_check(&init_task,  mem_cgroup_subsys_id, true));
+	ub_set_blkio_css(&ub0, task_subsys_state_check(&init_task, blkio_subsys_id, true));
+
 	register_sysctl_table(ub_sysctl_root);
 }
 
@@ -1203,11 +1206,6 @@ int __init ub_init_cgroup(void)
 		panic("Failed to mount beancounter cgroup: %ld\n",
 		      PTR_ERR(ub_cgroup_mnt));
 
-	ub_set_mem_css(&ub0, cgroup_subsys_state(
-		cgroup_get_root(mem_cgroup_mnt), mem_cgroup_subsys_id));
-	ub_set_blkio_css(&ub0, cgroup_subsys_state(
-		cgroup_get_root(blkio_cgroup_mnt), blkio_subsys_id));
-
 	return 0;
 }
 late_initcall(ub_init_cgroup);


More information about the Devel mailing list