[lxc-devel] [lxc/master] cgroups: don't escape if we're not real root

tych0 on Github lxc-bot at linuxcontainers.org
Tue Mar 13 15:58:14 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 481 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180313/9e149d97/attachment.bin>
-------------- next part --------------
From 8d961e28f1d759669b477a659cbb694aaa2af915 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho at tycho.ws>
Date: Tue, 13 Mar 2018 15:57:10 +0000
Subject: [PATCH] cgroups: don't escape if we're not real root

If we're host unpriv but root in our userns, we can't really escape
cgroups. Let's switch the cgroup escape test to reflect this.

Signed-off-by: Tycho Andersen <tycho at tycho.ws>
---
 src/lxc/cgroups/cgfsng.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index 10c7ab2cf..f337be449 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -1368,7 +1368,7 @@ static char *cg_unified_get_current_cgroup(void)
 	bool will_escape;
 	char *copy = NULL;
 
-	will_escape = (geteuid() == 0);
+	will_escape = !am_host_unpriv();
 	if (will_escape)
 		basecginfo = read_file("/proc/1/cgroup");
 	else


More information about the lxc-devel mailing list