Skip to content

Silence -fsanitize=function for generic callback calls - #12217

Open
julek-wolfssl wants to merge 2 commits into
wolfSSL:masterfrom
julek-wolfssl:sk-pop-free-no-sanitize
Open

julek-wolfssl wants to merge 2 commits into
wolfSSL:masterfrom
julek-wolfssl:sk-pop-free-no-sanitize

Conversation

@julek-wolfssl

Copy link
Copy Markdown
Member

Clang's -fsanitize=function flags calls through function pointers whose type doesn't match the callee's. Typed free functions are called through void (*)(void *). The types are not compatible in C, but the call is fine on supported ABIs.

  • Add WC_NO_SANITIZE_FUNCTION to wolfSSL_sk_pop_free so clang skips the check.
  • Apply the same silencing to other callers of generic callbacks: stack hash, TXT_DB, ASN.1 item template and CTS128 callbacks, which are also called through generic pointer types.

Addresses #12204

Typed free functions are called through void (*)(void *). The types
are not compatible in C but the call is fine on supported ABIs.
Add WC_NO_SANITIZE_FUNCTION to skip clang's check.
Stack hash, TXT_DB, ASN.1 item template and CTS128 callbacks are also
called through generic pointer types.
@julek-wolfssl julek-wolfssl self-assigned this Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 17:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The ASN.1 sanitizer suppression leaves d2i_generic_obj’s allocation-failure cleanup uncovered, so sequence decoding under memory pressure can still trigger a function-sanitizer report or abort.

1 open issue
What changed in this PR

This PR adds targeted Clang function-sanitizer suppression to generic callback callers in wolfSSL’s OpenSSL compatibility layer, addressing reports described in #12204 without changing callback behavior.

Changes:

  • Introduces WC_NO_SANITIZE_FUNCTION with compiler checks and an empty fallback.
  • Applies it to stack destructors, hash callbacks, and TXT_DB lookup callbacks.
  • Annotates ASN.1 template callback callers and CTS128 encryption/decryption functions.
File Description
wolfssl/​wolfcrypt/​types.h Defines the portable sanitizer-suppression macro.
src/​ssl_sk.c Annotates generic destructor and hash callback callers.
src/​ssl_crypto.c Annotates CTS128 CBC callback callers.
src/​ssl_asn1.c Annotates ASN.1 template callback helpers.
src/​conf.c Annotates TXT_DB indexed lookup callbacks.

Review effort: Balanced

Comment thread src/ssl_asn1.c
return len;
}

WC_NO_SANITIZE_FUNCTION
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

zephyr-frdm_rw612

  • FLASH: datas +16 B, log_const_area -8 B, rodata +108 B, text +13,496 B (+4.8%, 296,076 B / 67,108,864 B, total: 0% used)
  • RAM: bss +49 B, datas +16 B (+0.1%, 58,423 B / 983,040 B, total: 6% used)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

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.

2 participants