Skip to content

20260326-various-fixes#10086

Merged
padelsbach merged 4 commits intowolfSSL:masterfrom
douzzer:20260326-various-fixes
Mar 27, 2026
Merged

20260326-various-fixes#10086
padelsbach merged 4 commits intowolfSSL:masterfrom
douzzer:20260326-various-fixes

Conversation

@douzzer
Copy link
Copy Markdown
Contributor

@douzzer douzzer commented Mar 26, 2026

linuxkm/, wolfcrypt/src/dh.c, wolfcrypt/test/test.c, wolfcrypt/test/test.h, wolfssl/wolfcrypt/wc_port.h:

fixes and workarounds for clang-tidy complaints:

  • clang-diagnostic-unknown-warning-option
  • bugprone-sizeof-expression
  • clang-diagnostic-error "address argument to atomic operation must be a pointer to a trivially-copyable type"
  • bugprone-macro-parentheses
  • clang-diagnostic-unused-but-set-variable
  • readability-redundant-declaration

wolfcrypt/src/asn.c: fixes for invalid memory access in wc_DsaPublicKeyDecode() and wc_EccPublicKeyDecode(), detected by cppcheck-force-source, lms-xmss-wolfssl-all-clang-sanitizer, and sanitizer-clang-all-noasm.

wolfssl/wolfcrypt/types.h: restore WC_ALLOC_DO_ON_FAILURE fallback definition from 760178c -- reversion in part of 5f4d499. fixes optest build failures in all-crypto-only-intelasm-fips-v5-linuxkm-next-insmod-optest, all-crypto-only-intelasm-fips-v6-linuxkm-next-insmod-optest, and all-crypto-only-intelasm-fips-dev-linuxkm-next-insmod-optest.

tested with

wolfssl-multi-test.sh ...
super-quick-check
quantum-safe-wolfssl-all-crypto-only-noasm-linuxkm-mainline-insmod-clang-tidy

douzzer added 3 commits March 26, 2026 15:41
…est.h, wolfssl/wolfcrypt/wc_port.h:

fixes and workarounds for clang-tidy complaints:
  * clang-diagnostic-unknown-warning-option
  * bugprone-sizeof-expression
  * clang-diagnostic-error "address argument to atomic operation must be a pointer to a trivially-copyable type"
  * bugprone-macro-parentheses
  * clang-diagnostic-unused-but-set-variable
  * readability-redundant-declaration
…eyDecode() and wc_EccPublicKeyDecode(), detected by cppcheck-force-source, lms-xmss-wolfssl-all-clang-sanitizer, and sanitizer-clang-all-noasm.
…finition from 760178c -- reversion in part of 5f4d499.  fixes optest build failures in all-crypto-only-intelasm-fips-v5-linuxkm-next-insmod-optest, all-crypto-only-intelasm-fips-v6-linuxkm-next-insmod-optest, and all-crypto-only-intelasm-fips-dev-linuxkm-next-insmod-optest.
Copy link
Copy Markdown

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

Choose a reason for hiding this comment

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

Fenrir Automated Review — PR #10086

Scan targets checked: linuxkm-bugs, linuxkm-src, wolfcrypt-bugs, wolfcrypt-src
Findings: 2

High (1)

Wrong argument type passed to FREE_ASNGETDATA in wc_EccPublicKeyDecode

File: wolfcrypt/src/asn.c:30214
Function: wc_EccPublicKeyDecode
Category: API contract violations

The call FREE_ASNGETDATA(dataASN, key) passes key (an ecc_key* pointer) as the second argument, but the macro expects a heap pointer (the same type as the 4th argument to ALLOC_ASNGETDATA). The corresponding allocation on the same function uses key->heap: ALLOC_ASNGETDATA(dataASN, eccKeyASN_Length, ret, key->heap). The original code correctly passed key->heap. When WOLFSSL_SMALL_STACK is defined, FREE_ASNGETDATA expands to XFREE(dataASN, heap, DYNAMIC_TYPE_TMP_BUFFER) — passing an ecc_key* where a heap hint is expected would result in incorrect behavior or memory corruption.

FREE_ASNGETDATA(dataASN, key);
    return ret;

Recommendation: Restore the original heap argument: FREE_ASNGETDATA(dataASN, key->heap);


Low (1)

Potentially incorrect heap argument in FREE_ASNGETDATA

File: wolfcrypt/src/asn.c:30214
Function: wc_EccPublicKeyDecode
Category: Cryptographic correctness

