summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/kernel/ptrace.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2018-10-17 11:51:43 -0700
committerShentubot <shentubot@google.com>2018-10-17 11:53:04 -0700
commit578fe5a50dcf8e104b6bce3802987b0f8c069ade (patch)
tree417958193942e67f24665434d6cd493af6451b9b /pkg/sentry/kernel/ptrace.go
parent6cba410df0ea2eabb87bad5074a8a79ed89312b8 (diff)
Fix PTRACE_GETREGSET write size
The existing logic is backwards and writes iov_len == 0 for a full write. PiperOrigin-RevId: 217560377 Change-Id: I5a39c31bf0ba9063a8495993bfef58dc8ab7c5fa
Diffstat (limited to 'pkg/sentry/kernel/ptrace.go')
-rw-r--r--pkg/sentry/kernel/ptrace.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/sentry/kernel/ptrace.go b/pkg/sentry/kernel/ptrace.go
index e21a25ae6..9fe28f435 100644
--- a/pkg/sentry/kernel/ptrace.go
+++ b/pkg/sentry/kernel/ptrace.go
@@ -921,7 +921,13 @@ func (t *Task) Ptrace(req int64, pid ThreadID, addr, data usermem.Addr) error {
if err != nil {
return err
}
- ar.End -= usermem.Addr(n)
+
+ // Update iovecs to represent the range of the written register set.
+ end, ok := ar.Start.AddLength(uint64(n))
+ if !ok {
+ panic(fmt.Sprintf("%#x + %#x overflows. Invalid reg size > %#x", ar.Start, n, ar.Length()))
+ }
+ ar.End = end
return t.CopyOutIovecs(data, usermem.AddrRangeSeqOf(ar))
case linux.PTRACE_SETREGS: