From: Eugene Syromiatnikov Date: Thu, 31 Jul 2025 12:07:43 +0000 (+0200) Subject: crypto/mem.c: don't use aligned_alloc in CRYPTO_aligned_alloc X-Git-Tag: openssl-3.6.0-alpha1~214 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=648803a17e4c1;p=thirdparty%2Fopenssl.git crypto/mem.c: don't use aligned_alloc in CRYPTO_aligned_alloc The original C11 specification is pretty weird: it specifies that the size must be a multiple of alignment (rendering it useless for small page-aligned allocations that, for example, might be useful for RDMA) and until DR460[1] it was UB in failing to do so (as it is with OPENSSL_ligned_alloc() calls in alloc_new_neighborhood_list() on 32-bit systems, for example). Moreover, it has arguably not been used much before, as all supported POSIX systems have at least POSIX 2001 compatibility level nowadays, Windows doesn't implement aligned_alloc() at all (because implementation of free() in MS CRT is unable to handle aligned allocations[2]), and _ISOC11_SOURCE is a glibc-specific feature test macro. [1] https://open-std.org/JTC1/SC22/WG14/www/docs/summary.htm#dr_460 [2] https://learn.microsoft.com/en-us/cpp/standard-library/cstdlib?view=msvc-170#remarks-6 Signed-off-by: Eugene Syromiatnikov Reviewed-by: Saša Nedvědický Reviewed-by: Matt Caswell Reviewed-by: Paul Dale Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/28059) --- diff --git a/crypto/mem.c b/crypto/mem.c index 161d61dae63..3ac84841765 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -246,9 +246,6 @@ void *CRYPTO_aligned_alloc(size_t num, size_t alignment, void **freeptr, return NULL; *freeptr = ret; return ret; -#elif defined(_ISOC11_SOURCE) - ret = *freeptr = aligned_alloc(alignment, num); - return ret; #endif }