On Fri, Jul 31, 2026 at 06:23:23PM +0200, Laurent Vivier wrote:
The function-local static buffers elem[] and iov_vu[] in udp_vu_sock_to_tap() are shared across all threads. When multiple worker threads process UDP vhost-user data concurrently, they would stomp on each other's buffers.
Remove the static qualifier so each call gets its own stack-allocated arrays, eliminating cross-thread sharing.
Signed-off-by: Laurent Vivier
Reviewed-by: David Gibson
--- udp_vu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/udp_vu.c b/udp_vu.c index 21fa891b3b51..c045e421001c 100644 --- a/udp_vu.c +++ b/udp_vu.c @@ -151,9 +151,9 @@ void udp_vu_sock_to_tap(const struct ctx *c, int s, int n, flow_sidx_t tosidx, { const struct flowside *toside = flowside_at_sidx(tosidx); bool v6 = !(inany_v4(&toside->eaddr) && inany_v4(&toside->oaddr)); - static struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE]; + struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE]; + struct iovec iov_vu[VIRTQUEUE_MAX_SIZE]; int toguest = QPAIR_TOGUEST_QUEUE(qpair); - static struct iovec iov_vu[VIRTQUEUE_MAX_SIZE]; struct vu_dev *vdev = c->vdev; struct vu_virtq *vq = &vdev->vq[toguest]; size_t hdrlen = udp_vu_hdrlen(v6); -- 2.54.0
-- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson