Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/sentry/platform/systrap/usertrap/usertrap_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ func (s *State) PatchSyscall(ctx context.Context, ac *arch.Context64, mm memoryM
return fmt.Errorf("no task found")
}

// Skip syscall patching when the task is being ptraced, because
// single-stepping and other debugger features are incompatible with
// the "syshandler" routine used to handle patched syscalls (see
// syshandler_amd64.S). This incompatibility can result in inconsistent
// process states and failures (e.g. SIGSEGV).
// TODO: for a full fix we'd need to roll back existing patched
// syscalls, in case the traced program was patched before being
// traced (e.g. PTRACE_ATTACH on an already running process).
if task.Tracer() != nil {
return nil
}

s.mu.Lock()
defer s.mu.Unlock()

Expand Down