1
0
mirror of https://github.com/wolfSSL/wolfssl.git synced 2026-10-24 04:09:07 +03:00

Merge pull request #11705 from kaleb-himes/PQ-FS-2026-Part3-SecurityReview-nofallback-X

i386 & arm32 kernel space support
This commit is contained in:
philljj
2026-10-09 18:37:35 -05:00
committed by GitHub
11 changed files with 41 additions and 6 deletions

View File

@@ -253,6 +253,7 @@ CONFIG_WOLFSSL_XMSS
CONFIG_WOLFTPM
CONFIG_WOLFTPM_EXAMPLE_NAME_ESPRESSIF
CONFIG_X86
CONFIG_X86_32
CONFIG_X86_64
CONV_WITH_DIV
CPA_CY_API_VERSION_NUM_MAJOR

View File

@@ -4794,7 +4794,8 @@ then
AC_MSG_NOTICE([32bit ARMv4 found])
;;
*)
AM_CPPFLAGS="$AM_CPPFLAGS -mfpu=crypto-neon-fp-armv8 -marm"
# A toolchain default such as armv5t lacks strd and rev.
AM_CPPFLAGS="$AM_CPPFLAGS -march=armv8-a -mfpu=crypto-neon-fp-armv8 -marm"
# Include options.h
AM_CCASFLAGS="$AM_CCASFLAGS -DEXTERNAL_OPTS_OPENVPN"
ENABLED_ARMASM_CRYPTO=yes

View File

@@ -186,6 +186,9 @@ ifeq "$(ENABLED_LINUXKM_PIE)" "yes"
NO_PIE_FLAG := 0
endif
endif
else ifeq "$(CONFIG_X86_32)" "y"
NO_PIE_FLAG := 1
$(info Note: disabling -fPIE to avoid R_386_GOTOFF on i386.)
else
NO_PIE_FLAG := 0
endif

View File

@@ -207,7 +207,7 @@ GENERATE_RELOC_TAB := $(AWK) ' \
next; \
} \
/^0/ { \
if ($$3 !~ "^(R_X86_.*|R_AARCH64_.*|R_ARM.*)$$") { \
if ($$3 !~ "^(R_X86_.*|R_386_(32|PC32)|R_AARCH64_.*|R_ARM.*)$$") { \
print "Unexpected relocation type in " cur_seg ":\n" $$0 >"/dev/stderr"; \
++bad_relocs; \
} \

View File

