From 5c2b348a547ea9363fa920dcedebb42be194393b Mon Sep 17 00:00:00 2001 From: Vincenzo Maffione Date: Tue, 18 Jun 2019 17:51:30 +0000 Subject: [PATCH] bhyve: vtnet: fix locking on receive The vsc_rx_ready and the RX virtqueue is protected by the rx_mtx lock. However, pci_vtnet_ping_rxq() (currently called only once after each device reset) accesses those without acquiring the lock. Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D20609 --- usr.sbin/bhyve/pci_virtio_net.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c index 50bbcae134c1..af57a70d025c 100644 --- a/usr.sbin/bhyve/pci_virtio_net.c +++ b/usr.sbin/bhyve/pci_virtio_net.c @@ -583,10 +583,12 @@ pci_vtnet_ping_rxq(void *vsc, struct vqueue_info *vq) /* * A qnotify means that the rx process can now begin */ + pthread_mutex_lock(&sc->rx_mtx); if (sc->vsc_rx_ready == 0) { sc->vsc_rx_ready = 1; vq_kick_disable(vq); } + pthread_mutex_unlock(&sc->rx_mtx); } static void