diff --git a/pkg/sentry/platform/systrap/subprocess.go b/pkg/sentry/platform/systrap/subprocess.go index 4643c617d..2cafc36d6 100644 --- a/pkg/sentry/platform/systrap/subprocess.go +++ b/pkg/sentry/platform/systrap/subprocess.go @@ -228,6 +228,20 @@ func (s *subprocess) handlePtraceSyscallRequest(req any) { panic(fmt.Sprintf("error waiting for new clone: expected SIGSTOP, got %v", sig)) } + t.initRegs = ptraceThread.initRegs + // Set the parent death signal to SIGKILL. + _, err = t.syscallIgnoreInterrupt(&t.initRegs, unix.SYS_PRCTL, + arch.SyscallArgument{Value: linux.PR_SET_PDEATHSIG}, + arch.SyscallArgument{Value: uintptr(unix.SIGKILL)}, + arch.SyscallArgument{Value: 0}, + arch.SyscallArgument{Value: 0}, + arch.SyscallArgument{Value: 0}, + arch.SyscallArgument{Value: 0}, + ) + if err != nil { + panic(fmt.Sprintf("prctl: %v", err)) + } + id, ok := s.sysmsgStackPool.Get() if !ok { panic("unable to allocate a sysmsg stub thread") @@ -240,7 +254,6 @@ func (s *subprocess) handlePtraceSyscallRequest(req any) { // Detach the thread. t.detach() - t.initRegs = ptraceThread.initRegs // Return the thread. r.thread <- t diff --git a/pkg/sentry/platform/systrap/sysmsg_thread_unsafe.go b/pkg/sentry/platform/systrap/sysmsg_thread_unsafe.go index ec71034a8..59d553222 100644 --- a/pkg/sentry/platform/systrap/sysmsg_thread_unsafe.go +++ b/pkg/sentry/platform/systrap/sysmsg_thread_unsafe.go @@ -39,20 +39,6 @@ func (p *sysmsgThread) setMsg(addr uintptr) { func (p *sysmsgThread) init(sentryAddr, guestAddr uintptr) { t := p.thread - - // Set the parent death signal to SIGKILL. - _, err := t.syscallIgnoreInterrupt(&t.initRegs, unix.SYS_PRCTL, - arch.SyscallArgument{Value: linux.PR_SET_PDEATHSIG}, - arch.SyscallArgument{Value: uintptr(unix.SIGKILL)}, - arch.SyscallArgument{Value: 0}, - arch.SyscallArgument{Value: 0}, - arch.SyscallArgument{Value: 0}, - arch.SyscallArgument{Value: 0}, - ) - if err != nil { - panic(fmt.Sprintf("prctl: %v", err)) - } - // Set the sysmsg signal stack. // // sentryAddr is from the stub mapping which is mapped once and never @@ -61,7 +47,7 @@ func (p *sysmsgThread) init(sentryAddr, guestAddr uintptr) { *alt = linux.SignalStack{} alt.Addr = uint64(guestAddr) alt.Size = uint64(sysmsg.MsgOffsetFromSharedStack) - _, err = t.syscallIgnoreInterrupt(&t.initRegs, unix.SYS_SIGALTSTACK, + _, err := t.syscallIgnoreInterrupt(&t.initRegs, unix.SYS_SIGALTSTACK, arch.SyscallArgument{Value: guestAddr}, arch.SyscallArgument{Value: 0}, arch.SyscallArgument{Value: 0},