[lxc-devel] [lxc/master] cgfsng: do not reuse another monitor's cgroup

brauner on Github lxc-bot at linuxcontainers.org
Tue Oct 2 15:29:19 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 400 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181002/c79f04a8/attachment.bin>
-------------- next part --------------
From ee455be41cd127dd9fb37f35a2ee826e637bb76d Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 2 Oct 2018 17:27:55 +0200
Subject: [PATCH] cgfsng: do not reuse another monitor's cgroup

Otherwise we will create a race.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/cgroups/cgfsng.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index e248db31a..0fc9b11d2 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -1262,8 +1262,10 @@ static bool monitor_create_path_for_hierarchy(struct hierarchy *h, char *cgname)
 	int ret;
 
 	h->monitor_full_path = must_make_path(h->mountpoint, h->container_base_path, cgname, NULL);
-	if (dir_exists(h->monitor_full_path))
-		return true;
+	if (dir_exists(h->monitor_full_path)) {
+		ERROR("The cgroup \"%s\" already existed", h->monitor_full_path);
+		return false;
+	}
 
 	if (!cg_legacy_handle_cpuset_hierarchy(h, cgname)) {
 		ERROR("Failed to handle legacy cpuset controller");


More information about the lxc-devel mailing list