Skip to content

20260610-linuxkm-fenrir#10676

Open
douzzer wants to merge 26 commits into
wolfSSL:masterfrom
douzzer:20260610-linuxkm-fenrir
Open

20260610-linuxkm-fenrir#10676
douzzer wants to merge 26 commits into
wolfSSL:masterfrom
douzzer:20260610-linuxkm-fenrir

Conversation

@douzzer

@douzzer douzzer commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Fixes for numerous "low" Fenrir issues in linuxkm/. See commit messages for the details.

tested with

wolfssl-multi-test.sh ...
check-source-text
quantum-safe-wolfssl-all-crypto-only-noasm-fips-dev-linuxkm-next-clang-tidy
quantum-safe-wolfssl-all-crypto-only-intelasm-sp-asm-sp-fips-dev-linuxkm-next-insmod

douzzer added 25 commits June 12, 2026 18:14
F-1880: Unsigned word32 dec_len Silently Wraps Negative wc_RsaSSL_Verify Error Codes, Returning Wrong Errno on RSA Signature Verification Failure
F-1881: word32 sig_len Silently Wraps Negative wc_RsaSSL_Sign Error in Self-Test Functions, Bypassing <= 0 Guard
F-1882: word32 priv_len / pub_len Silently Wrap Negative wc_RsaKeyToDer / wc_RsaKeyToPublicDer Errors Across Three RSA Self-Test Functions
also ForceZeros various other potentially sensitive allocations before freeing them, and uses unconditional free() per current libwolfssl best practice.
in AesGcmCrypt_1() and AesCcmCrypt_1(), check for overflow on assoclen+cryptlen in both encrypt and decrypt modes;

in linuxkm_test_kpp_driver(), return MEMORY_E, not -ENOMEM;

in km_direct_rsa_dec(), only update req->dst_len for -EOVERFLOW, not for -EINVAL.
F-1428: Missing ForceZero on sg_buf Containing Decrypted Plaintext in AES-GCM Non-Stream Path
F-3293: AES-CCM Non-Contiguous SG Path Missing ForceZero on sg_buf Containing Decrypted Plaintext
F-1433: AES CBC/CFB Self-Test Functions Silently Continue After enc2/dec2 Allocation Failure
F-1434: linuxkm_test_aesgcm Silently Returns Success on Kernel Crypto Allocation Failure
…ith Plain Assignment Instead of wc_ForceZero

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #10676

Scan targets checked: linuxkm-bugs, linuxkm-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Findings are non-blocking.

Comment thread linuxkm/module_hooks.c Outdated
WC_SANITIZE_ENABLE();
buf = 0;
}
wc_ForceZero(&buf, 0, sizeof buf);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 [High] wc_ForceZero called with 3 arguments instead of 2 · API contract violations

wc_ForceZero is prototyped as void wc_ForceZero(void *mem, size_t len) (2 params), but it is called as wc_ForceZero(&buf, 0, sizeof buf) with 3 arguments, which fails to compile when WC_LINUXKM_RDSEED_IN_GLUE_LAYER is defined (the guarding config).

Fix: Drop the spurious 0 argument: call wc_ForceZero(&buf, sizeof buf).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@dgarske dgarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skoll Multi-Scan Review

Modes: review + review-securityOverall recommendation: REQUEST_CHANGES
Findings: 4 total — 4 posted, 0 skipped
4 finding(s) posted as inline comments (see file-level comments below)

Posted findings

  • [High] [review+review-security] wc_ForceZero() called with 3 arguments (compile error / broken entropy zeroization fix)linuxkm/module_hooks.c:475
  • [Low] [review] Trailing comma instead of period in error messagelinuxkm/lkcapi_aes_glue.c:3643
  • [Low] [review-security] km_direct_rsa_dec no longer reports required dst_len on -EINVAL pathlinuxkm/lkcapi_rsa_glue.c:799
  • [Info] [review-security] x86_vector_register_glue.c allocation-failure log size argument changedlinuxkm/x86_vector_register_glue.c:72

Review generated by Skoll

Comment thread linuxkm/module_hooks.c Outdated
WC_SANITIZE_ENABLE();
buf = 0;
}
wc_ForceZero(&buf, 0, sizeof buf);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 [High] wc_ForceZero() called with 3 arguments (compile error / broken entropy zeroization fix) · Logic

