summaryrefslogtreecommitdiff
path: root/include/uapi/linux
diff options
context:
space:
mode:
authorAndrey Drobyshev <andrey.drobyshev@virtuozzo.com>2026-07-24 14:45:41 +0300
committerMichael S. Tsirkin <mst@redhat.com>2026-09-17 11:39:30 -0400
commit5efd97e6f0c745d5cb34e4e3b709200e23d4d7b7 (patch)
tree655f3166b231826cea0469873c08acc0b710acf3 /include/uapi/linux
parentbb52825eddec2801ae9ace88f53dfee01d22b9bd (diff)
downloadlinux-next-5efd97e6f0c745d5cb34e4e3b709200e23d4d7b7.tar.gz
linux-next-5efd97e6f0c745d5cb34e4e3b709200e23d4d7b7.zip
vhost: synchronize with RCU readers when freeing workers
vhost_vq_work_queue() only holds the RCU read lock while it dereferences vq->worker and queues work on it. vhost_workers_free() however clears the vq->worker pointers and immediately frees the workers, without waiting for a grace period. A caller that fetched the worker right before the pointer was cleared can therefore still be queueing work on it while it is freed. And even when the queueing itself wins the race, the work is never run, so its VHOST_WORK_QUEUED bit stays set and all future attempts to queue it are silently skipped. None of the current callers can actually hit this: net and scsi stop their virtqueues before the workers are freed, and vsock unhashes the device and does synchronize_rcu() of its own in vhost_vsock_dev_release() before the workers go away. But the upcoming VHOST_RESET_OWNER support in vhost-vsock keeps the device hashed while its workers are freed, so the lockless send/cancel paths become able to race with the teardown. Fix this by threading a bool 'sync' param through the chain: vhost_dev_reset_owner() vhost_dev_cleanup() vhost_workers_free() When set, after clearing the vq->worker pointers, wait for a grace period and flush the workers so any work the last RCU readers queued runs (clearing VHOST_WORK_QUEUED) before the workers are freed. Only the vsock RESET_OWNER path (added in the next patch) passes sync=true; every other teardown has already quiesced and passes false, so they do not need to wait the grace period. Suggested-by: Stefano Garzarella <sgarzare@redhat.com> Suggested-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20260724114542.734623-5-andrey.drobyshev@virtuozzo.com>
Diffstat (limited to 'include/uapi/linux')
0 files changed, 0 insertions, 0 deletions