From 578fe5a50dcf8e104b6bce3802987b0f8c069ade Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 17 Oct 2018 11:51:43 -0700 Subject: 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 --- pkg/sentry/kernel/ptrace.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'pkg/sentry') 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: -- cgit v1.2.3