gvisor/pkg
Jianfeng Tan 96f78e2466 unix: return zero if peer is closed
Previously, recvmsg() on a unix stream socket with its peer closed will
never return, with goroutine call trace like this:

  ...
  2  in gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).block
     at pkg/sentry/kernel/task_block.go:124
  3  in gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).BlockWithDeadline
     at pkg/sentry/kernel/task_block.go:69
  4  in gvisor.dev/gvisor/pkg/sentry/socket/unix.(*SocketOperations).RecvMsg
     at pkg/sentry/socket/unix/unix.go:612
  5  in gvisor.dev/gvisor/pkg/sentry/syscalls/linux.recvFrom
     at pkg/sentry/syscalls/linux/sys_socket.go:885
  6  in gvisor.dev/gvisor/pkg/sentry/syscalls/linux.RecvFrom
     at pkg/sentry/syscalls/linux/sys_socket.go:910
  ...

The issue is caused by that ErrClosedForReceive returned by
unix/transport.queue is turned into nil in
unix.(*EndpointReader).ReadToBlocks():

  err.ToError()

As a result, in unix.(*SocketOperations).RecvMsg():

  n == 0 and err == nil

We shall differentiate it from another case - no data to read where
ErrWouldBlock shall be returned; and return 0 immediately.

Fixes: #734

Reported-by: chenglang.hy <chenglang.hy@antfin.com>
Signed-off-by: Jianfeng Tan <henry.tjf@antfin.com>
2019-08-22 15:25:38 +00:00
..
abi Document RWF_HIPRI not implemented for preadv2/pwritev2. 2019-08-19 14:07:44 -07:00
amutex Fix various spelling issues in the documentation 2019-06-27 14:25:50 -07:00
atomicbitops Update canonical repository. 2019-06-13 16:50:15 -07:00
binary Update canonical repository. 2019-06-13 16:50:15 -07:00
bits Update canonical repository. 2019-06-13 16:50:15 -07:00
bpf Update canonical repository. 2019-06-13 16:50:15 -07:00
compressio Update canonical repository. 2019-06-13 16:50:15 -07:00
control Update canonical repository. 2019-06-13 16:50:15 -07:00
cpuid Fix various spelling issues in the documentation 2019-06-27 14:25:50 -07:00
eventchannel Rate limit the unimplemented syscall event handler. 2019-07-29 17:12:50 -07:00
fd Fix various spelling issues in the documentation 2019-06-27 14:25:50 -07:00
fdchannel Add //pkg/fdchannel. 2019-06-25 15:38:11 -07:00
fdnotifier Change syscall.EPOLLET to unix.EPOLLET 2019-08-05 23:10:08 +00:00
flipcall Flipcall refinements. 2019-07-31 12:56:04 -07:00
fspath Sentry virtual filesystem, v2 2019-07-18 15:10:29 -07:00
gate Update canonical repository. 2019-06-13 16:50:15 -07:00
ilist Update canonical repository. 2019-06-13 16:50:15 -07:00
linewriter Update canonical repository. 2019-06-13 16:50:15 -07:00
log Fix various spelling issues in the documentation 2019-06-27 14:25:50 -07:00
memutil Update canonical repository. 2019-06-13 16:50:15 -07:00
metric Update canonical repository. 2019-06-13 16:50:15 -07:00
p9 Drop local_server support. 2019-06-28 20:35:10 -07:00
procid Update canonical repository. 2019-06-13 16:50:15 -07:00
rand Update canonical repository. 2019-06-13 16:50:15 -07:00
refs Add note to name logging mentioning trace logging should be enabled to debug. 2019-08-13 12:49:18 -07:00
seccomp Change syscall.POLL to syscall.PPOLL. 2019-07-30 11:01:29 -07:00
secio Update canonical repository. 2019-06-13 16:50:15 -07:00
segment Fix various spelling issues in the documentation 2019-06-27 14:25:50 -07:00
sentry unix: return zero if peer is closed 2019-08-22 15:25:38 +00:00
sleep Update canonical repository. 2019-06-13 16:50:15 -07:00
state Fix various spelling issues in the documentation 2019-06-27 14:25:50 -07:00
syserr netstack/udp: connect with the AF_UNSPEC address family means disconnect 2019-07-03 14:19:02 -07:00
syserror Cleanup straggling syscall dependencies. 2019-07-09 16:18:02 -07:00
tcpip Support binding to multicast and broadcast addresses 2019-08-21 22:54:25 -07:00
tmutex Update canonical repository. 2019-06-13 16:50:15 -07:00
unet Change syscall.POLL to syscall.PPOLL. 2019-07-30 11:01:29 -07:00
urpc Fix various spelling issues in the documentation 2019-06-27 14:25:50 -07:00
waiter Update canonical repository. 2019-06-13 16:50:15 -07:00