From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ak+qgnJI; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id E19EB5A061C for ; Tue, 16 Jun 2026 19:11:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781629861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BGfozPiGhaA7NWVCBIeIt7kUz+FGAXihuNGT2MlDcmE=; b=ak+qgnJI7RLbR8FJ+IBovi6fj/kRfWf+AkUt2fz5aVu9H+d2JUcIUqCq5pDqMIBSIQogYp 8ydbm4q2cv/0EkWb6XbnRfOnHpxH4Li0roMRdrlPEfRAFo4jlUuU97zUQEDlQ1z0cTdpIP nlmDVnEQdp2Fg2yy+JB6yruNe1hCsTo= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-408-WYzGFN5zODacbm10nug1_w-1; Tue, 16 Jun 2026 13:11:00 -0400 X-MC-Unique: WYzGFN5zODacbm10nug1_w-1 X-Mimecast-MFC-AGG-ID: WYzGFN5zODacbm10nug1_w_1781629859 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6F1961955F2A for ; Tue, 16 Jun 2026 17:10:59 +0000 (UTC) Received: from lenovo-t14s.redhat.corp (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 927CB195410F; Tue, 16 Jun 2026 17:10:58 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH 4/8] udp_vu: Make virtqueue buffers stack-local for thread safety Date: Tue, 16 Jun 2026 19:10:48 +0200 Message-ID: <20260616171052.3785909-5-lvivier@redhat.com> In-Reply-To: <20260616171052.3785909-1-lvivier@redhat.com> References: <20260616171052.3785909-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: WS-W-FLhlckQ7-g7wcQH3k2b9E5KEGKiAFP-4FMdCt8_1781629859 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: RXYSJWHU3ZN2H2TEEIBK4N26TEZDSJDQ X-Message-ID-Hash: RXYSJWHU3ZN2H2TEEIBK4N26TEZDSJDQ X-MailFrom: lvivier@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- udp_vu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/udp_vu.c b/udp_vu.c index 864e7a99b8d9..342673dc7e6d 100644 --- a/udp_vu.c +++ b/udp_vu.c @@ -146,8 +146,8 @@ 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]; - static struct iovec iov_vu[VIRTQUEUE_MAX_SIZE]; + struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE]; + struct iovec iov_vu[VIRTQUEUE_MAX_SIZE]; int rx_queue = QPAIR_TOGUEST_QUEUE(qpair); struct vu_dev *vdev = c->vdev; struct vu_virtq *vq = &vdev->vq[rx_queue]; -- 2.54.0