From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 789C4606A31C for ; Mon, 30 Nov 2026 12:31:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=T1UEVvT5 Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3C73240288; Mon, 30 Nov 2026 13:31:16 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTPS id ABD8340288 for ; Mon, 30 Nov 2026 13:31:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796041873; 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; bh=mH6lBKax/tZGFMB5h2Ztb9S4S4KCaAJuXQ9vlr7ecKQ=; b=T1UEVvT5EF572NCV/N7qSjPPRtt0uNQf8EXrUuVLVVAs900MdnUZAVBlEPzqya8bMrwlBJ 96TbcQUbBjhsdGPtwpLW6nRbpkuUSe1eIg21yRsWgkxQkpxLUcvMqsq35LAIVyT5eWyzQZ 8RuK7XR0dRPHLfafgVwgcyd+fgj56aU= Received: from mx-prod-mc-05.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-652--WBWLVr3MGWjAGA0pVG7vw-1; Mon, 30 Nov 2026 12:31:10 +0000 X-MC-Unique: -WBWLVr3MGWjAGA0pVG7vw-1 X-Mimecast-MFC-AGG-ID: -WBWLVr3MGWjAGA0pVG7vw_1796041868 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 660641955F2D; Mon, 30 Nov 2026 12:31:08 +0000 (UTC) Received: from ringo.home (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 58F90436; Mon, 30 Nov 2026 12:31:06 +0000 (UTC) From: Robin Jarry To: dev@dpdk.org, Konstantin Ananyev , Wathsala Vithanage , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Stephen Hemminger Cc: stable@dpdk.org Subject: [PATCH dpdk] ring: bound wraparound enqueue by input length Date: Mon, 30 Nov 2026 13:31:01 +0100 Message-ID: <20261130123100.247604-2-rjarry@redhat.com> X-Archived-By: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ktK0Tn6aT2D9i6HfFBYMTdaxPx0dtCcbaods-zPKFGk_1796041868 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Archive: List-Post: List-Help: List-Subscribe: , X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 GCC 13 at -O2 reports -Wmaybe-uninitialized for a fully initialized 24-byte item passed to rte_ring_enqueue_elem(): struct item item = { .callback = cb, .obj = obj, .priv = priv }; rte_ring_enqueue_elem(ring, &item, sizeof(item)); In DPDK 25.11, the single-thread head update uses rte_smp_rmb(), which expands to empty assembly with a memory clobber on x86. Commit f2f3cf6d098a ("ring: replace SMP barrier with acquire fence") replaces it with an acquire fence. Neither needs a CPU instruction on x86, but GCC 13 analyzes the inlined copy differently: the warning appears with the acquire fence and disappears when the compiler barrier is restored. The item is initialized. For a valid wrap, size - idx < n, so the first copy loop cannot read more than n input words. GCC 13 fails to establish that bound from the ring indices. State it in the loop condition instead of relying on the barrier to hide the warning. This does not change the copy for valid ring indices. Fixes: f2f3cf6d098a ("ring: replace SMP barrier with acquire fence") Cc: stable@dpdk.org Signed-off-by: Robin Jarry --- lib/ring/rte_ring_elem_pvt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ring/rte_ring_elem_pvt.h b/lib/ring/rte_ring_elem_pvt.h index 3d680749ad96..404bf1d8d24e 100644 --- a/lib/ring/rte_ring_elem_pvt.h +++ b/lib/ring/rte_ring_elem_pvt.h @@ -47,7 +47,7 @@ __rte_ring_enqueue_elems_32(void *ring_table, const void *obj_table, ring[idx++] = obj[i++]; /* fallthrough */ } } else { - for (i = 0; idx < size; i++, idx++) + for (i = 0; idx < size && i < n; i++, idx++) ring[idx] = obj[i]; /* Start at the beginning */ for (idx = 0; i < n; i++, idx++) -- 2.56.1