Both the review and review-security modes independently flag this. The newly added stack-entropy scrub call invokes wc_ForceZero(&buf, 0, sizeof buf) with THREE arguments, but wc_ForceZero is declared as void wc_ForceZero(void *mem, size_t len) (wolfssl/wolfcrypt/memory.h:335; defined wolfcrypt/src/memory.c:1681) and takes only TWO. The stray middle 0 looks like a memset(&buf, 0, sizeof buf) signature carried over by mistake. This is a C constraint violation that GCC reports as error: too many arguments to function 'wc_ForceZero', and under the kernel build's -Werror it fails to compile. The same file already shows the correct 2-argument form at line 523: wc_ForceZero(&rndTmp, sizeof(rndTmp));. The function IntelRDseed64_r is compiled only under WC_LINUXKM_RDSEED_IN_GLUE_LAYER (guard at module_hooks.c:413-528) with HAVE_INTEL_RDSEED/HAVE_AMD_RDSEED (e.g. FIPS v5 RDSEED-in-glue builds), which is why the PR's tested configs (which took the WC_LINUXKM_WOLFENTROPY_IN_GLUE_LAYER branch at line 405) did not surface the break. Net effect: (1) the module will not build in the affected RDSEED-glue configs, and (2) the F-3294 entropy-zeroization hardening it implements is malformed. No 3-argument wc_ForceZero/ForceZero macro exists anywhere in the tree.

Fix: Drop the stray 0 argument so the call matches the 2-arg prototype: wc_ForceZero(&buf, sizeof buf);. Ideally add a CI config that defines WC_LINUXKM_RDSEED_IN_GLUE_LAYER (HAVE_INTEL_RDSEED / HAVE_AMD_RDSEED) so this path is compiled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caught locally too. Fixed, to commit&push in a minute.

Comment thread linuxkm/lkcapi_aes_glue.c
pr_err("error: malloc src failed: %ld\n",
PTR_ERR(src));
pr_err("error: malloc src failed,\n");
ret = MEMORY_E;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 [Low] Trailing comma instead of period in error message · style

The reworked malloc-failure message reads pr_err("error: malloc src failed,\n"); with a trailing comma, whereas the sibling messages in the same function use a period (e.g. "error: malloc dst failed.\n"). Purely cosmetic; the removal of the bogus PTR_ERR(src) (which is meaningless for a NULL malloc return) and the added ret = MEMORY_E; are correct.

Fix: Change the trailing comma to a period for consistency: pr_err("error: malloc src failed.\n");. Not blocking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Typo obviously.

Comment thread linuxkm/lkcapi_rsa_glue.c
@@ -793,11 +797,12 @@ static int km_direct_rsa_dec(struct akcipher_request *req)
}

if (req->dst_len != (unsigned int)ctx->key_len) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 [Low] km_direct_rsa_dec no longer reports required dst_len on -EINVAL path · Logic

The diff moved req->dst_len = ctx->key_len; inside the -EOVERFLOW branch. BEFORE, req->dst_len was set to ctx->key_len for both the -EOVERFLOW (dst_len too small) and -EINVAL (dst_len == 0 or dst_len > key_len) branches. AFTER, on the -EINVAL branch req->dst_len is left unchanged. This is a behavioral change but is benign and arguably more correct: the kernel akcipher convention only requires the driver to report the needed size on -EOVERFLOW so the caller can retry; -EINVAL is a hard error. No out-of-bounds or security impact -- flagged only as a behavior-delta note.

Fix: No change required if intentional. If callers were relying on the previous behavior of always receiving key_len in req->dst_len, restore the unconditional assignment; otherwise document the deliberate change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was indeed intentional for API compliance.

@@ -72,7 +72,7 @@ WARN_UNUSED_RESULT int allocate_wolfcrypt_linuxkm_fpu_states(void)
if (! wc_linuxkm_fpu_states) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ [Info] x86_vector_register_glue.c allocation-failure log size argument changed · Logic

The error message argument was changed from nr_cpu_ids * sizeof(struct fpu_state *) to nr_cpu_ids * sizeof(wc_linuxkm_fpu_states[0]), making the logged byte count track the actual element type of the allocation. This is a purely cosmetic logging accuracy improvement with no functional or security impact; noted for completeness.

Fix: No action needed; the change is correct.

linuxkm/lkcapi_aes_glue.c: fix typo in linuxkm_test_aesgcm() error message.
@douzzer douzzer removed their assignment Jun 13, 2026
@douzzer douzzer requested a review from dgarske June 13, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For This Release Release version 5.9.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants