Skip to content

Commit 4eb726b

Browse files
committed
netdev-dpdk: Fix vhost_driver_flags data race in destruct.
Coverity reports a data race where netdev_dpdk_vhost_destruct() accesses vhost_driver_flags without holding dpdk_mutex, while netdev_dpdk_vhost_client_reconfigure() writes to vhost_driver_flags with the mutex held (as is done 4 out of 4 times when writing). This could cause a race if another thread modifies vhost_driver_flags through netdev_dpdk_vhost_client_reconfigure() at the same time the destructor is running, potentially leading to incorrect socket cleanup. Fix by capturing the flag value while holding dpdk_mutex, similar to how vhost_id is already handled. Fixes: c1ff66a ("netdev-dpdk: vHost client mode and reconnect") Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com> Acked-by: Mike Pattrick <mkp@redhat.com> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
1 parent fc9442d commit 4eb726b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/netdev-dpdk.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,7 @@ static void
18431843
netdev_dpdk_vhost_destruct(struct netdev *netdev)
18441844
{
18451845
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
1846+
bool is_client_mode;
18461847
char *vhost_id;
18471848

18481849
ovs_mutex_lock(&dpdk_mutex);
@@ -1857,6 +1858,7 @@ netdev_dpdk_vhost_destruct(struct netdev *netdev)
18571858
}
18581859

18591860
vhost_id = dev->vhost_id;
1861+
is_client_mode = dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT;
18601862
dev->vhost_id = NULL;
18611863
rte_free(dev->vhost_rxq_enabled);
18621864

@@ -1871,7 +1873,7 @@ netdev_dpdk_vhost_destruct(struct netdev *netdev)
18711873
if (dpdk_vhost_driver_unregister(dev, vhost_id)) {
18721874
VLOG_ERR("%s: Unable to unregister vhost driver for socket '%s'.\n",
18731875
netdev->name, vhost_id);
1874-
} else if (!(dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT)) {
1876+
} else if (!is_client_mode) {
18751877
/* OVS server mode - remove this socket from list for deletion */
18761878
fatal_signal_remove_file_to_unlink(vhost_id);
18771879
}

0 commit comments

Comments
 (0)