From a447a991b0db66f817209eb0d9c9337195977d81 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Wed, 23 Jul 2025 14:31:52 -0500 Subject: [PATCH] linuxkm/Kbuild: add KERNEL_EXTRA_CFLAGS_REMOVE; linuxkm/linuxkm_wc_port.h: fix version threshold for HAVE_KVREALLOC (6.12.0, not 6.11.0), and add manual overrides. --- .wolfssl_known_macro_extras | 4 ++++ linuxkm/Kbuild | 4 ++++ linuxkm/linuxkm_wc_port.h | 32 +++++++++++++++++++++----------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.wolfssl_known_macro_extras b/.wolfssl_known_macro_extras index 236de6627..3e039f6fc 100644 --- a/.wolfssl_known_macro_extras +++ b/.wolfssl_known_macro_extras @@ -193,6 +193,10 @@ DILITHIUM_MUL_QINV_SLOW DILITHIUM_MUL_Q_SLOW DILITHIUM_MUL_SLOW DILITHIUM_USE_HINT_CT +DONT_HAVE_KVMALLOC +DONT_HAVE_KVREALLOC +DONT_USE_KVMALLOC +DONT_USE_KVREALLOC DTLS_RECEIVEFROM_NO_TIMEOUT_ON_INVALID_PEER ECCSI_ORDER_MORE_BITS_THAN_PRIME ECC_DUMP_OID diff --git a/linuxkm/Kbuild b/linuxkm/Kbuild index 5e15ce1d4..ab0399131 100644 --- a/linuxkm/Kbuild +++ b/linuxkm/Kbuild @@ -129,6 +129,10 @@ ifeq "$(ENABLED_LINUXKM_PIE)" "yes" $(obj)/linuxkm/module_hooks.o: ccflags-y += $(PIE_SUPPORT_FLAGS) endif +ifdef KERNEL_EXTRA_CFLAGS_REMOVE + ccflags-remove-y += KERNEL_EXTRA_CFLAGS_REMOVE +endif + $(obj)/wolfcrypt/benchmark/benchmark.o: ccflags-y = $(WOLFSSL_CFLAGS) $(CFLAGS_FPU_ENABLE) $(CFLAGS_SIMD_ENABLE) $(PIE_SUPPORT_FLAGS) -DNO_MAIN_FUNCTION -DWOLFSSL_NO_OPTIONS_H $(obj)/wolfcrypt/benchmark/benchmark.o: asflags-y = $(WOLFSSL_ASFLAGS) $(ASFLAGS_FPU_ENABLE_SIMD_DISABLE) diff --git a/linuxkm/linuxkm_wc_port.h b/linuxkm/linuxkm_wc_port.h index 1d15bbedd..0caedae70 100644 --- a/linuxkm/linuxkm_wc_port.h +++ b/linuxkm/linuxkm_wc_port.h @@ -81,28 +81,38 @@ * kvrealloc() added in de2860f463, merged for 5.15, backported to 5.10.137. * moved to ultimate home (slab.h) in 8587ca6f34, merged for 5.16. * - * however, until 6.11, it took an extra argument, oldsize, that makes it - * incompatible with traditional libc usage patterns, so we don't try to use it. + * however, until 6.12 (commit 590b9d576c), it took an extra argument, + * oldsize, that makes it incompatible with traditional libc usage patterns, + * so we don't try to use it. */ - #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) + #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) && \ + !defined(DONT_HAVE_KVMALLOC) && !defined(HAVE_KVMALLOC) #define HAVE_KVMALLOC #endif - #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) + #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) && \ + !defined(DONT_HAVE_KVREALLOC) && !defined(HAVE_KVREALLOC) #define HAVE_KVREALLOC #endif #ifdef WOLFCRYPT_ONLY - #ifdef HAVE_KVMALLOC + #if defined(HAVE_KVMALLOC) && \ + !defined(DONT_USE_KVMALLOC) && !defined(USE_KVMALLOC) #define USE_KVMALLOC #endif - #ifdef HAVE_KVREALLOC + #ifdef HAVE_KVREALLOC && \ + !defined(DONT_USE_KVREALLOC) && !defined(USE_KVREALLOC) #define USE_KVREALLOC #endif #else /* functioning realloc() is needed for the TLS stack. */ - #if defined(HAVE_KVMALLOC) && defined(HAVE_KVREALLOC) - #define USE_KVMALLOC - #define USE_KVREALLOC + #if defined(HAVE_KVMALLOC) && defined(HAVE_KVREALLOC) && \ + !defined(DONT_USE_KVMALLOC) && !defined(DONT_USE_KVREALLOC) + #ifndef USE_KVMALLOC + #define USE_KVMALLOC + #endif + #ifndef USE_KVREALLOC + #define USE_KVREALLOC + #endif #endif #endif @@ -680,7 +690,7 @@ const unsigned char *_ctype; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) typeof(kmalloc_noprof) *kmalloc_noprof; typeof(krealloc_noprof) *krealloc_noprof; typeof(kzalloc_noprof) *kzalloc_noprof; @@ -953,7 +963,7 @@ #define _ctype WC_LKM_INDIRECT_SYM(_ctype) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0) /* see include/linux/alloc_tag.h and include/linux/slab.h */ #define kmalloc_noprof WC_LKM_INDIRECT_SYM(kmalloc_noprof) #define krealloc_noprof WC_LKM_INDIRECT_SYM(krealloc_noprof)