Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c38f11b
fixes for false positives on linuxkm CONFIG_FORTIFY_SOURCE builds on …
douzzer Jun 16, 2026
d4eaeb1
linuxkm/lkcapi_sha_glue.c: refactor error code handling in wc_linuxkm…
douzzer Jun 16, 2026
479a685
wolfcrypt/src/aes.c: fix performance regressions on GMAC and AES-CFB …
douzzer Jun 27, 2026
300f58d
src/include.am: remove wolfcrypt/src/aes_x86_64_asm.S from AESNI sour…
douzzer Jun 27, 2026
6d21d60
in all FIPS-relevant C sources, add a "#define _WC_BUILDING_foo" firs…
douzzer Jun 27, 2026
5ae99fb
wolfcrypt/src/aes.c, wolfcrypt/src/port/, wolfssl/wolfcrypt/aes.h, wo…
douzzer Jun 27, 2026
4d46e1e
wolfcrypt/test/test.c:
douzzer Jun 27, 2026
8b5b6af
linuxkm/x86_vector_register_glue.c, linuxkm/linuxkm_wc_port.h, wolfss…
douzzer Jun 27, 2026
7a40256
wolfcrypt/src/sha3.c: refactor WC_C_DYNAMIC_FALLBACK using SAVE_VECTO…
douzzer Jun 27, 2026
7545798
clean up setup code for kernel modules:
douzzer Jun 27, 2026
948ba6e
* add hard compile-time assert in settings.h for FIPS v7+ asserting t…
douzzer Jun 27, 2026
538262a
linuxkm/linuxkm_wc_port.h, linuxkm/module_hooks.c: add linuxkm-pie su…
douzzer Jun 27, 2026
bf088df
linuxkm/linuxkm_wc_port.h, linuxkm/module_hooks.c: on kernel >= 7.2, …
douzzer Jun 27, 2026
649197d
replace several nonconformant uses of __FUNCTION__ with __func__ (lin…
douzzer Jun 27, 2026
cba6909
wolfcrypt/src/port/riscv/riscv-64-aes.c: in GHASH(), remove runtime n…
douzzer Jun 27, 2026
ac5f2b9
wolfcrypt/src/wc_slhdsa.c:
douzzer Jun 27, 2026
3811ec0
linuxkm-related loose ends:
douzzer Jun 27, 2026
262b0ed
tweaks for linuxkm targeting clang-built kernels:
douzzer Jun 27, 2026
47cf8d0
wolfcrypt/src/pkcs7.c: in wc_PKCS7_DecodeAuthEnvelopedData(), accommo…
douzzer Jun 27, 2026
d69d49c
wolfcrypt/src/aes.c: don't use explicit inline attribute on wc_local_…
douzzer Jun 27, 2026
568c660
wolfcrypt/src/pkcs7.c: in wc_PKCS7_DecodeAuthEnvelopedData(), accommo…
douzzer Jun 28, 2026
8452f2b
wolfssl/wolfcrypt/wc_port.h: keep #define INLINE WC_INLINE even for l…
douzzer Jun 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .wolfssl_known_macro_extras
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ USE_WOLF_STRNSTR
USS_API
WC_AESXTS_STREAM_NO_REQUEST_ACCOUNTING
WC_AES_BS_WORD_SIZE
WC_AES_GCM_ALLOW_NONSTANDARD_TAG_LENGTH
WC_AES_GCM_DEC_AUTH_EARLY
WC_ALLOW_ECC_ZERO_HASH
WC_ASN_HASH_SHA256
Expand Down Expand Up @@ -669,6 +670,7 @@ WC_HASH_CUSTOM_MAX_DIGEST_SIZE
WC_HASH_CUSTOM_MIN_DIGEST_SIZE
WC_INIT_ERROR_WHEN_CONTENDED
WC_LINUXKM_NO_USE_HEAP_WRAPPERS
WC_MLDSA_NO_ASM
WC_MLKEM_KERNEL_ASM
WC_NO_ASYNC_SLEEP
WC_NO_RNG_SIMPLE
Expand Down
98 changes: 51 additions & 47 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,36 @@ AC_ARG_ENABLE([linuxkm],
[ENABLED_LINUXKM=no]
)

AC_ARG_ENABLE([linuxkm-defaults],
[AS_HELP_STRING([--enable-linuxkm-defaults],[Enable feature defaults for Linux Kernel Module (default: disabled)])],
[KERNEL_MODE_DEFAULTS=$enableval],
[KERNEL_MODE_DEFAULTS=$ENABLED_LINUXKM]
)

# FreeBSD Kernel Module
AC_ARG_ENABLE([freebsdkm],
[AS_HELP_STRING([--enable-freebsdkm],[Enable FreeBSD Kernel Module (default: disabled)])],
[ENABLED_BSDKM=$enableval],
[ENABLED_BSDKM=no]
)

if test "$ENABLED_LINUXKM" != "no" || test "$ENABLED_BSDKM" != "no"
then
KERNEL_MODE_DEFAULTS=yes
else
KERNEL_MODE_DEFAULTS=no
fi

AC_ARG_ENABLE([kernel-settings],
[AS_HELP_STRING([--enable-kernel-settings],[Enable default settings appropriate for kernel modules (default: disabled)])],
[KERNEL_MODE_DEFAULTS=$enableval]
)

# backward-compat alias for --enable-kernel-settings
AC_ARG_ENABLE([linuxkm-defaults],
[AS_HELP_STRING([--enable-linuxkm-defaults],[Enable default settings appropriate for kernel modules (default: disabled)])],
[KERNEL_MODE_DEFAULTS=$enableval]
)

if test "$KERNEL_MODE_DEFAULTS" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_KERNEL_MODE_DEFAULTS"
fi

AC_ARG_ENABLE([freebsdkm-crypto-register],
[AS_HELP_STRING([--enable-freebsdkm-crypto-register],[Register wolfCrypt implementations with the FreeBSD kernel opencrypto framework. (default: disabled)])],
[ENABLED_BSDKM_REGISTER=$enableval],
Expand Down Expand Up @@ -446,7 +463,7 @@ AC_SUBST([ENABLED_ASM])

# Default math is SP Math all and not fast math
# FIPS v1 and v2 must use fast math
DEF_SP_MATH="yes"
DEF_SP_MATH_ALL="yes"
DEF_FAST_MATH="no"

# FIPS 140
Expand Down Expand Up @@ -557,23 +574,23 @@ AS_CASE([$ENABLED_FIPS],
FIPS_VERSION="v1"
HAVE_FIPS_VERSION_MAJOR=1
ENABLED_FIPS="yes"
DEF_SP_MATH="no"
DEF_SP_MATH_ALL="no"
DEF_FAST_MATH="yes"
],
[v2|cert3389],[
FIPS_VERSION="v2"
HAVE_FIPS_VERSION_MAJOR=2
HAVE_FIPS_VERSION_MINOR=0
ENABLED_FIPS="yes"
DEF_SP_MATH="no"
DEF_SP_MATH_ALL="no"
DEF_FAST_MATH="yes"
],
[rand],[
FIPS_VERSION="rand"
HAVE_FIPS_VERSION_MAJOR=2
HAVE_FIPS_VERSION_MINOR=1
ENABLED_FIPS="yes"
DEF_SP_MATH="no"
DEF_SP_MATH_ALL="no"
DEF_FAST_MATH="no"
],
[v5|cert4718],[
Expand All @@ -582,7 +599,7 @@ AS_CASE([$ENABLED_FIPS],
HAVE_FIPS_VERSION_MINOR=2
HAVE_FIPS_VERSION_PATCH=1
ENABLED_FIPS="yes"
DEF_SP_MATH="no"
DEF_SP_MATH_ALL="no"
DEF_FAST_MATH="yes"
],
[v5.2.3],[
Expand All @@ -591,7 +608,7 @@ AS_CASE([$ENABLED_FIPS],
HAVE_FIPS_VERSION_MINOR=2
HAVE_FIPS_VERSION_PATCH=3
ENABLED_FIPS="yes"
DEF_SP_MATH="yes"
DEF_SP_MATH_ALL="yes"
DEF_FAST_MATH="no"
],
[v5.2.4],[
Expand All @@ -600,7 +617,7 @@ AS_CASE([$ENABLED_FIPS],
HAVE_FIPS_VERSION_MINOR=2
HAVE_FIPS_VERSION_PATCH=4
ENABLED_FIPS="yes"
DEF_SP_MATH="yes"
DEF_SP_MATH_ALL="yes"
DEF_FAST_MATH="no"
],
[v5-RC12],[
Expand All @@ -609,15 +626,15 @@ AS_CASE([$ENABLED_FIPS],
HAVE_FIPS_VERSION_MINOR=2
HAVE_FIPS_VERSION_PATCH=0
ENABLED_FIPS="yes"
DEF_SP_MATH="no"
DEF_SP_MATH_ALL="no"
DEF_FAST_MATH="yes"
],
[v5-ready],[
FIPS_VERSION="v5-ready"
HAVE_FIPS_VERSION_MAJOR=5
HAVE_FIPS_VERSION_MINOR=3
ENABLED_FIPS="yes"
DEF_SP_MATH="no"
DEF_SP_MATH_ALL="no"
DEF_FAST_MATH="yes"
],
[v5-dev],[
Expand All @@ -626,15 +643,15 @@ AS_CASE([$ENABLED_FIPS],
HAVE_FIPS_VERSION_MINOR=2
HAVE_FIPS_VERSION_PATCH=1
ENABLED_FIPS="yes"
# for dev, DEF_SP_MATH and DEF_FAST_MATH follow non-FIPS defaults (currently sp-math-all)
# for dev, DEF_SP_MATH_ALL and DEF_FAST_MATH follow non-FIPS defaults (currently sp-math-all)
],
[v5-kcapi],[
FIPS_VERSION="v5-dev"
HAVE_FIPS_VERSION_MAJOR=5
HAVE_FIPS_VERSION_MINOR=3
HAVE_FIPS_VERSION_PATCH=0
ENABLED_FIPS="yes"
# for dev, DEF_SP_MATH and DEF_FAST_MATH follow non-FIPS defaults (currently sp-math-all)
# for dev, DEF_SP_MATH_ALL and DEF_FAST_MATH follow non-FIPS defaults (currently sp-math-all)
],
[v6|v6-dev],[
FIPS_VERSION="v6"
Expand All @@ -643,7 +660,7 @@ AS_CASE([$ENABLED_FIPS],
HAVE_FIPS_VERSION_MINOR=0
HAVE_FIPS_VERSION_PATCH=0
ENABLED_FIPS="yes"
DEF_SP_MATH="yes"
DEF_SP_MATH_ALL="yes"
DEF_FAST_MATH="no"
],
[v7],[
Expand All @@ -653,7 +670,7 @@ AS_CASE([$ENABLED_FIPS],
HAVE_FIPS_VERSION_MINOR=0
HAVE_FIPS_VERSION_PATCH=0
ENABLED_FIPS="yes"
DEF_SP_MATH="yes"
DEF_SP_MATH_ALL="yes"
DEF_FAST_MATH="no"
],
# Should always remain one ahead of the latest so as not to be confused with
Expand All @@ -665,7 +682,7 @@ AS_CASE([$ENABLED_FIPS],
HAVE_FIPS_VERSION_MINOR=0
HAVE_FIPS_VERSION_PATCH=0
ENABLED_FIPS="yes"
DEF_SP_MATH="yes"
DEF_SP_MATH_ALL="yes"
DEF_FAST_MATH="no"
],
[dev|v7-dev],[
Expand All @@ -674,7 +691,7 @@ AS_CASE([$ENABLED_FIPS],
HAVE_FIPS_VERSION_MINOR=0
HAVE_FIPS_VERSION_PATCH=0
ENABLED_FIPS="yes"
# for dev, DEF_SP_MATH and DEF_FAST_MATH follow non-FIPS defaults (currently sp-math-all)
# for dev, DEF_SP_MATH_ALL and DEF_FAST_MATH follow non-FIPS defaults (currently sp-math-all)
],
[lean-aesgcm|lean-aesgcm-ready|lean-aesgcm-dev],[
FIPS_VERSION="$ENABLED_FIPS"
Expand Down Expand Up @@ -809,16 +826,10 @@ then
fi
AC_SUBST([ENABLED_KERNEL_BENCHMARKS])

if test "$ENABLED_LINUXKM" = "yes" && test "$KERNEL_MODE_DEFAULTS" = "yes"
# Kernel mode only supports sp-math-all with smallstack.
if test "$KERNEL_MODE_DEFAULTS" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DH_CONST -DWOLFSSL_SP_MOD_WORD_RP -DWOLFSSL_SP_DIV_64 -DWOLFSSL_SP_DIV_WORD_HALF -DWOLFSSL_SMALL_STACK_STATIC -DWC_SHA3_NO_ASM"
if test "$ENABLED_LINUXKM_PIE" = "yes"; then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NO_OCSP_ISSUER_CHECK"
fi
if test "$ENABLED_FIPS" = "no"; then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_OLD_PRIME_CHECK"
fi
DEF_SP_MATH="yes"
DEF_SP_MATH_ALL="yes"
DEF_FAST_MATH="no"
fi

Expand Down Expand Up @@ -848,11 +859,11 @@ then
# Currently DWARF 5 is the default debug format, but it results in
# "Unsupported DW_TAG_atomic_type(0x47): type: 0x1eefc" in some
# kernel module builds.
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LINUXKM -DWC_SIPHASH_NO_ASM -gdwarf-4"
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_LINUXKM -gdwarf-4"
AS_IF([test "$ax_enable_debug" = "yes"],
[AM_CFLAGS="$AM_CFLAGS -g3"],
[AM_CFLAGS="$AM_CFLAGS -g1"])
AM_CCASFLAGS="$AM_CFLAGS -DWOLFSSL_LINUXKM -DWC_SIPHASH_NO_ASM -gdwarf-4"
AM_CCASFLAGS="$AM_CFLAGS -DWOLFSSL_LINUXKM -gdwarf-4"
AS_IF([test "$ax_enable_debug" = "yes"],
[AM_CCASFLAGS="$AM_CFLAGS -g3"],
[AM_CCASFLAGS="$AM_CFLAGS -g1"])
Expand All @@ -879,8 +890,6 @@ then
if test "${KERNEL_ARCH}" = ""; then
AC_MSG_ERROR([Linux kernel target architecture for build tree ${KERNEL_ROOT} could not be determined. Is target kernel configured?])
fi

AM_CFLAGS="$AM_CFLAGS -DNO_DEV_RANDOM -DNO_WRITEV -DNO_STDIO_FILESYSTEM -DWOLFSSL_NO_SOCK -DWOLFSSL_USER_IO"
fi

#
Expand All @@ -894,7 +903,6 @@ if test "x$ENABLED_BSDKM" = "xyes"
then
# note: bsdkm is wolfcrypt only for now.
HAVE_KERNEL_MODE=yes
KERNEL_MODE_DEFAULTS=yes
ENABLED_NO_LIBRARY=yes
ENABLED_BENCHMARK=no

Expand Down Expand Up @@ -938,9 +946,9 @@ then
DEF_FAST_MATH=no
fi

if test "$DEF_SP_MATH" = "yes" && (test "$enable_fastmath" = "yes" || test "$enable_fasthugemath" = "yes" || test "$enable_heapmath" = "yes")
if test "$DEF_SP_MATH_ALL" = "yes" && (test "$enable_fastmath" = "yes" || test "$enable_fasthugemath" = "yes" || test "$enable_heapmath" = "yes")
then
DEF_SP_MATH=no
DEF_SP_MATH_ALL=no
fi

# Single Precision maths implementation
Expand All @@ -953,7 +961,7 @@ AC_ARG_ENABLE([sp],
AC_ARG_ENABLE([sp-math-all],
[AS_HELP_STRING([--enable-sp-math-all],[Enable Single Precision math implementation for full algorithm suite (default: enabled)])],
[ ENABLED_SP_MATH_ALL=$enableval ],
[ ENABLED_SP_MATH_ALL=$DEF_SP_MATH ],
[ ENABLED_SP_MATH_ALL=$DEF_SP_MATH_ALL ],
)

# Single Precision maths (acceleration for common key sizes and curves)
Expand Down Expand Up @@ -985,7 +993,7 @@ then
fi
fi

# enable SP math assembly support automatically for x86_64 and aarch64 (except Linux kernel module)
# enable SP math assembly support automatically for x86_64 and aarch64 (except kernel modules)
SP_ASM_DEFAULT=no
if test "$ENABLED_SP_MATH" = "yes" && test "$KERNEL_MODE_DEFAULTS" = "no"
then
Expand Down Expand Up @@ -1272,7 +1280,7 @@ then

if test "$ENABLED_SP_MATH" != "yes"
then
# linuxkm is incompatible with opensslextra and its dependents.
# kernel modules are currently incompatible with opensslextra and its dependents.
if test "$KERNEL_MODE_DEFAULTS" != "yes"
then
test "$enable_opensslextra" = "" && enable_opensslextra=yes
Expand Down Expand Up @@ -1318,7 +1326,7 @@ if test "$ENABLED_ALL_OSP" = "yes"
then
if test "$KERNEL_MODE_DEFAULTS" = "yes"
then
AC_MSG_ERROR([--enable-all-osp is incompatible with --enable-linuxkm-defaults])
AC_MSG_ERROR([--enable-all-osp is incompatible with kernel mode defaults])
fi

test "$enable_tailscale" = "" && enable_tailscale=yes
Expand Down Expand Up @@ -1593,12 +1601,8 @@ then
# AFALG lacks AES-EAX
test "$enable_aeseax" = "" && test "$enable_afalg" != "yes" && enable_aeseax=yes
test "$enable_sakke" = "" && test "$enable_ecc" != "no" && enable_sakke=yes

if test "$KERNEL_MODE_DEFAULTS" != "yes"
then
test "$enable_cryptocb" = "" && enable_cryptocb=yes
test "$enable_pkcallbacks" = "" && enable_pkcallbacks=yes
fi
test "$enable_cryptocb" = "" && enable_cryptocb=yes
test "$enable_pkcallbacks" = "" && enable_pkcallbacks=yes
fi

if test "$ENABLED_FIPS" = "no" || test "$HAVE_FIPS_VERSION" -ge 6
Expand Down
14 changes: 13 additions & 1 deletion linuxkm/Kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,21 @@ endif

HOST_EXTRACFLAGS += $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CFLAGS) -static -fno-omit-frame-pointer

ifdef CONFIG_CC_IS_CLANG
HOST_EXTRACFLAGS += -mfunction-return=keep
endif

# "-mindirect-branch=keep -mfunction-return=keep" to avoid "undefined reference
# to `__x86_return_thunk'" on CONFIG_RETHUNK kernels (5.19.0-rc7)
ifdef CONFIG_CC_IS_GCC
ifeq "$(KERNEL_ARCH_X86)" "yes"
HOST_EXTRACFLAGS += -mindirect-branch=keep -mfunction-return=keep
endif
endif

ifdef CONFIG_CC_IS_CLANG
WOLFSSL_CFLAGS += -Wno-unused-parameter
endif

# this rule is needed to get build to succeed in 4.x (get_thread_size still doesn't get built)
$(obj)/linuxkm/get_thread_size: $(src)/linuxkm/get_thread_size.c
Expand All @@ -93,7 +103,9 @@ ifndef KERNEL_THREAD_STACK_SIZE
$(WOLFSSL_OBJ_TARGETS): | $(obj)/linuxkm/get_thread_size
KERNEL_THREAD_STACK_SIZE=$(shell test -x $(obj)/linuxkm/get_thread_size && $(obj)/linuxkm/get_thread_size || echo 16384)
endif
MAX_STACK_FRAME_SIZE=$(shell echo $$(( $(KERNEL_THREAD_STACK_SIZE) / 4)))
ifndef MAX_STACK_FRAME_SIZE
MAX_STACK_FRAME_SIZE=$(shell echo $$(( $(KERNEL_THREAD_STACK_SIZE) / 4)))
endif

$(LIBWOLFSSL_NAME)-y := $(WOLFSSL_OBJ_FILES) linuxkm/module_hooks.o linuxkm/module_exports.o

Expand Down
13 changes: 8 additions & 5 deletions linuxkm/linuxkm_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static inline long find_reloc_tab_offset(
unsigned long hop;

if (seg_in_offset >= (size_t)reloc_tab[reloc_tab_len - 1].offset) {
RELOC_DEBUG_PRINTF("ERROR: %s failed.\n", __FUNCTION__);
RELOC_DEBUG_PRINTF("ERROR: %s failed.\n", __func__);
return BAD_FUNC_ARG;
}

Expand Down Expand Up @@ -113,7 +113,7 @@ static inline long find_reloc_tab_offset(

#ifdef DEBUG_LINUXKM_PIE_SUPPORT
if (ret < 0)
RELOC_DEBUG_PRINTF("ERROR: %s returning %ld.\n", __FUNCTION__, ret);
RELOC_DEBUG_PRINTF("ERROR: %s returning %ld.\n", __func__, ret);
#endif
return ret;
}
Expand All @@ -122,8 +122,11 @@ static inline long find_reloc_tab_offset(
* build and target host, but if we were, these macros would byte swap.
* Currently, we detect and fail early on endianness conflicts.
*/
#define wc_get_unaligned(v) ({ typeof(*(v)) _v_aligned; XMEMCPY((void *)&_v_aligned, (void *)(v), sizeof _v_aligned); _v_aligned; })
#define wc_put_unaligned(v, v_out) do { typeof(v) _v = (v); XMEMCPY((void *)(v_out), (void *)&_v, sizeof(typeof(*(v_out)))); } while (0)
#define wc_get_unaligned(v) (((const struct __attribute__((packed)) { typeof(*(v)) x; } *)(v))->x)
#define wc_put_unaligned(v, v_out) do { \
struct __attribute__((packed)) { typeof(*(v_out)) x; } *_pptr = (typeof(_pptr))(v_out); \
_pptr->x = (v); \
} while (0)

ssize_t wc_reloc_normalize_segment(
const byte *seg_in,
Expand Down Expand Up @@ -173,7 +176,7 @@ ssize_t wc_reloc_normalize_segment(
else
{
RELOC_DEBUG_PRINTF("ERROR: %s returning BAD_FUNC_ARG with span %llx-%llx versus text %llx-%llx and rodata %llx-%llx.\n",
__FUNCTION__,
__func__,
(unsigned long long)(uintptr_t)seg_in,
(unsigned long long)(uintptr_t)(seg_in + *seg_in_out_len),
(unsigned long long)seg_map->text_start,
Expand Down
Loading
Loading