[RHEL7,COMMIT] cgroup: Fixed null pointer dereference at cgroup_mount #PSBM-107596

Submitted by Vasily Averin on Sept. 4, 2020, 7:31 a.m.


Message ID 202009040731.0847VTCE025220@vz7build.vvs.sw.ru
State New
Series "cgroup: Fixed null pointer dereference at cgroup_mount #PSBM-107596"
Headers show

Commit Message

Vasily Averin Sept. 4, 2020, 7:31 a.m.
The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.vz7.163.16
commit c0b641f9bab3fda5bce3a125c64c0d947b2030f5
Author: Valeriy Vdovin <valeriy.vdovin@virtuozzo.com>
Date:   Fri Sep 4 10:31:29 2020 +0300

    cgroup: Fixed null pointer dereference at cgroup_mount #PSBM-107596
    At cgroup_mount new_root a call to cgroup_root_from_opts may return
    early and not allocate a new cgroup root object, instead returning NULL.
    In that case we should not initialize ve_owner field for cgroup root.
    Signed-off-by: Valeriy Vdovin <valeriy.vdovin@virtuozzo.com>
    Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
 kernel/cgroup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 5f311180..691505c 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1749,6 +1749,9 @@  static struct cgroupfs_root *cgroup_root_from_opts(struct cgroup_sb_opts *opts)
 		strcpy(root->name, opts->name);
 	if (opts->cpuset_clone_children)
 		set_bit(CGRP_CPUSET_CLONE_CHILDREN, &root->top_cgroup.flags);
+	RCU_INIT_POINTER(root->top_cgroup.ve_owner, &ve0);
 	return root;
@@ -1859,7 +1862,6 @@  static struct dentry *cgroup_mount(struct file_system_type *fs_type,
 		goto drop_modules;
-	RCU_INIT_POINTER(new_root->top_cgroup.ve_owner, &ve0);
 	opts.new_root = new_root;
 	/* Locate an existing or new sb for this hierarchy */