]> git.ipfire.org Git - thirdparty/linux.git/commit
vsock: keep poll shutdown state consistent
authorZiyu Zhang <ziyuzhang201@gmail.com>
Tue, 19 May 2026 16:56:36 +0000 (00:56 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 22 May 2026 18:27:57 +0000 (11:27 -0700)
commitaae9d8a5528b8ee9ff8dc5d3558b8a9f852a724a
treeb1d0d9d322400ad8eefe018d076cf1ea532153af
parentaa8963fdce667a42fb7f0bdd2909fadcab02f9a8
vsock: keep poll shutdown state consistent

vsock_poll() reads vsk->peer_shutdown before taking the socket lock
to set EPOLLHUP and EPOLLRDHUP, then reads it again after taking
the lock to report EOF readability. A shutdown packet can update
peer_shutdown while poll is waiting for the lock, so one poll invocation
can report EOF readability without the corresponding HUP/RDHUP bits.

For connectible sockets, take one peer_shutdown snapshot after
lock_sock() and use it for all peer-shutdown-derived poll bits. For
datagram sockets, which do not take lock_sock() in poll(), take one
lockless READ_ONCE() snapshot and pair it with WRITE_ONCE() on the
writer side.

This keeps the peer-shutdown-derived bits internally consistent for each
poll pass.

Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
Signed-off-by: Ziyu Zhang <ziyuzhang201@gmail.com>
Link: https://patch.msgid.link/20260519165636.62542-1-ziyuzhang201@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/vmw_vsock/af_vsock.c
net/vmw_vsock/hyperv_transport.c
net/vmw_vsock/virtio_transport_common.c
net/vmw_vsock/vmci_transport.c