Commit a80dec3f authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

cgroup: add a check for cgroup namespaces

v2: print a warning when cgroup ns is not present.
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent f400efb2
...@@ -820,6 +820,23 @@ static int check_clone_parent_vs_pid() ...@@ -820,6 +820,23 @@ static int check_clone_parent_vs_pid()
return 0; return 0;
} }
static int check_cgroupns(void)
{
int ret;
if (opts.check_ms_kernel) {
pr_warn("Skipping cgroup namespaces check\n");
return 0;
}
ret = access("/proc/self/ns/cgroup", F_OK);
if (ret < 0) {
pr_err("cgroupns not supported. This is not fatal.");
return -1;
}
return 0;
}
static int (*chk_feature)(void); static int (*chk_feature)(void);
int cr_check(void) int cr_check(void)
...@@ -876,6 +893,7 @@ int cr_check(void) ...@@ -876,6 +893,7 @@ int cr_check(void)
ret |= check_aio_remap(); ret |= check_aio_remap();
ret |= check_fdinfo_lock(); ret |= check_fdinfo_lock();
ret |= check_clone_parent_vs_pid(); ret |= check_clone_parent_vs_pid();
ret |= check_cgroupns();
out: out:
if (!ret) if (!ret)
...@@ -949,6 +967,8 @@ int check_add_feature(char *feat) ...@@ -949,6 +967,8 @@ int check_add_feature(char *feat)
chk_feature = check_ptrace_dump_seccomp_filters; chk_feature = check_ptrace_dump_seccomp_filters;
else if (!strcmp(feat, "loginuid")) else if (!strcmp(feat, "loginuid"))
chk_feature = check_loginuid; chk_feature = check_loginuid;
else if (!strcmp(feat, "cgroupns"))
chk_feature = check_cgroupns;
else { else {
pr_err("Unknown feature %s\n", feat); pr_err("Unknown feature %s\n", feat);
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment