Skip to content

Commit

Permalink
gvisor/ptrace: grub initial thread registers only once
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 255465635
  • Loading branch information
avagin authored and gvisor-bot committed Jun 27, 2019
1 parent 7188790 commit e276083
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sentry/platform/ptrace/subprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func newSubprocess(create func() (*thread, error)) (*subprocess, error) {
errChan <- err
return
}
firstThread.grabInitRegs()

// Ready to handle requests.
errChan <- nil
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/sentry/platform/ptrace/subprocess_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e276083

Please sign in to comment.