Skip to content

Commit f86caea

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 71dae04 commit f86caea

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
@@ -1822,6 +1822,7 @@ static void
18221822
netdev_dpdk_vhost_destruct(struct netdev *netdev)
18231823
{
18241824
struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
1825+
bool is_client_mode;
18251826
char *vhost_id;
18261827

18271828
ovs_mutex_lock(&dpdk_mutex);
@@ -1836,6 +1837,7 @@ netdev_dpdk_vhost_destruct(struct netdev *netdev)
18361837
}
18371838

18381839
vhost_id = dev->vhost_id;
1840+
is_client_mode = dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT;
18391841
dev->vhost_id = NULL;
18401842
rte_free(dev->vhost_rxq_enabled);
18411843

@@ -1850,7 +1852,7 @@ netdev_dpdk_vhost_destruct(struct netdev *netdev)
18501852
if (dpdk_vhost_driver_unregister(dev, vhost_id)) {
18511853
VLOG_ERR("%s: Unable to unregister vhost driver for socket '%s'.\n",
18521854
netdev->name, vhost_id);
1853-
} else if (!(dev->vhost_driver_flags & RTE_VHOST_USER_CLIENT)) {
1855+
} else if (!is_client_mode) {
18541856
/* OVS server mode - remove this socket from list for deletion */
18551857
fatal_signal_remove_file_to_unlink(vhost_id);
18561858
}

0 commit comments

Comments
 (0)