diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2016-11-26 17:04:23 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2016-11-26 17:04:23 +0100 |
| commit | 23fd96806d2ac9946e38df5eb2a2e7d6c2cd44da (patch) | |
| tree | 30633fdd312a0c745e583d10d0cfaec211ca6cd6 /ipc | |
| parent | c732a41acb817d330610e0e3ebbdcafca6fc2095 (diff) | |
ipc: append pid to binary name
E.g. if binary is 'syz-executor' and pid=15,
we create a link from 'syz-executor15' to 'syz-executor' and use 'syz-executor15' as binary.
This allows to easily identify program that lead to a crash in the log.
Log contains pid in "executing program 15" and crashes usually contain "Comm: syz-executor15".
Diffstat (limited to 'ipc')
| -rw-r--r-- | ipc/ipc.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ipc/ipc.go b/ipc/ipc.go index 144bf9828..36cee04c5 100644 --- a/ipc/ipc.go +++ b/ipc/ipc.go @@ -131,6 +131,21 @@ func MakeEnv(bin string, timeout time.Duration, flags uint64, pid int) (*Env, er if err != nil { return nil, fmt.Errorf("filepath.Abs failed: %v", err) } + // Append pid to binary name. + // E.g. if binary is 'syz-executor' and pid=15, + // we create a link from 'syz-executor15' to 'syz-executor' and use 'syz-executor15' as binary. + // This allows to easily identify program that lead to a crash in the log. + // Log contains pid in "executing program 15" and crashes usually contain "Comm: syz-executor15". + base := filepath.Base(env.bin[0]) + pidStr := fmt.Sprint(pid) + if len(base)+len(pidStr) >= 16 { + // TASK_COMM_LEN is currently set to 16 + base = base[:15-len(pidStr)] + } + binCopy := filepath.Join(filepath.Dir(env.bin[0]), base+pidStr) + if err := os.Link(env.bin[0], binCopy); err == nil { + env.bin[0] = binCopy + } inf = nil outf = nil return env, nil |
