From: Willy Tarreau Date: Fri, 7 Nov 2025 21:10:45 +0000 (+0100) Subject: BUG/MEDIUM: proxy: use aligned allocations for struct proxy_per_tgroup X-Git-Tag: v3.3-dev12~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb8edd0ce69e98e3c9a08e6546edceef1cc4a7f6;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: proxy: use aligned allocations for struct proxy_per_tgroup In 3.2, commit f879b9a18 ("MINOR: proxies: Add a per-thread group field to struct proxy") introduced struct proxy_per_tgroup that is declared as thread_aligned, but is allocated using calloc(). Thus it is at risk of crashing on machines using instructions requiring 64-byte alignment such as AVX512. Let's use ha_aligned_zalloc_typed() instead of malloc(). For 3.2, we don't have aligned allocations, so instead the THREAD_ALIGNED() will have to be removed from the struct definition. Alternately, we could manually align it as is done for fdtab. --- diff --git a/src/proxy.c b/src/proxy.c index 7bd259a97..429f4b110 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1507,7 +1507,7 @@ int proxy_init_per_thr(struct proxy *px) { int i; - px->per_tgrp = calloc(global.nbtgroups, sizeof(*px->per_tgrp)); + px->per_tgrp = ha_aligned_zalloc_typed(global.nbtgroups, typeof(*px->per_tgrp)); for (i = 0; i < global.nbtgroups; i++) queue_init(&px->per_tgrp[i].queue, px, NULL);