summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-24 17:31:51 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-26 18:43:34 +0200
commitab275f23867311e136887755728e6b368324831d (patch)
treef969750446f6c4856d80c810508788327dc3735e
parent4edd65e4cff40158dded65c010b8c3e0b5ff5519 (diff)
downloadsystemd-ab275f23867311e136887755728e6b368324831d.tar.gz
systemd-ab275f23867311e136887755728e6b368324831d.tar.bz2
systemd-ab275f23867311e136887755728e6b368324831d.zip
cgroup-util: before operating on a mounted cgroup controller check if it actually can be mounted
We now have the "BPF" pseudo-controllers. These should never be assumed to be accessible as /sys/fs/cgroup/<controller> and not through "cgroup.subtree_control" either, hence always check explicitly before we go to the file system. We do this through our new CGROUP_MASK_V1 and CGROUP_MASK_V2 definitions.
-rw-r--r--src/basic/cgroup-util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index a501049619..520e18e1b0 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -2139,6 +2139,9 @@ int cg_create_everywhere(CGroupMask supported, CGroupMask mask, const char *path
CGroupMask bit = CGROUP_CONTROLLER_TO_MASK(c);
const char *n;
+ if (!FLAGS_SET(CGROUP_MASK_V1, bit))
+ continue;
+
n = cgroup_controller_to_string(c);
if (mask & bit)
@@ -2168,6 +2171,9 @@ int cg_attach_everywhere(CGroupMask supported, const char *path, pid_t pid, cg_m
CGroupMask bit = CGROUP_CONTROLLER_TO_MASK(c);
const char *p = NULL;
+ if (!FLAGS_SET(CGROUP_MASK_V1, bit))
+ continue;
+
if (!(supported & bit))
continue;
@@ -2220,6 +2226,9 @@ int cg_migrate_everywhere(CGroupMask supported, const char *from, const char *to
CGroupMask bit = CGROUP_CONTROLLER_TO_MASK(c);
const char *p = NULL;
+ if (!FLAGS_SET(CGROUP_MASK_V1, bit))
+ continue;
+
if (!(supported & bit))
continue;
@@ -2252,6 +2261,9 @@ int cg_trim_everywhere(CGroupMask supported, const char *path, bool delete_root)
for (c = 0; c < _CGROUP_CONTROLLER_MAX; c++) {
CGroupMask bit = CGROUP_CONTROLLER_TO_MASK(c);
+ if (!FLAGS_SET(CGROUP_MASK_V1, bit))
+ continue;
+
if (!(supported & bit))
continue;
@@ -2586,6 +2598,9 @@ int cg_enable_everywhere(CGroupMask supported, CGroupMask mask, const char *p) {
CGroupMask bit = CGROUP_CONTROLLER_TO_MASK(c);
const char *n;
+ if (!FLAGS_SET(CGROUP_MASK_V2, bit))
+ continue;
+
if (!(supported & bit))
continue;