mirror of
https://github.com/golang/go
synced 2024-11-19 14:54:43 -07:00
syscall: move ptrace setup to right before exec
This will prevent any ptrace calls from getting trace output from the runtime itself setting up after fork. Fixes #21428. Change-Id: I9d835bd5a8f404394eb6237679f2111a72e5bc17 Reviewed-on: https://go-review.googlesource.com/55811 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Avelino <t@avelino.xxx>
This commit is contained in:
parent
0c7fd56951
commit
e974f4fddf
@ -199,14 +199,6 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att
|
||||
}
|
||||
}
|
||||
|
||||
// Enable tracing if requested.
|
||||
if sys.Ptrace {
|
||||
_, _, err1 = RawSyscall(SYS_PTRACE, uintptr(PTRACE_TRACEME), 0, 0)
|
||||
if err1 != 0 {
|
||||
goto childerror
|
||||
}
|
||||
}
|
||||
|
||||
// Session ID
|
||||
if sys.Setsid {
|
||||
_, _, err1 = RawSyscall(SYS_SETSID, 0, 0, 0)
|
||||
@ -402,6 +394,16 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att
|
||||
}
|
||||
}
|
||||
|
||||
// Enable tracing if requested.
|
||||
// Do this right before exec so that we don't unnecessarily trace the runtime
|
||||
// setting up after the fork. See issue #21428.
|
||||
if sys.Ptrace {
|
||||
_, _, err1 = RawSyscall(SYS_PTRACE, uintptr(PTRACE_TRACEME), 0, 0)
|
||||
if err1 != 0 {
|
||||
goto childerror
|
||||
}
|
||||
}
|
||||
|
||||
// Time to exec.
|
||||
_, _, err1 = RawSyscall(SYS_EXECVE,
|
||||
uintptr(unsafe.Pointer(argv0)),
|
||||
|
Loading…
Reference in New Issue
Block a user