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
This commit is contained in:
Brian Geffon 2018-06-08 10:32:30 -07:00 committed by Shentubot
parent 5c51bc51e4
commit 2f3895d6f7
1 changed files with 4 additions and 4 deletions

View File

@ -465,8 +465,8 @@ func (s *socketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags
res, err := rpcRecvMsg(t, req) res, err := rpcRecvMsg(t, req)
if err == nil { if err == nil {
n, e := dst.CopyOut(t, res.Data) _, e := dst.CopyOut(t, res.Data)
return int(n), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e) return int(res.Length), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e)
} }
if err != syserr.ErrWouldBlock || flags&linux.MSG_DONTWAIT != 0 { if err != syserr.ErrWouldBlock || flags&linux.MSG_DONTWAIT != 0 {
return 0, nil, 0, socket.ControlMessages{}, err return 0, nil, 0, socket.ControlMessages{}, err
@ -481,8 +481,8 @@ func (s *socketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags
for { for {
res, err := rpcRecvMsg(t, req) res, err := rpcRecvMsg(t, req)
if err == nil { if err == nil {
n, e := dst.CopyOut(t, res.Data) _, e := dst.CopyOut(t, res.Data)
return int(n), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e) return int(res.Length), res.Address.GetAddress(), res.Address.GetLength(), socket.ControlMessages{}, syserr.FromError(e)
} }
if err != syserr.ErrWouldBlock { if err != syserr.ErrWouldBlock {
return 0, nil, 0, socket.ControlMessages{}, err return 0, nil, 0, socket.ControlMessages{}, err