[Devel] [PATCH RH8] cgroup/ve: Fix crash in ve_set_release_agent_path on zero ve_owner

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue Aug 10 15:44:34 MSK 2021


Can be reproduced with:

 mount -t cgroup -onone,name=mytestcg,release_agent="/usr/bin/true" \
  cgroup /mnt/mytestcg

Crash happens on BUG() statement in ve_set_release_agent_path.

If we add new cgroup root initially having a release agent ve_owner
should be initialized before ve_set_release_agent_path.

https://jira.sw.ru/browse/PSBM-131979
Fixes: 099f87a441bf ("ve/cgroup: Add ve_owner field to cgroup")
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 kernel/cgroup/cgroup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 5eb8e72b983e..dcd7983c393f 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -2242,6 +2242,8 @@ void init_cgroup_root(struct cgroup_fs_context *ctx)
 	init_cgroup_housekeeping(cgrp);
 
 	root->flags = ctx->flags;
+
+	RCU_INIT_POINTER(cgrp->ve_owner, &ve0);
 	if (ctx->release_agent)
 		ve_set_release_agent_path(cgrp->ve_owner, root,
 					  ctx->release_agent);
@@ -2353,8 +2355,6 @@ int cgroup_do_get_tree(struct fs_context *fc)
 	struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
 	int ret;
 
-	RCU_INIT_POINTER(ctx->root->cgrp.ve_owner, &ve0);
-
 	ctx->kfc.root = ctx->root->kf_root;
 	if (fc->fs_type == &cgroup2_fs_type)
 		ctx->kfc.magic = CGROUP2_SUPER_MAGIC;
-- 
2.31.1



More information about the Devel mailing list