diff options
author | Brian Geffon <bgeffon@google.com> | 2018-06-08 15:57:33 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-06-08 15:58:22 -0700 |
commit | 2fbd1cf57cb06c5f0165a2d0e9225eed242a41f5 (patch) | |
tree | 60d6d88c39ef182cdd12b67504219e1b87f92dad | |
parent | 6728f09910bd9f7633f277fafe6945cfaa2abf42 (diff) |
Add checks for short CopyOut in rpcinet
PiperOrigin-RevId: 199864753
Change-Id: Ibace6a1fdf99ee6ce368ac12c390aa8a02dbdfb7
-rw-r--r-- | pkg/sentry/socket/rpcinet/socket.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pkg/sentry/socket/rpcinet/socket.go b/pkg/sentry/socket/rpcinet/socket.go index c4ecb30f5..a9dd1780a 100644 --- a/pkg/sentry/socket/rpcinet/socket.go +++ b/pkg/sentry/socket/rpcinet/socket.go @@ -465,7 +465,10 @@ func (s *socketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags res, err := rpcRecvMsg(t, req) if err == nil { - _, e := dst.CopyOut(t, res.Data) + n, e := dst.CopyOut(t, res.Data) + if e == nil && n != len(res.Data) { + panic("CopyOut failed to copy full buffer") + } return int(res.Length), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e) } if err != syserr.ErrWouldBlock || flags&linux.MSG_DONTWAIT != 0 { @@ -481,7 +484,10 @@ func (s *socketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags for { res, err := rpcRecvMsg(t, req) if err == nil { - _, e := dst.CopyOut(t, res.Data) + n, e := dst.CopyOut(t, res.Data) + if e == nil && n != len(res.Data) { + panic("CopyOut failed to copy full buffer") + } return int(res.Length), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e) } if err != syserr.ErrWouldBlock { |