|
178 | 178 | #endif |
179 | 179 | #endif |
180 | 180 |
|
181 | | - #if defined(HAVE_HASHDRBG) && defined(HAVE_FIPS) && FIPS_VERSION3_LT(6, 0, 0) && \ |
| 181 | + #if defined(HAVE_HASHDRBG) && defined(HAVE_FIPS) && \ |
| 182 | + defined(HAVE_ENTROPY_MEMUSE) && \ |
| 183 | + !defined(WC_LINUXKM_WOLFENTROPY_IN_GLUE_LAYER) |
| 184 | + #define WC_LINUXKM_WOLFENTROPY_IN_GLUE_LAYER |
| 185 | + #elif defined(HAVE_HASHDRBG) && defined(HAVE_FIPS) && \ |
182 | 186 | (defined(HAVE_INTEL_RDSEED) || defined(HAVE_AMD_RDSEED)) && \ |
| 187 | + !defined(HAVE_ENTROPY_MEMUSE) && \ |
183 | 188 | !defined(WC_LINUXKM_RDSEED_IN_GLUE_LAYER) |
184 | 189 | #define WC_LINUXKM_RDSEED_IN_GLUE_LAYER |
185 | 190 | #endif |
186 | | - #ifdef WC_LINUXKM_RDSEED_IN_GLUE_LAYER |
| 191 | + #if defined(WC_LINUXKM_WOLFENTROPY_IN_GLUE_LAYER) |
| 192 | + struct OS_Seed; |
| 193 | + extern int wc_linuxkm_GenerateSeed_wolfEntropy(struct OS_Seed* os, unsigned char* output, unsigned int sz); |
| 194 | + #define WC_GENERATE_SEED_DEFAULT wc_linuxkm_GenerateSeed_wolfEntropy |
| 195 | + #elif defined(WC_LINUXKM_RDSEED_IN_GLUE_LAYER) |
187 | 196 | struct OS_Seed; |
188 | 197 | extern int wc_linuxkm_GenerateSeed_IntelRD(struct OS_Seed* os, unsigned char* output, unsigned int sz); |
189 | 198 | #define WC_GENERATE_SEED_DEFAULT wc_linuxkm_GenerateSeed_IntelRD |
|
208 | 217 | #endif |
209 | 218 | #endif |
210 | 219 |
|
211 | | - #if defined(CONFIG_MIPS) && defined(WC_PIE_RELOC_TABLES) |
| 220 | + #if defined(CONFIG_MIPS) && defined(WC_SYM_RELOC_TABLES) |
212 | 221 | /* __ZBOOT__ disables some unhelpful macros around the mem*() funcs in |
213 | 222 | * legacy arch/mips/include/asm/string.h |
214 | 223 | */ |
|
255 | 264 |
|
256 | 265 | #if defined(CONFIG_FORTIFY_SOURCE) && \ |
257 | 266 | !defined(WC_FORCE_LINUXKM_FORTIFY_SOURCE) && \ |
258 | | - (defined(WC_PIE_RELOC_TABLES) || \ |
| 267 | + (defined(WC_SYM_RELOC_TABLES) || \ |
259 | 268 | (LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0))) |
260 | 269 | /* fortify-source causes all sorts of awkward problems for the PIE |
261 | 270 | * build, up to and including stubborn external references and multiple |
|
272 | 281 | #error WC_FORCE_LINUXKM_FORTIFY_SOURCE without CONFIG_FORTIFY_SOURCE. |
273 | 282 | #endif |
274 | 283 |
|
275 | | - #if defined(__PIE__) && defined(CONFIG_ARM64) |
| 284 | + #if defined(WC_CONTAINERIZE_THIS) && defined(CONFIG_ARM64) |
276 | 285 | #define alt_cb_patch_nops my__alt_cb_patch_nops |
277 | 286 | #define queued_spin_lock_slowpath my__queued_spin_lock_slowpath |
278 | 287 | #endif |
|
281 | 290 | #include <linux/ctype.h> |
282 | 291 |
|
283 | 292 | #if defined(CONFIG_FORTIFY_SOURCE) || defined(DEBUG_LINUXKM_FORTIFY_OVERLAY) |
284 | | - #ifdef __PIE__ |
| 293 | + #ifdef WC_CONTAINERIZE_THIS |
285 | 294 | /* the inline definitions in fortify-string.h use non-inline |
286 | 295 | * fortify_panic(). |
287 | 296 | */ |
|
412 | 421 |
|
413 | 422 | #endif /* !CONFIG_FORTIFY_SOURCE */ |
414 | 423 |
|
415 | | - #ifndef __PIE__ |
| 424 | + #ifndef WC_CONTAINERIZE_THIS |
416 | 425 | #include <linux/init.h> |
417 | 426 | #include <linux/module.h> |
418 | 427 | #include <linux/delay.h> |
|
426 | 435 | * mm.h. however, mm.h brings in static, but not inline, pmd_to_page(), |
427 | 436 | * with direct references to global vmem variables. |
428 | 437 | */ |
429 | | - #ifdef __PIE__ |
| 438 | + #ifdef WC_CONTAINERIZE_THIS |
430 | 439 | #include <linux/mm_types.h> |
431 | 440 | #if USE_SPLIT_PMD_PTLOCKS |
432 | 441 | static __always_inline struct page *pmd_to_page(pmd_t *pmd); |
|
435 | 444 | #include <linux/mm.h> |
436 | 445 | #endif |
437 | 446 |
|
438 | | -#ifndef __PIE__ |
| 447 | +#ifndef WC_CONTAINERIZE_THIS |
439 | 448 | #include <linux/kthread.h> |
440 | 449 | #include <linux/net.h> |
441 | 450 | #endif |
|
450 | 459 | #endif |
451 | 460 | #include <linux/random.h> |
452 | 461 |
|
453 | | - #if !defined(__PIE__) && defined(CONFIG_HAVE_KPROBES) |
| 462 | + #if !defined(WC_CONTAINERIZE_THIS) && defined(CONFIG_HAVE_KPROBES) |
454 | 463 | #include <linux/kprobes.h> |
455 | 464 | #endif |
456 | 465 |
|
|
483 | 492 | #define LINUXKM_LKCAPI_REGISTER_HASH_DRBG_DEFAULT |
484 | 493 | #endif |
485 | 494 |
|
486 | | - #ifndef __PIE__ |
| 495 | + #ifndef WC_CONTAINERIZE_THIS |
487 | 496 | #include <linux/crypto.h> |
488 | 497 | #include <linux/scatterlist.h> |
489 | 498 | #include <crypto/scatterwalk.h> |
|
513 | 522 | } |
514 | 523 | #endif |
515 | 524 | #define WC_LKM_REFCOUNT_TO_INT(refcount) wc_lkm_refcount_to_int(&(refcount)) |
516 | | - #endif /* !__PIE__ */ |
| 525 | + #endif /* !WC_CONTAINERIZE_THIS */ |
517 | 526 | #endif /* LINUXKM_LKCAPI_REGISTER */ |
518 | 527 |
|
519 | 528 | /* benchmarks.c uses floating point math, so needs a working |
|
730 | 739 |
|
731 | 740 | #endif /* !WOLFCRYPT_ONLY && !NO_CERTS */ |
732 | 741 |
|
733 | | - #if defined(__PIE__) && !defined(WC_PIE_RELOC_TABLES) |
734 | | - #error "compiling -fPIE requires PIE relocation tables." |
| 742 | + #if defined(WC_CONTAINERIZE_THIS) && !defined(WC_SYM_RELOC_TABLES) |
| 743 | + #error "compiling -DWC_CONTAINERIZE_THIS requires relocation tables." |
735 | 744 | #endif |
736 | 745 |
|
737 | | - #ifdef WC_PIE_RELOC_TABLES |
| 746 | + #ifdef WC_SYM_RELOC_TABLES |
738 | 747 |
|
739 | 748 | #ifndef WOLFSSL_TEXT_SEGMENT_CANONICALIZER |
740 | 749 | #define WOLFSSL_TEXT_SEGMENT_CANONICALIZER(text_in, text_in_len, text_out, cur_index_p) \ |
|
759 | 768 | __wc_rwdata_end[], |
760 | 769 | __wc_bss_start[], |
761 | 770 | __wc_bss_end[]; |
| 771 | + |
762 | 772 | extern const unsigned int wc_linuxkm_pie_reloc_tab[]; |
763 | 773 | extern const unsigned long wc_linuxkm_pie_reloc_tab_length; |
764 | 774 | extern ssize_t wc_linuxkm_normalize_relocations( |
|
1013 | 1023 | #endif |
1014 | 1024 |
|
1015 | 1025 | #ifdef CONFIG_ARM64 |
1016 | | - #ifdef __PIE__ |
| 1026 | + #ifdef WC_CONTAINERIZE_THIS |
1017 | 1027 | /* alt_cb_patch_nops and queued_spin_lock_slowpath are defined early |
1018 | 1028 | * to allow shimming in system headers, but now we need the native |
1019 | 1029 | * ones. |
|
1088 | 1098 | #error no WC_PIE_INDIRECT_SYM method defined. |
1089 | 1099 | #endif |
1090 | 1100 |
|
1091 | | - #ifdef __PIE__ |
| 1101 | + #ifdef WC_CONTAINERIZE_THIS |
1092 | 1102 |
|
1093 | 1103 | #define wc_linuxkm_normalize_relocations \ |
1094 | 1104 | WC_PIE_INDIRECT_SYM(wc_linuxkm_normalize_relocations) |
|
1237 | 1247 | #endif |
1238 | 1248 |
|
1239 | 1249 | /* per linux/ctype.h, tolower() and toupper() are macros bound to static inlines |
1240 | | - * that use macros that bring in the _ctype global. for __PIE__, this needs to |
1241 | | - * be masked out. |
| 1250 | + * that use macros that bring in the _ctype global. for WC_CONTAINERIZE_THIS, |
| 1251 | + * this needs to be masked out. |
1242 | 1252 | */ |
1243 | 1253 | #undef tolower |
1244 | 1254 | #undef toupper |
|
1296 | 1306 | #define wc_linuxkm_check_for_intr_signals WC_PIE_INDIRECT_SYM(wc_linuxkm_check_for_intr_signals) |
1297 | 1307 | #define wc_linuxkm_relax_long_loop WC_PIE_INDIRECT_SYM(wc_linuxkm_relax_long_loop) |
1298 | 1308 |
|
1299 | | - #endif /* __PIE__ */ |
| 1309 | + #endif /* WC_CONTAINERIZE_THIS */ |
1300 | 1310 |
|
1301 | | - #endif /* WC_PIE_RELOC_TABLES */ |
| 1311 | + #endif /* WC_SYM_RELOC_TABLES */ |
1302 | 1312 |
|
1303 | 1313 | /* remove this multifariously conflicting macro, picked up from |
1304 | 1314 | * Linux arch/<arch>/include/asm/current.h. |
|
1456 | 1466 | return 0; |
1457 | 1467 | } |
1458 | 1468 |
|
1459 | | - #ifdef __PIE__ |
1460 | | - /* wc_lkm_LockMutex() can't be used inline in __PIE__ objects, due to |
| 1469 | + #ifdef WC_CONTAINERIZE_THIS |
| 1470 | + /* wc_lkm_LockMutex() can't be used inline in WC_CONTAINERIZE_THIS objects, due to |
1461 | 1471 | * direct access to pv_ops. |
1462 | 1472 | */ |
1463 | 1473 | static __must_check __always_inline int wc_LockMutex(wolfSSL_Mutex *m) |
1464 | 1474 | { |
1465 | 1475 | return WC_PIE_INDIRECT_SYM(wc_lkm_LockMutex)(m); |
1466 | 1476 | } |
1467 | 1477 |
|
1468 | | - #else /* !__PIE__ */ |
| 1478 | + #else /* !WC_CONTAINERIZE_THIS */ |
1469 | 1479 |
|
1470 | 1480 | static __must_check __always_inline int wc_LockMutex(wolfSSL_Mutex *m) |
1471 | 1481 | { |
1472 | 1482 | return wc_lkm_LockMutex(m); |
1473 | 1483 | } |
1474 | 1484 |
|
1475 | | - #endif /* !__PIE__ */ |
| 1485 | + #endif /* !WC_CONTAINERIZE_THIS */ |
1476 | 1486 |
|
1477 | 1487 | static __always_inline int wc_UnLockMutex(wolfSSL_Mutex* m) |
1478 | 1488 | { |
|
0 commit comments