From 648803a17e4c1511ebc90a78542d0e649b6eb318 Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Thu, 31 Jul 2025 14:07:43 +0200 Subject: [PATCH] crypto/mem.c: don't use aligned_alloc in CRYPTO_aligned_alloc MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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) --- crypto/mem.c | 3 --- 1 file changed, 3 deletions(-) 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 } -- 2.47.3