The second argument to FREE_ASNGETDATA was changed from key->heap to key. The corresponding ALLOC_ASNGETDATA call still uses key->heap as the heap parameter: ALLOC_ASNGETDATA(dataASN, eccKeyASN_Length, ret, key->heap). If FREE_ASNGETDATA passes its second argument directly to XFREE as the heap identifier, passing key (an ecc_key* pointer) instead of key->heap (a void* heap pointer) would supply the wrong value. With custom memory allocators that inspect the heap parameter, this could cause incorrect deallocation behavior. Note: if the FREE_ASNGETDATA macro was updated elsewhere to extract ->heap from the key object, this change is correct — the reviewer could not access the macro definition to confirm.

-    FREE_ASNGETDATA(dataASN, key->heap);
+    FREE_ASNGETDATA(dataASN, key);

Recommendation: Verify that the FREE_ASNGETDATA macro definition accepts a key struct pointer and correctly extracts the heap. If it still expects a raw heap pointer, revert to FREE_ASNGETDATA(dataASN, key->heap) to match the ALLOC_ASNGETDATA call.


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

@douzzer
Copy link
Copy Markdown
Contributor Author

douzzer commented Mar 26, 2026

retest this please
(numerous harness glitches)

@douzzer
Copy link
Copy Markdown
Contributor Author

douzzer commented Mar 26, 2026

Fenrir Automated Review — PR #10086

Scan targets checked: linuxkm-bugs, linuxkm-src, wolfcrypt-bugs, wolfcrypt-src Findings: 2

High (1)

Wrong argument type passed to FREE_ASNGETDATA in wc_EccPublicKeyDecode

File: wolfcrypt/src/asn.c:30214 Function: wc_EccPublicKeyDecode Category: API contract violations

The call FREE_ASNGETDATA(dataASN, key) passes key (an ecc_key* pointer) as the second argument, but the macro expects a heap pointer (the same type as the 4th argument to ALLOC_ASNGETDATA). The corresponding allocation on the same function uses key->heap: ALLOC_ASNGETDATA(dataASN, eccKeyASN_Length, ret, key->heap). The original code correctly passed key->heap. When WOLFSSL_SMALL_STACK is defined, FREE_ASNGETDATA expands to XFREE(dataASN, heap, DYNAMIC_TYPE_TMP_BUFFER) — passing an ecc_key* where a heap hint is expected would result in incorrect behavior or memory corruption.

FREE_ASNGETDATA(dataASN, key);
    return ret;

Recommendation: Restore the original heap argument: FREE_ASNGETDATA(dataASN, key->heap);

Low (1)

Potentially incorrect heap argument in FREE_ASNGETDATA

File: wolfcrypt/src/asn.c:30214 Function: wc_EccPublicKeyDecode Category: Cryptographic correctness

The second argument to FREE_ASNGETDATA was changed from key->heap to key. The corresponding ALLOC_ASNGETDATA call still uses key->heap as the heap parameter: ALLOC_ASNGETDATA(dataASN, eccKeyASN_Length, ret, key->heap). If FREE_ASNGETDATA passes its second argument directly to XFREE as the heap identifier, passing key (an ecc_key* pointer) instead of key->heap (a void* heap pointer) would supply the wrong value. With custom memory allocators that inspect the heap parameter, this could cause incorrect deallocation behavior. Note: if the FREE_ASNGETDATA macro was updated elsewhere to extract ->heap from the key object, this change is correct — the reviewer could not access the macro definition to confirm.

-    FREE_ASNGETDATA(dataASN, key->heap);
+    FREE_ASNGETDATA(dataASN, key);

Recommendation: Verify that the FREE_ASNGETDATA macro definition accepts a key struct pointer and correctly extracts the heap. If it still expects a raw heap pointer, revert to FREE_ASNGETDATA(dataASN, key->heap) to match the ALLOC_ASNGETDATA call.

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

fixed

@douzzer
Copy link
Copy Markdown
Contributor Author

douzzer commented Mar 27, 2026

retest this please
(single remaining failure, PRB-FIPS-windows-test-ACVP\testing-cert3389.bat "Power On Self Test FAILURE")

@douzzer
Copy link
Copy Markdown
Contributor Author

douzzer commented Mar 27, 2026

Note, the OpenVPN failure is reporting defects in OpenVPN, not in libwolfssl. Ignore for now.

@padelsbach padelsbach merged commit 5b1d2d7 into wolfSSL:master Mar 27, 2026
652 of 656 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants