gvisor/ptrace: grub initial thread registers only once

PiperOrigin-RevId: 255465635
This commit is contained in:
Andrei Vagin
2019-06-27 13:59:57 -07:00
committed by gVisor bot
parent 7188790f92
commit e276083903
2 changed files with 5 additions and 0 deletions
+4
View File
@@ -155,6 +155,7 @@ func newSubprocess(create func() (*thread, error)) (*subprocess, error) {
errChan <- err
return
}
firstThread.grabInitRegs()
// Ready to handle requests.
errChan <- nil
@@ -179,6 +180,7 @@ func newSubprocess(create func() (*thread, error)) (*subprocess, error) {
// Detach the thread.
t.detach()
t.initRegs = firstThread.initRegs
// Return the thread.
r <- t
@@ -269,7 +271,9 @@ func (t *thread) attach() {
// Initialize options.
t.init()
}
func (t *thread) grabInitRegs() {
// Grab registers.
//
// Note that we adjust the current register RIP value to be just before
@@ -235,6 +235,7 @@ func attachedThread(flags uintptr, defaultAction linux.BPFAction) (*thread, erro
return nil, fmt.Errorf("wait failed: expected SIGSTOP, got %v", sig)
}
t.attach()
t.grabInitRegs()
return t, nil
}