[PATCH v4 09/22] stack: fix unaligned accesses on 128-bit
David Marchand
david.marchand at redhat.com
Wed Jul 16 15:01:56 CEST 2025
Caught by UBSan:
../lib/eal/x86/include/rte_atomic_64.h:206:21: runtime error:
member access within misaligned address 0x7ffd9c67f228 for
type 'const rte_int128_t', which requires 16 byte alignment
0x7ffd9c67f228: note: pointer points here
00 00 00 00 c0 5d 3e 00 01 00 00 00 01 00 00 00 00 00 00 00
^
00 00 00 00 00 00 00 00 00 00 00 00
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
../lib/eal/x86/include/rte_atomic_64.h:206:21 in
../lib/eal/x86/include/rte_atomic_64.h:206:21: runtime error:
member access within misaligned address 0x7ffd9c67f228 for type
'const union rte_int128_t::(anonymous at
../lib/eal/include/generic/rte_atomic.h:1102:2)', which requires
16 byte alignment
0x7ffd9c67f228: note: pointer points here
00 00 00 00 c0 5d 3e 00 01 00 00 00 01 00 00 00 00 00 00 00
^
00 00 00 00 00 00 00 00 00 00 00 00
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
../lib/eal/x86/include/rte_atomic_64.h:206:21 in
../lib/eal/x86/include/rte_atomic_64.h:206:16: runtime error:
load of misaligned address 0x7ffd9c67f228 for type
'const uint64_t' (aka 'const unsigned long'), which requires
16 byte alignment
0x7ffd9c67f228: note: pointer points here
00 00 00 00 c0 5d 3e 00 01 00 00 00 01 00 00 00 00 00 00 00
^
00 00 00 00 00 00 00 00 00 00 00 00
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
../lib/eal/x86/include/rte_atomic_64.h:206:21 in
Rather than explicitly set alignment in callers, mark the structure
itself with an alignment constraint.
Fixes: 3340202f5954 ("stack: add lock-free implementation")
Signed-off-by: David Marchand <david.marchand at redhat.com>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev at huawei.com>
---
Changes since v3:
- changed rte_stack_lf_head struct alignment,
---
devtools/libabigail.abignore | 8 ++++++++
lib/stack/rte_stack.h | 4 ++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/devtools/libabigail.abignore b/devtools/libabigail.abignore
index 96ae32455f..c65bea2b51 100644
--- a/devtools/libabigail.abignore
+++ b/devtools/libabigail.abignore
@@ -47,3 +47,11 @@
name = rte_node
has_size_change = no
has_data_member_inserted_between = {offset_after(original_process), offset_of(xstat_off)}
+
+;;;;;;;;;;;;;;;;;;;
+; DONT MERGE THIS ;
+;;;;;;;;;;;;;;;;;;;
+
+[suppress_type]
+ name = rte_stack_lf_list
+ has_size_change = yes
diff --git a/lib/stack/rte_stack.h b/lib/stack/rte_stack.h
index 4439adfc42..fd17ac791d 100644
--- a/lib/stack/rte_stack.h
+++ b/lib/stack/rte_stack.h
@@ -33,14 +33,14 @@ struct rte_stack_lf_elem {
struct rte_stack_lf_elem *next; /**< Next pointer */
};
-struct rte_stack_lf_head {
+struct __rte_aligned(16) rte_stack_lf_head {
struct rte_stack_lf_elem *top; /**< Stack top */
uint64_t cnt; /**< Modification counter for avoiding ABA problem */
};
struct rte_stack_lf_list {
/** List head */
- alignas(16) struct rte_stack_lf_head head;
+ struct rte_stack_lf_head head;
/** List len */
RTE_ATOMIC(uint64_t) len;
};
--
2.50.0
More information about the dev
mailing list