summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorBrian Geffon <bgeffon@google.com>2018-06-08 10:32:30 -0700
committerShentubot <shentubot@google.com>2018-06-08 10:33:25 -0700
commit2f3895d6f7ad37915edcdd80706f880ce50c519c (patch)
tree31a4be0b3fe7631e6f386b633d6e187adcba7fb9 /pkg
parent5c51bc51e43a0f1d1f06ae490b0d352d1b483766 (diff)
rpcinet is not correctly handling MSG_TRUNC on recvmsg(2).
MSG_TRUNC can cause recvmsg(2) to return a value larger than the buffer size. In this situation it's an indication that the buffer was completely filled and that the msg was truncated. Previously in rpcinet we were returning the buffer size but we should actually be returning the payload length as returned by the syscall. PiperOrigin-RevId: 199814221 Change-Id: If09aa364219c1bf193603896fcc0dc5c55e85d21
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/socket/rpcinet/socket.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/sentry/socket/rpcinet/socket.go b/pkg/sentry/socket/rpcinet/socket.go
index 69cf604b7..c4ecb30f5 100644
--- a/pkg/sentry/socket/rpcinet/socket.go
+++ b/pkg/sentry/socket/rpcinet/socket.go
@@ -465,8 +465,8 @@ func (s *socketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags
res, err := rpcRecvMsg(t, req)
if err == nil {
- n, e := dst.CopyOut(t, res.Data)
- return int(n), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e)
+ _, e := dst.CopyOut(t, res.Data)
+ return int(res.Length), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e)
}
if err != syserr.ErrWouldBlock || flags&linux.MSG_DONTWAIT != 0 {
return 0, nil, 0, socket.ControlMessages{}, err
@@ -481,8 +481,8 @@ func (s *socketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags
for {
res, err := rpcRecvMsg(t, req)
if err == nil {
- n, e := dst.CopyOut(t, res.Data)
- return int(n), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e)
+ _, e := dst.CopyOut(t, res.Data)
+ return int(res.Length), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e)
}
if err != syserr.ErrWouldBlock {
return 0, nil, 0, socket.ControlMessages{}, err