diff options
author | Eyal Soha <eyalsoha@google.com> | 2020-02-05 17:56:00 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-02-05 17:56:42 -0800 |
commit | f3d95607036b8a502c65aa7b3e8145227274dbbc (patch) | |
tree | f077cba6b93e226535d0bb87567af9915651801e /pkg/sentry | |
parent | f2d3efca1deded31a2929ea77c0eecf476764660 (diff) |
recv() on a closed TCP socket returns ENOTCONN
From RFC 793 s3.9 p58 Event Processing:
If RECEIVE Call arrives in CLOSED state and the user has access to such a
connection, the return should be "error: connection does not exist"
Fixes #1598
PiperOrigin-RevId: 293494287
Diffstat (limited to 'pkg/sentry')
-rw-r--r-- | pkg/sentry/socket/netstack/netstack.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/sentry/socket/netstack/netstack.go b/pkg/sentry/socket/netstack/netstack.go index 049d04bf2..ed2fbcceb 100644 --- a/pkg/sentry/socket/netstack/netstack.go +++ b/pkg/sentry/socket/netstack/netstack.go @@ -2229,11 +2229,16 @@ func (s *SocketOperations) coalescingRead(ctx context.Context, dst usermem.IOSeq var copied int // Copy as many views as possible into the user-provided buffer. - for dst.NumBytes() != 0 { + for { + // Always do at least one fetchReadView, even if the number of bytes to + // read is 0. err = s.fetchReadView() if err != nil { break } + if dst.NumBytes() == 0 { + break + } var n int var e error |