From 3a2fe60529aff48ba86c979157df9c1a7eefd658 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 9 Aug 2018 14:48:06 +0200 Subject: executor: fix cgroups 1. Create per-proc cgroup in executor. 2. Setup cgroups after chdir into test dir (it assumes relative paths against test dir). 3. Add test. --- pkg/csource/generated.go | 8 ++++---- pkg/runtest/run.go | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'pkg') diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go index cd59914e3..a5b25001f 100644 --- a/pkg/csource/generated.go +++ b/pkg/csource/generated.go @@ -3422,7 +3422,7 @@ static void kill_and_wait(int pid, int* status) #define SYZ_HAVE_SETUP_LOOP 1 static void setup_loop() { -#if SYZ_ENABLE_CGROUPS +#if SYZ_EXECUTOR || SYZ_ENABLE_CGROUPS int pid = getpid(); char cgroupdir[64]; char procs_file[128]; @@ -3871,13 +3871,13 @@ static void loop() if (pid < 0) fail("clone failed"); if (pid == 0) { -#if SYZ_HAVE_SETUP_TEST - setup_test(); -#endif #if SYZ_EXECUTOR || SYZ_USE_TMP_DIR if (chdir(cwdbuf)) fail("failed to chdir"); #endif +#if SYZ_HAVE_SETUP_TEST + setup_test(); +#endif #if GOOS_akaros #if SYZ_EXECUTOR dup2(child_pipe[0], kInPipeFd); diff --git a/pkg/runtest/run.go b/pkg/runtest/run.go index 21724fb2c..aa090e371 100644 --- a/pkg/runtest/run.go +++ b/pkg/runtest/run.go @@ -337,15 +337,16 @@ func (ctx *Context) createSyzTest(p *prog.Prog, sandbox string, threaded, cov bo func (ctx *Context) createCTest(p *prog.Prog, sandbox string, threaded bool, times int) (*RunRequest, error) { opts := csource.Options{ - Threaded: threaded, - Collide: false, - Repeat: times > 1, - RepeatTimes: times, - Procs: 1, - Sandbox: sandbox, - UseTmpDir: true, - HandleSegv: true, - Trace: true, + Threaded: threaded, + Collide: false, + Repeat: times > 1, + RepeatTimes: times, + Procs: 1, + Sandbox: sandbox, + UseTmpDir: true, + HandleSegv: true, + EnableCgroups: p.Target.OS == "linux" && sandbox != "", + Trace: true, } if sandbox != "" { if ctx.Features[host.FeatureNetworkInjection].Enabled { -- cgit mrf-deployment