From 7021866f78604fecd47103377cc583118b66e13e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 15 Jul 2022 09:56:50 +0200 Subject: executor: prevent ENOSPC if cgroup mount fails Remove /syzcgroup/* if cgroup mount fails. See #3241 for context. Fixes #3241 --- pkg/csource/generated.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'pkg') diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index 6168f1793..59c8e89ee 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -8147,10 +8147,15 @@ static void mount_cgroups(const char* dir, const char** controllers, int count) strcat(enabled, ","); strcat(enabled, controllers[i]); } - if (enabled[0] == 0) + if (enabled[0] == 0) { + if (rmdir(dir) && errno != EBUSY) + failmsg("rmdir failed", "dir=%s", dir); return; + } if (mount("none", dir, "cgroup", 0, enabled + 1)) { debug("mount(%s, %s) failed: %d\n", dir, enabled + 1, errno); + if (rmdir(dir) && errno != EBUSY) + failmsg("rmdir failed", "dir=%s enabled=%s", dir, enabled); } if (chmod(dir, 0777)) { debug("chmod(%s) failed: %d\n", dir, errno); @@ -8170,6 +8175,8 @@ static void setup_cgroups() } if (mount("none", "/syzcgroup/unified", "cgroup2", 0, NULL)) { debug("mount(cgroup2) failed: %d\n", errno); + if (rmdir("/syzcgroup/unified") && errno != EBUSY) + fail("rmdir(/syzcgroup/unified) failed"); } if (chmod("/syzcgroup/unified", 0777)) { debug("chmod(/syzcgroup/unified) failed: %d\n", errno); -- cgit mrf-deployment