]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stick-tables: properly mark stktable_data as packed
authorWilly Tarreau <w@1wt.eu>
Wed, 15 May 2024 14:22:23 +0000 (16:22 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 15 May 2024 17:03:18 +0000 (19:03 +0200)
The stktable_data union is made of types of varying sizes, and depending
on which types are stored in a table, some offsets might not necessarily
be aligned. This results in a bus error for certain regtests (e.g.
lb-services) on MIPS64. This bug may impact MIPS64, SPARC64, armv7 when
accessing a 64-bit counter (e.g. bytes) and depending on how the compiler
emitted the operation, and cause a trap that's emulated by the OS on RISCV
(heavy cost). x86_64 and armv8 are not affected at all.

Let's properly mark the struct with __attribute__((packed)) so that the
compiler emits the suitable unaligned-compatible instructions when
accessing the fields.

This should be backported to all versions where it applies.

include/haproxy/stick_table-t.h

index 33c719cbcb5872362723f09fdd7f02df98a5aa69..fe23848dd70f4e42ea33da7495c313d1d22d1bbd 100644 (file)
@@ -119,7 +119,7 @@ union stktable_data {
        unsigned long long std_t_ull;
        struct freq_ctr std_t_frqp;
        struct dict_entry *std_t_dict;
-};
+} __attribute__((packed));
 
 /* known data types */
 struct stktable_data_type {