Merge pull request #1461 from xiaobo55x:ptrace_sysemu

PiperOrigin-RevId: 287225250
This commit is contained in:
gVisor bot 2019-12-26 14:19:34 -08:00
commit 5b9034cc18
2 changed files with 4 additions and 3 deletions

View File

@ -21,6 +21,7 @@ import (
"sync" "sync"
"syscall" "syscall"
"golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/log" "gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/pkg/procid" "gvisor.dev/gvisor/pkg/procid"
"gvisor.dev/gvisor/pkg/sentry/arch" "gvisor.dev/gvisor/pkg/sentry/arch"
@ -541,14 +542,14 @@ func (s *subprocess) switchToApp(c *context, ac arch.Context) bool {
if isSingleStepping(regs) { if isSingleStepping(regs) {
if _, _, errno := syscall.RawSyscall6( if _, _, errno := syscall.RawSyscall6(
syscall.SYS_PTRACE, syscall.SYS_PTRACE,
syscall.PTRACE_SYSEMU_SINGLESTEP, unix.PTRACE_SYSEMU_SINGLESTEP,
uintptr(t.tid), 0, 0, 0, 0); errno != 0 { uintptr(t.tid), 0, 0, 0, 0); errno != 0 {
panic(fmt.Sprintf("ptrace sysemu failed: %v", errno)) panic(fmt.Sprintf("ptrace sysemu failed: %v", errno))
} }
} else { } else {
if _, _, errno := syscall.RawSyscall6( if _, _, errno := syscall.RawSyscall6(
syscall.SYS_PTRACE, syscall.SYS_PTRACE,
syscall.PTRACE_SYSEMU, unix.PTRACE_SYSEMU,
uintptr(t.tid), 0, 0, 0, 0); errno != 0 { uintptr(t.tid), 0, 0, 0, 0); errno != 0 {
panic(fmt.Sprintf("ptrace sysemu failed: %v", errno)) panic(fmt.Sprintf("ptrace sysemu failed: %v", errno))
} }

View File

@ -54,7 +54,7 @@ func probeSeccomp() bool {
for { for {
// Attempt an emulation. // Attempt an emulation.
if _, _, errno := syscall.RawSyscall6(syscall.SYS_PTRACE, syscall.PTRACE_SYSEMU, uintptr(t.tid), 0, 0, 0, 0); errno != 0 { if _, _, errno := syscall.RawSyscall6(syscall.SYS_PTRACE, unix.PTRACE_SYSEMU, uintptr(t.tid), 0, 0, 0, 0); errno != 0 {
panic(fmt.Sprintf("ptrace syscall-enter failed: %v", errno)) panic(fmt.Sprintf("ptrace syscall-enter failed: %v", errno))
} }