aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2022-07-15 09:56:50 +0200
committerAleksandr Nogikh <wp32pw@gmail.com>2022-07-15 16:03:50 +0200
commit7021866f78604fecd47103377cc583118b66e13e (patch)
tree4695552bcd21a95c2bd1fae93489e97cdd5297ad /pkg
parent5d921b0849eb1958da5e91793b7795131d28b54c (diff)
executor: prevent ENOSPC if cgroup mount fails
Remove /syzcgroup/* if cgroup mount fails. See #3241 for context. Fixes #3241
Diffstat (limited to 'pkg')
-rw-r--r--pkg/csource/generated.go9
1 files changed, 8 insertions, 1 deletions
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);