From c4b454fc54ca0caad77d11c5ba27b09b5da9b034 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 16 Jul 2020 12:22:57 +0200 Subject: pkg/runtest: tell ASAN to not mess with our NONFAILING It seems that different gcc's have different defaults for ASAN flags. Some fail with: run.go:67: nonfailing none/thr/repeat : FAIL: run 0: call 0 is not executed ASAN:DEADLYSIGNAL ================================================================= ==67143==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f7b0befb0a2 bp 0x7f7b0cfdad10 sp 0x7f7b0cfda490 T1) #0 0x7f7b0befb0a1 (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x8d0a1) #1 0x404bbb in syz_compare(long, long, long, long) (/tmp/utor355225125.0+0x404bbb) #2 0x403cdf in execute_call(thread_t*) (/tmp/utor355225125.0+0x403cdf) #3 0x404006 in worker_thread(void*) (/tmp/utor355225125.0+0x404006) #4 0x7f7b0bc584a3 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x74a3) #5 0x7f7b0b99ad0e in __clone (/lib/x86_64-linux-gnu/libc.so.6+0xe8d0e) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x8d0a1) Thread T1 created by T0 here: #0 0x7f7b0be9ef59 in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.3+0x30f59) #1 0x406117 in execute_one() (/tmp/utor355225125.0+0x406117) --- pkg/ipc/ipc.go | 2 ++ pkg/runtest/run.go | 34 +++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) (limited to 'pkg') diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go index 4e41f92fe..11e73835b 100644 --- a/pkg/ipc/ipc.go +++ b/pkg/ipc/ipc.go @@ -586,6 +586,8 @@ func makeCommand(pid int, bin []string, config *Config, inFile, outFile *os.File cmd.ExtraFiles = []*os.File{inFile, outFile} } cmd.Dir = dir + // Tell ASAN to not mess with our NONFAILING. + cmd.Env = append(append([]string{}, os.Environ()...), "ASAN_OPTIONS=handle_segv=0 allow_user_segv_handler=1") cmd.Stdin = outrp cmd.Stdout = inwp if config.Flags&FlagDebug != 0 { diff --git a/pkg/runtest/run.go b/pkg/runtest/run.go index 2730e3e02..2da871fe6 100644 --- a/pkg/runtest/run.go +++ b/pkg/runtest/run.go @@ -551,19 +551,7 @@ func parseBinOutput(req *RunRequest) ([]*ipc.ProgInfo, error) { func RunTest(req *RunRequest, executor string) { if req.Bin != "" { - tmpDir, err := ioutil.TempDir("", "syz-runtest") - if err != nil { - req.Err = fmt.Errorf("failed to create temp dir: %v", err) - return - } - defer os.RemoveAll(tmpDir) - req.Output, req.Err = osutil.RunCmd(20*time.Second, tmpDir, req.Bin) - if verr, ok := req.Err.(*osutil.VerboseError); ok { - // The process can legitimately do something like exit_group(1). - // So we ignore the error and rely on the rest of the checks (e.g. syscall return values). - req.Err = nil - req.Output = verr.Output - } + runTestC(req) return } req.Cfg.Executor = executor @@ -607,3 +595,23 @@ func RunTest(req *RunRequest, executor string) { req.Info = append(req.Info, info) } } + +func runTestC(req *RunRequest) { + tmpDir, err := ioutil.TempDir("", "syz-runtest") + if err != nil { + req.Err = fmt.Errorf("failed to create temp dir: %v", err) + return + } + defer os.RemoveAll(tmpDir) + cmd := osutil.Command(req.Bin) + cmd.Dir = tmpDir + // Tell ASAN to not mess with our NONFAILING. + cmd.Env = append(append([]string{}, os.Environ()...), "ASAN_OPTIONS=handle_segv=0 allow_user_segv_handler=1") + req.Output, req.Err = osutil.Run(20*time.Second, cmd) + if verr, ok := req.Err.(*osutil.VerboseError); ok { + // The process can legitimately do something like exit_group(1). + // So we ignore the error and rely on the rest of the checks (e.g. syscall return values). + req.Err = nil + req.Output = verr.Output + } +} -- cgit mrf-deployment