From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Stephen Hemminger" <stephen@networkplumber.org>, <dev@dpdk.org>
Cc: "Honnappa Nagarahalli" <honnappa.nagarahalli@arm.com>,
"Konstantin Ananyev" <konstantin.ananyev@huawei.com>
Subject: RE: [PATCH v3 1/6] test/soring: fix buffer overflow warnings with LTO
Date: Fri, 16 Jan 2026 10:32:52 +0100 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35F65669@smartserver.smartshare.dk> (raw)
In-Reply-To: <20260116064646.224254-2-stephen@networkplumber.org>
> From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> Sent: Friday, 16 January 2026 07.46
>
> When building with LTO (Link Time Optimization), GCC performs
> aggressive cross-compilation-unit inlining. This causes the compiler
> to analyze all code paths in __rte_ring_do_dequeue_elems(), including
> the 16-byte element path (__rte_ring_dequeue_elems_128), even when
> the runtime element size is only 4 bytes.
>
> The static analyzer sees that the 16-byte path would copy
> 32 elements * 16 bytes = 512 bytes into a 128-byte buffer
> (uint32_t[32]),
> triggering -Wstringop-overflow warnings.
>
> The existing #pragma GCC diagnostic suppression in rte_ring_elem_pvt.h
> doesn't help because with LTO the warning context shifts to the test
> file where the inlined code is instantiated.
>
> Fix by sizing all buffers passed to soring acquire/dequeue functions
> for the worst-case element size (16 bytes = 4 * sizeof(uint32_t)).
> This satisfies the static analyzer without changing runtime behavior.
Using wildly oversized buffers doesn't seem like a recommendable solution.
If the ring library is ever updated to support cache size elements (64 byte), the buffers would have to be oversize by factor 16.
Maybe adding __rte_assume(sor->esize == sizeof(uint32_t)); immediately before calling each of the affected soring functions would fix the problem instead?
It's only a test application, so oversized buffers as a workaround is acceptable.
But if it serves as guidance for real applications, a better solution/workaround would be preferable.
>
> Bugzilla ID: 1458
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> app/test/test_soring.c | 29 ++++++++++++++++++++++-------
> 1 file changed, 22 insertions(+), 7 deletions(-)
>
> diff --git a/app/test/test_soring.c b/app/test/test_soring.c
> index 3c1944424e..96be3935d4 100644
> --- a/app/test/test_soring.c
> +++ b/app/test/test_soring.c
> @@ -31,6 +31,19 @@
>
> #define MAX_ACQUIRED 20
>
> +/*
> + * Buffer scaling factor for static analyzer appeasement.
> + *
> + * With LTO, GCC analyzes all code paths in
> __rte_ring_do_dequeue_elems(),
> + * including the 16-byte element path, even when runtime esize is
> smaller.
> + * Buffers passed to soring acquire/dequeue must be sized for the
> worst-case
> + * element size (16 bytes) to avoid -Wstringop-overflow warnings.
> + *
> + * Scale factor of 4 converts uint32_t count to 16-byte element
> capacity:
> + * N elements * 4 * sizeof(uint32_t) = N * 16 bytes
> + */
> +#define SORING_TEST_BUFSIZE(n) ((n) * 4)
> +
> #define SORING_TEST_ASSERT(val, expected) do { \
> RTE_TEST_ASSERT(expected == val, \
> "%s: expected %u got %u\n", #val, expected, val); \
> @@ -58,7 +71,8 @@ move_forward_stage(struct rte_soring *sor,
> {
> uint32_t acquired;
> uint32_t ftoken;
> - uint32_t *acquired_objs[MAX_ACQUIRED];
> + /* Sized for 16-byte elements to satisfy LTO static analysis */
> + uint32_t *acquired_objs[SORING_TEST_BUFSIZE(MAX_ACQUIRED)];
>
> acquired = rte_soring_acquire_bulk(sor, acquired_objs, stage,
> num_packets, &ftoken, NULL);
> @@ -149,12 +163,13 @@ test_soring_stages(void)
> {
> struct rte_soring *sor = NULL;
> struct rte_soring_param prm;
> - uint32_t objs[32];
> - uint32_t rcs[32];
> - uint32_t acquired_objs[32];
> - uint32_t acquired_rcs[32];
> - uint32_t dequeued_rcs[32];
> - uint32_t dequeued_objs[32];
> + /* Buffers sized for 16-byte elements to satisfy LTO static
> analysis */
> + uint32_t objs[SORING_TEST_BUFSIZE(32)];
> + uint32_t rcs[SORING_TEST_BUFSIZE(32)];
> + uint32_t acquired_objs[SORING_TEST_BUFSIZE(32)];
> + uint32_t acquired_rcs[SORING_TEST_BUFSIZE(32)];
> + uint32_t dequeued_rcs[SORING_TEST_BUFSIZE(32)];
> + uint32_t dequeued_objs[SORING_TEST_BUFSIZE(32)];
> size_t ssz;
> uint32_t stage, enqueued, dequeued, acquired;
> uint32_t i, ftoken;
> --
> 2.51.0
next prev parent reply other threads:[~2026-01-16 9:33 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 19:41 [RFC 0/3] common/cnxk: remove dependence on VLA Stephen Hemminger
2025-10-23 19:41 ` [RFC 1/3] common/cnxk: replace variable length state array Stephen Hemminger
2025-10-23 19:41 ` [RFC 2/3] common/cnxk: replace variable length array Stephen Hemminger
2025-10-27 5:22 ` [EXTERNAL] " Harman Kalra
2025-10-23 19:41 ` [RFC 3/3] common/cnxk: re-enable vla warnings Stephen Hemminger
2026-01-14 1:49 ` [PATCH v2 0/3] common/cnxk: remove variable length arrays Stephen Hemminger
2026-01-14 1:49 ` [PATCH v2 1/3] common/cnxk: replace variable length state array Stephen Hemminger
2026-01-14 1:50 ` [PATCH v2 2/3] common/cnxk: replace variable length array Stephen Hemminger
2026-01-14 1:50 ` [PATCH v2 3/3] common/cnxk: re-enable vla warnings Stephen Hemminger
2026-01-16 6:46 ` [PATCH v3 0/6] fix GCC warnings when building with LTO Stephen Hemminger
2026-01-16 6:46 ` [PATCH v3 1/6] test/soring: fix buffer overflow warnings " Stephen Hemminger
2026-01-16 9:32 ` Morten Brørup [this message]
2026-01-19 22:48 ` Stephen Hemminger
2026-01-20 8:49 ` Morten Brørup
2026-01-20 14:34 ` Stephen Hemminger
2026-01-20 15:01 ` Morten Brørup
2026-01-20 15:40 ` Konstantin Ananyev
2026-01-20 15:48 ` Stephen Hemminger
2026-01-20 16:52 ` Stephen Hemminger
2026-01-20 19:27 ` Stephen Hemminger
2026-01-21 10:40 ` Morten Brørup
2026-01-21 12:56 ` Konstantin Ananyev
2026-01-21 14:57 ` Stephen Hemminger
2026-01-16 6:46 ` [PATCH v3 2/6] common/cnxk: replace variable length state array Stephen Hemminger
2026-01-16 6:46 ` [PATCH v3 3/6] common/cnxk: replace variable length array Stephen Hemminger
2026-01-16 6:46 ` [PATCH v3 4/6] common/cnxk: re-enable vla warnings Stephen Hemminger
2026-01-16 6:46 ` [PATCH v3 5/6] common/cnxk: fix buffer overflow in reassembly SA setup Stephen Hemminger
2026-01-16 6:46 ` [PATCH v3 6/6] net/mlx5/hws: fix LTO false positive stringop-overflow warning Stephen Hemminger
2026-01-19 22:44 ` [PATCH v4 0/6] fix build failures with LTO enabled Stephen Hemminger
2026-01-19 22:44 ` [PATCH v4 1/6] common/cnxk: replace variable length state array Stephen Hemminger
2026-01-19 22:44 ` [PATCH v4 2/6] common/cnxk: replace variable length array Stephen Hemminger
2026-01-19 22:44 ` [PATCH v4 3/6] common/cnxk: re-enable vla warnings Stephen Hemminger
2026-01-19 22:44 ` [PATCH v4 4/6] common/cnxk: fix buffer overflow in reassembly SA setup Stephen Hemminger
2026-01-19 22:44 ` [PATCH v4 5/6] net/mlx5: fix LTO false positive stringop-overflow warning Stephen Hemminger
2026-01-19 22:44 ` [PATCH v4 6/6] test/soring: fix stringop-overflow warning with LTO Stephen Hemminger
2026-01-20 19:52 ` [PATCH 0/6] Fix LTO compilation warnings Stephen Hemminger
2026-01-20 19:52 ` [PATCH v5 1/6] common/cnxk: replace variable length state array Stephen Hemminger
2026-01-20 19:52 ` [PATCH v5 2/6] common/cnxk: replace variable length array Stephen Hemminger
2026-01-20 19:52 ` [PATCH v5 3/6] common/cnxk: re-enable vla warnings Stephen Hemminger
2026-01-20 19:52 ` [PATCH v5 4/6] common/cnxk: fix buffer overflow in SA setup Stephen Hemminger
2026-01-20 19:52 ` [PATCH v5 5/6] net/mlx5: fix LTO stringop-overflow warning Stephen Hemminger
2026-02-05 13:43 ` Dariusz Sosnowski
2026-02-05 17:07 ` Stephen Hemminger
2026-01-20 19:52 ` [PATCH v5 6/6] ring: use inline instead of always inline in soring Stephen Hemminger
2026-01-22 9:52 ` Konstantin Ananyev
2026-01-22 10:49 ` Morten Brørup
2026-02-05 17:55 ` [PATCH v6 0/6] Fix LTO compilation warnings Stephen Hemminger
2026-02-05 17:55 ` [PATCH v6 1/6] common/cnxk: replace variable length state array Stephen Hemminger
2026-03-02 19:06 ` [EXTERNAL] " Tejasree Kondoj
2026-03-02 19:36 ` Stephen Hemminger
2026-02-05 17:55 ` [PATCH v6 2/6] common/cnxk: replace variable length array Stephen Hemminger
2026-03-02 10:51 ` [EXTERNAL] " Tejasree Kondoj
2026-02-05 17:55 ` [PATCH v6 3/6] common/cnxk: re-enable vla warnings Stephen Hemminger
2026-03-02 16:50 ` Nithin Dabilpuram
2026-02-05 17:55 ` [PATCH v6 4/6] common/cnxk: fix buffer overflow in SA setup Stephen Hemminger
2026-03-02 16:40 ` Nithin Dabilpuram
2026-02-05 17:55 ` [PATCH v6 5/6] ring: use inline instead of always inline in soring Stephen Hemminger
2026-02-05 17:55 ` [PATCH v6 6/6] net/mlx5: fix LTO stringop-overflow warning Stephen Hemminger
2026-02-06 9:51 ` Dariusz Sosnowski
2026-02-27 7:57 ` [PATCH v6 0/6] Fix LTO compilation warnings David Marchand
2026-03-03 16:24 ` David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=98CBD80474FA8B44BF855DF32C47DC35F65669@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=dev@dpdk.org \
--cc=honnappa.nagarahalli@arm.com \
--cc=konstantin.ananyev@huawei.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox