20260904-linuxkm-misc - #11382
Conversation
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11382
Scan targets checked: linuxkm-bugs, linuxkm-src, wolfcrypt-bugs, wolfcrypt-rs-bugs, wolfcrypt-src
Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
|
* reduce WC_LINUXKM_MAX_NS_WITHOUT_YIELD from 1 second to 25 ms for better kernel citizenship.
* add WC_DEBUG_FORCE_KERNEL_SETTINGS for inhibiting #errors on unsupported configurations.
* add __extension__ annotation to macros that need it.
* add wc_svr_disallowed_count_reset() and wc_svr_disallowed_count_current().
* fix CAN_SAVE_VECTOR_REGISTERS() to honor DEBUG_VECTOR_REGISTER_ACCESS_ALWAYS_{ON,OFF}.
* add WC_RELAX_LONG_LOOP() to DEBUG_VECTOR_REGISTER_ACCESS_ALWAYS_OFF variant of SAVE_VECTOR_REGISTERS2().
* allow for fully user-supplied SAVE_VECTOR_REGISTERS() and friends.
* add WOLFSSL_DEBUG_TRACE_ERROR_CODES coverage for all system error codes used by module_hooks.c and its includes. * implement double-run wolfCrypt_IntegrityTest_fips() and wc_RunAllCast_fips() in WC_C_DYNAMIC_FALLBACK configurations, once with acceleration on (leveraging fallback instrumentation to fail the module if any fallbacks occur), and once with it forced off using DISABLE_VECTOR_REGISTERS().
…DEBUG_VECTOR_REGISTER_ACCESS_ALWAYS_ON, inhibit DISABLE_VECTOR_REGISTERS() exercises and auditing of wc_svr_disallowed_count_current().
…run_code_audit_accel and /sys/module/libwolfssl/FIPS_optest_run_code_audit_c.
… USE_INTEL_SPEEDUP, don't expect wc_svr_disallowed_count_current() to increase for wolfCrypt_IntegrityTest_fips() (no AES in it).
…PI coexistence: in FIPS_optest_trig_handler(), implement assiduous (atomic-based) mutual exclusion with LKCAPI registration.
…, not wc_HmacUpdate_fips(), for compatibility with dev-no-post.
…ith a runtime check that kernel fips_enabled is zero.
* add libwolfssl_inited flag variable and use it for proper error-path cleanup; * call wc_linuxkm_allocate_svr_states() and wc_linuxkm_free_svr_states() explicitly in FIPS builds (avoid atomic-context synchronous call to wc_linuxkm_allocate_svr_states() via fipEntry()); * add missing WOLFSSL_FIPS_DEV_NO_POST gates; * in wc_lkm_LockMutex(), return BUSY_E immediately if in_nmi().
…batching several chunks within a single SAVE_VECTOR_REGISTERS2() bracket (entails adding WALK_ATOMIC to calls that affect walk dynamics during the locked batches).
…ERROR_CODES_PER_FILE and WOLFSSL_DEBUG_TRACE_ERROR_CODES_THIS_FILE (file-scoped code traces).
…G_PREEMPT_RT kernels.
…WOLFSSL_ATOMIC_LOAD() and WOLFSSL_ATOMIC_STORE(), use __ATOMIC_SEQ_CST rather than __ATOMIC_CONSUME/__ATOMIC_RELEASE, for consistency with semantics of the primary C11 bindings to atomic_load() and atomic_store().
…rly, and add WC_LINUXKM_HAVE_MY_KALLSYMS_LOOKUP_NAME.
…S_optest_trig_audit_c_attr to use distinct handlers that pass distinct mode arguments to a multi-personality FIPS_optest_trig_common(), properly implementing the SVR-auditing variants of the FIPS_optest_run_code sysfs node.
…ECTOR_REGISTER_ACCESS_ALWAYS_{OFF,ON} settings.
* always call wolfCrypt_Init() directly, even in TLS builds, to assure mutex-free scheduler context during allocations; * convert sysfs nodes from struct kobj_attribute to struct module_attribute, matching the module_sysfs_ops dispatch on THIS_MODULE->mkobj.kobj, for compatibility with CONFIG_CFI_CLANG (kCFI) kernels.
2c52057 to
8864af4
Compare
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #11382
Scan targets checked: linuxkm-src, linuxkm-bugs, wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs
Findings: 3
3 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
| } | ||
|
|
||
| #if WC_LINUXKM_GCM_SVR_BATCH > 0 | ||
| if (SAVE_VECTOR_REGISTERS2() == 0) { |
There was a problem hiding this comment.
GCM batching moves AAD allocation into atomic context · Kernel memory safety
SAVE_VECTOR_REGISTERS2() makes fragmented-AAD allocation and freeing run with preemption disabled, forcing unreliable GFP_ATOMIC allocation. With vmalloc storage, free() reaches kvfree() outside its permitted task context. Unlike known #9680, this concerns allocation context, not bounds.
Related known finding #12850 (similar but distinct): Both affect AesGcmCrypt_1 GCM processing, but #12850 writes unauthenticated plaintext before final tag verification; this performs AAD allocation/free under a saved-vector atomic context. The faulting operations, root causes, and fixes differ.
Suggested fix: Allocate and free the AAD bounce buffer outside the saved-vector region; bracket only the GCM operations that require SIMD.
Basis: Linux Memory Management APIs: GFP_ATOMIC is a non-sleeping emergency-pool allocation, while kvfree() requires preemptible task or non-NMI interrupt context.
| ret = linuxkm_sysfs_install_attr(&FIPS_optest_trig_audit_accel_attr.attr, &installed_sysfs_FIPS_optest_trig_audit_accel_files); | ||
| if (ret != 0) { | ||
| pr_err("ERROR: linuxkm_sysfs_install_attr() failed for %s (code %d).\n", FIPS_optest_trig_audit_accel_attr.attr.name, ret); | ||
| (void)libwolfssl_cleanup(); |
There was a problem hiding this comment.
New optest sysfs nodes lack init-failure rollback · Resource leaks on error paths
The new audit attributes are installed sequentially, but later failures call only libwolfssl_cleanup(), which removes no sysfs files. Successful earlier installs survive the init abort. This is adjacent to known #7892 but covers the newly added audit nodes.
Related known finding #7892 (similar but distinct): Both are wolfssl_init error-path rollback omissions involving sysfs state, but #7892 covers existing post-initialization and FIPS optest-trigger paths, while this covers newly added audit attributes installed sequentially. The installed nodes and rollback paths differ, so a separate patch is required.
Suggested fix: Rollback every optest attribute whose installed flag is set before any post-install initialization error returns.
Basis: Linux sysfs API pairing contract: each successful sysfs_create_file() installation is released with sysfs_remove_file().
linuxkm/linuxkm_wc_port.h:WC_LINUXKM_MAX_NS_WITHOUT_YIELDfrom 1 second to 25 ms for better kernel citizenship.WC_DEBUG_FORCE_KERNEL_SETTINGSfor inhibiting#errorson unsupported configurations.__extension__annotation to macros that need it.wc_svr_disallowed_count_reset()andwc_svr_disallowed_count_current().CAN_SAVE_VECTOR_REGISTERS()to honorDEBUG_VECTOR_REGISTER_ACCESS_ALWAYS_{ON,OFF}.WC_RELAX_LONG_LOOP()toDEBUG_VECTOR_REGISTER_ACCESS_ALWAYS_OFFvariant ofSAVE_VECTOR_REGISTERS2().SAVE_VECTOR_REGISTERS()and friends.linuxkm/module_hooks.c:WOLFSSL_DEBUG_TRACE_ERROR_CODEScoverage for all system error codes used bymodule_hooks.cand its includes.wolfCrypt_IntegrityTest_fips()andwc_RunAllCast_fips()inWC_C_DYNAMIC_FALLBACKconfigurations, once with acceleration on (leveraging fallback instrumentation to fail the module if any fallbacks occur), and once with it forced off usingDISABLE_VECTOR_REGISTERS().linuxkm/module_hooks.c: whenDEBUG_VECTOR_REGISTER_ACCESS_FUZZINGorDEBUG_VECTOR_REGISTER_ACCESS_ALWAYS_ON, inhibitDISABLE_VECTOR_REGISTERS()exercises and auditing ofwc_svr_disallowed_count_current().linuxkm/module_hooks.c: implement/sys/module/libwolfssl/FIPS_optest_run_code_audit_acceland/sys/module/libwolfssl/FIPS_optest_run_code_audit_c.linuxkm/module_hooks.c: inwolfssl_init(), whenWOLFSSL_AESNIbut notUSE_INTEL_SPEEDUP, don't expectwc_svr_disallowed_count_current()to increase forwolfCrypt_IntegrityTest_fips()(no AES in it).linuxkm/module_hooks.candwolfcrypt/src/rng_bank.c: fixes for external review ofFIPS_OPTEST/LKCAPI coexistence and affinity lock error handling.in
FIPS_optest_trig_handler(), implement assiduous (atomic-based) mutual exclusion with LKCAPI registration.in
wc_rng_bank_checkout(), propagateINTERRUPTED_Efrombank->affinity_lock_cbrather than swallowing it -- caller-requested interruption must abort checkout, consistent with theWC_CHECK_FOR_INTR_SIGNALS()handling in the same loop; other affinity lock errors continue to be tolerated (affinity is advisory).linuxkm/linuxkm-fips-hash.c: inhmac_update_cb(), usewc_HmacUpdate(), notwc_HmacUpdate_fips(), for compatibility withdev-no-post.linuxkm/lkcapi_glue.c: tolerate !HAVE_FIPSwithCONFIG_CRYPTO_FIPS, with a runtime check that kernelfips_enabledis zero.linuxkm/module_hooks.c:add
libwolfssl_initedflag variable and use it for proper error-path cleanup;call
wc_linuxkm_allocate_svr_states()andwc_linuxkm_free_svr_states()explicitly in FIPS builds (avoid atomic-context synchronous call towc_linuxkm_allocate_svr_states()viafipEntry());add missing
WOLFSSL_FIPS_DEV_NO_POSTgates;in
wc_lkm_LockMutex(), returnBUSY_Eimmediately ifin_nmi().tested with