@@ -52,6 +52,8 @@ static const struct reloc_layout_ent {
[WC_R_X86_64_64] = { "R_X86_64_64", ~0UL, 64, .is_signed = 0, .is_relative = 0 },
[WC_R_X86_64_PC32] = { "R_X86_64_PC32", ~0UL, 32, .is_signed = 1, .is_relative = 1 },
[WC_R_X86_64_PLT32] = { "R_X86_64_PLT32", ~0UL, 32, .is_signed = 1, .is_relative = 1 },
[WC_R_386_32] = { "R_386_32", ~0UL, 32, .is_signed = 0, .is_relative = 0 },
[WC_R_386_PC32] = { "R_386_PC32", ~0UL, 32, .is_signed = 1, .is_relative = 1 },
[WC_R_AARCH64_ABS32] = { "R_AARCH64_ABS32", ~0UL, 32, .is_signed = 1, .is_relative = 0, .is_pages = 0, .is_pair_lo = 0, .is_pair_hi = 0 },
[WC_R_AARCH64_ABS64] = { "R_AARCH64_ABS64", ~0UL, 64, .is_signed = 1, .is_relative = 0, .is_pages = 0, .is_pair_lo = 0, .is_pair_hi = 0 },
[WC_R_AARCH64_ADD_ABS_LO12_NC] = { "R_AARCH64_ADD_ABS_LO12_NC", 0b00000000001111111111110000000000, 32, .is_signed = 0, .is_relative = 0, .is_pages = 0, .is_pair_lo = 1, .is_pair_hi = 0 },
@@ -416,6 +418,12 @@ ssize_t wc_reloc_normalize_segment(
break;
case WC_R_386_32:
case WC_R_386_PC32:
/* i386 is REL: its addend lives in the field, not in reloc_tab. */
reloc_buf = 0;
break;
case WC_R_ARM_ABS32:
case WC_R_ARM_CALL:
case WC_R_ARM_JUMP24:

View File

@@ -60,7 +60,9 @@ enum wc_reloc_type {
WC_R_ARM_THM_JUMP11,
WC_R_ARM_THM_JUMP24,
WC_R_ARM_THM_MOVT_ABS,
WC_R_ARM_THM_MOVW_ABS_NC
WC_R_ARM_THM_MOVW_ABS_NC,
WC_R_386_32,
WC_R_386_PC32
};
/* This structure is accessed natively by kernel module glue logic, and also

View File

@@ -1238,6 +1238,11 @@
extern int memcmp(const void *s1, const void *s2, size_t n);
#endif
#ifdef CONFIG_X86_32
/* asm/string_32.h #defines memcmp, which would rename its slot below. */
#undef memcmp
#endif
struct wolfssl_linuxkm_pie_redirect_table {
#ifdef HAVE_FIPS
typeof(wc_linuxkm_normalize_relocations) *wc_linuxkm_normalize_relocations;
@@ -1634,9 +1639,11 @@
#define memcmp WC_PIE_INDIRECT_SYM(memcmp)
#endif
#ifndef __ARCH_MEMCPY_NO_REDIRECT
#undef memcpy
#define memcpy WC_PIE_INDIRECT_SYM(memcpy)
#endif
#ifndef __ARCH_MEMSET_NO_REDIRECT
#undef memset
#define memset WC_PIE_INDIRECT_SYM(memset)
#endif
#ifndef __ARCH_MEMMOVE_NO_REDIRECT

View File

@@ -759,7 +759,11 @@ int wc_linuxkm_GenerateSeed_IntelRD(struct OS_Seed* os, byte* output, word32 sz)
#endif /* WC_LINUXKM_RDSEED_IN_GLUE_LAYER */
#if defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS) && defined(CONFIG_X86)
/* i386 this_cpu_read() declares an extern inside the function. */
PRAGMA_GCC_DIAG_PUSH
PRAGMA_GCC("GCC diagnostic ignored \"-Wnested-externs\"")
#include "linuxkm/x86_vector_register_glue.c"
PRAGMA_GCC_DIAG_POP
#elif defined(WOLFSSL_USE_SAVE_VECTOR_REGISTERS) && \
(defined(CONFIG_ARM64) || defined(CONFIG_ARM))
#include "linuxkm/arm64_vector_register_glue.c"
@@ -2526,7 +2530,7 @@ static ssize_t FIPS_optest_trig_common(enum FIPS_optest_audit_mode audit_mode,
int ret;
int argc;
const char *argv[3];
char code_buf[5];
char code_buf[6];
size_t corrected_count;
int i;
#ifdef WC_LINUXKM_SVR_DYNAMIC_AUDITING
@@ -2545,7 +2549,7 @@ static ssize_t FIPS_optest_trig_common(enum FIPS_optest_audit_mode audit_mode,
corrected_count = count - 1;
else
corrected_count = count;
if ((corrected_count < 1) || (corrected_count > 4))
if ((corrected_count < 1) || (corrected_count > 5))
return -EINVAL;
XMEMCPY(code_buf, buf, corrected_count);
code_buf[corrected_count] = 0;

View File

@@ -164,7 +164,7 @@ WARN_UNUSED_RESULT int wc_linuxkm_allocate_svr_states(void)
wc_linuxkm_svr_states_n_tracked * sizeof(wc_linuxkm_svr_states[0]));
if (! wc_linuxkm_svr_states) {
pr_err("ERROR: allocation of %lu bytes for "
pr_err("ERROR: allocation of %zu bytes for "
"wc_linuxkm_svr_states failed.\n",
nr_cpu_ids * sizeof(wc_linuxkm_svr_states[0]));
return MEMORY_E;

View File

@@ -99,6 +99,11 @@
#define cpuid_xgetbv0() ((word32)_xgetbv(0))
#endif /* _MSC_VER */
/* i386 kernel <asm/ptrace-abi.h> uses these names for ptrace offsets. */
#undef EAX
#undef EBX
#undef ECX
#undef EDX
#define EAX 0
#define EBX 1
#define ECX 2

View File

@@ -1920,6 +1920,10 @@ WOLFSSL_API word32 CheckRunTimeSettings(void);
#define XASM_LINK(f) /* null expansion */
#elif defined(__APPLE__)
#define XASM_LINK(f) asm("_" f)
#elif defined(__GNUC__) && defined(__i386__)
/* The 32-bit asm reads its arguments from the stack, but i386 kernels
* compile C with -mregparm=3 (linux arch/x86/Makefile). */
#define XASM_LINK(f) __asm__(f) __attribute__((regparm(0)))
#elif defined(__GNUC__)
/* use alternate keyword for compatibility with -std=c99 */
#define XASM_LINK(f) __asm__(f)