]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MAJOR: stats-file: fix crash on non-x86 platform caused by unaligned cast
authorWilly Tarreau <w@1wt.eu>
Mon, 3 Nov 2025 06:13:53 +0000 (07:13 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 3 Nov 2025 06:33:11 +0000 (07:33 +0100)
commitad1bdc3364c660fefb009ed99ebaa50479d1d8c0
tree6938bddc815acf15f9a252c0027b7104638628b1
parent561dc127bd3a2eb86740e8f92ba12ff076ba4944
BUG/MAJOR: stats-file: fix crash on non-x86 platform caused by unaligned cast

Since commit d655ed5f14 ("BUG/MAJOR: stats-file: ensure
shm_stats_file_object struct mapping consistency (2nd attempt)"), the
last_state_change field in the counters is a uint (to match how it's
reported). However, it happens that there are explicit casts in function
me_generate_field() to retrieve the value, and which cause crashes on
aarch64 and likely other non-x86 64-bit platforms due to atomically
reading an unaligned 64-bit value, and may even randomly crash other
64-bit platforms when reading past the end of the structure.

The fix for now adapts the cast to match the one used by the accessed
type (i.e. unsigned int), but the approach must change, as there's
nothing there which allows to figure whether or not the type is correct
by just reading the code. At minima a typeof() on a named field is
needed, but this requires more invasive changes, hence this temporary
fix.

No backport is needed, as stats-file is only in 3.3.
src/stats-proxy.c