summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/socket/epsocket
diff options
context:
space:
mode:
authorBrian Geffon <bgeffon@google.com>2018-06-22 10:18:19 -0700
committerShentubot <shentubot@google.com>2018-06-22 10:19:25 -0700
commit5d45f88f2c2840123e2f5ec2e45ac6d5b5a5729f (patch)
treed20dc462747456e626fac898d02e36a188e00f73 /pkg/sentry/socket/epsocket
parente1aee51d09d650cca8d098050665c2d49d859e26 (diff)
Netstack should return EOF on closed read.
The shutdown behavior where we return EAGAIN for sockets which are non-blocking is only correct for packet based sockets. SOCK_STREAM sockets should return EOF. PiperOrigin-RevId: 201703055 Change-Id: I20b25ceca7286c37766936475855959706fc5397
Diffstat (limited to 'pkg/sentry/socket/epsocket')
-rw-r--r--pkg/sentry/socket/epsocket/epsocket.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/pkg/sentry/socket/epsocket/epsocket.go b/pkg/sentry/socket/epsocket/epsocket.go
index a1bb265c0..a2927e1b9 100644
--- a/pkg/sentry/socket/epsocket/epsocket.go
+++ b/pkg/sentry/socket/epsocket/epsocket.go
@@ -945,7 +945,6 @@ func (s *SocketOperations) nonBlockingRead(ctx context.Context, dst usermem.IOSe
// tcpip.Endpoint.
func (s *SocketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags int, haveDeadline bool, deadline ktime.Time, senderRequested bool, controlDataLen uint64) (n int, senderAddr interface{}, senderAddrLen uint32, controlMessages socket.ControlMessages, err *syserr.Error) {
trunc := flags&linux.MSG_TRUNC != 0
-
peek := flags&linux.MSG_PEEK != 0
if senderRequested && !s.isPacketBased() {
// Stream sockets ignore the sender address.
@@ -953,7 +952,7 @@ func (s *SocketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags
}
n, senderAddr, senderAddrLen, controlMessages, err = s.nonBlockingRead(t, dst, peek, trunc, senderRequested)
- if err == syserr.ErrClosedForReceive && flags&linux.MSG_DONTWAIT != 0 {
+ if s.isPacketBased() && err == syserr.ErrClosedForReceive && flags&linux.MSG_DONTWAIT != 0 {
// In this situation we should return EAGAIN.
return 0, nil, 0, socket.ControlMessages{}, syserr.ErrTryAgain
}