summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/platform/ptrace/subprocess.go
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2018-10-24 15:51:46 -0700
committerShentubot <shentubot@google.com>2018-10-24 15:52:44 -0700
commite7191f058f550cc3a203a854a1d81f7746c96e53 (patch)
treea733e8897a903917e15f475df59bb6de4e82ab10 /pkg/sentry/platform/ptrace/subprocess.go
parent425dccdd7ed035a671aaf8da1982f7b029365d66 (diff)
Use TRAP to simplify vsyscall emulation.
PiperOrigin-RevId: 218592058 Change-Id: I373a2d813aa6cc362500dd5a894c0b214a1959d7
Diffstat (limited to 'pkg/sentry/platform/ptrace/subprocess.go')
-rw-r--r--pkg/sentry/platform/ptrace/subprocess.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/pkg/sentry/platform/ptrace/subprocess.go b/pkg/sentry/platform/ptrace/subprocess.go
index 6a9da5db8..2cd49d1ec 100644
--- a/pkg/sentry/platform/ptrace/subprocess.go
+++ b/pkg/sentry/platform/ptrace/subprocess.go
@@ -357,15 +357,13 @@ func (t *thread) destroy() {
// init initializes trace options.
func (t *thread) init() {
- // Set our TRACESYSGOOD option to differeniate real SIGTRAP. Also, we
- // require the SECCOMP option to ensure that seccomp violations
- // generate a ptrace event.
+ // Set our TRACESYSGOOD option to differeniate real SIGTRAP.
_, _, errno := syscall.RawSyscall6(
syscall.SYS_PTRACE,
syscall.PTRACE_SETOPTIONS,
uintptr(t.tid),
0,
- syscall.PTRACE_O_TRACESYSGOOD|_PTRACE_O_TRACESECCOMP,
+ syscall.PTRACE_O_TRACESYSGOOD,
0, 0)
if errno != 0 {
panic(fmt.Sprintf("ptrace set options failed: %v", errno))
@@ -522,12 +520,6 @@ func (s *subprocess) switchToApp(c *context, ac arch.Context) bool {
// Ensure registers are sane.
updateSyscallRegs(regs)
return true
- } else if sig == (seccompEvent | syscall.SIGTRAP) {
- // Seccomp is enabled, and caught the system call. This
- // is an emulated vsyscall call, since those are caught
- // only by seccomp and explicitly set to trace.
- updateSyscallRegs(regs)
- return true
} else if sig == syscall.SIGSTOP {
// SIGSTOP was delivered to another thread in the same thread
// group, which initiated another group stop. Just ignore it.
@@ -544,9 +536,17 @@ func (s *subprocess) switchToApp(c *context, ac arch.Context) bool {
// either delivered from the kernel or from this process. We
// don't respect other signals.
if c.signalInfo.Code > 0 {
- return false // kernel.
+ // The signal was generated by the kernel. We inspect
+ // the signal information, and may patch it in order to
+ // faciliate vsyscall emulation. See patchSignalInfo.
+ patchSignalInfo(regs, &c.signalInfo)
+ return false
} else if c.signalInfo.Code <= 0 && c.signalInfo.Pid() == int32(os.Getpid()) {
- return false // this process.
+ // The signal was generated by this process. That means
+ // that it was an interrupt or something else that we
+ // should bail for. Note that we ignore signals
+ // generated by other processes.
+ return false
}
}
}