Skip to content

Bsdkm cleanup - #11119

Open
philljj wants to merge 3 commits into
wolfSSL:masterfrom
philljj:bsdkm_cleanup
Open

Bsdkm cleanup#11119
philljj wants to merge 3 commits into
wolfSSL:masterfrom
philljj:bsdkm_cleanup

Conversation

@philljj

@philljj philljj commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Description

bsdkm cleanup:

  • F-7721: wrap wolfkmod_fpu_kern_enter / leave macros.
  • F-7711: missing wc_debug_CipherLifecycleInit.
  • F-6855: don't free a never-initialized aes_decrypt context.

Testing

#!/bin/sh                                                                       
BSDKM_CFLAGS="-DWC_DEBUG_CIPHER_LIFECYCLE -DWOLFSSL_BSDKM_VERBOSE_DEBUG -DWOLFSSL_BSDKM_FPU_DEBUG -DWOLFSSL_BSDKM_MEMORY_DEBUG"
                                                                                
./configure --enable-freebsdkm --enable-freebsdkm-crypto-register \
  --enable-cryptonly --enable-crypttests \
  --enable-kernel-benchmarks --enable-all-crypto --enable-aesni \ 
  --enable-aesni-with-avx \ 
  CFLAGS="$BSDKM_CFLAGS" && make \
  || exit 1
                      
file bsdkm/libwolfssl.ko && sudo kldload bsdkm/libwolfssl.ko || exit 1
BSDKM_CFLAGS="-DWOLFSSL_BSDKM_VERBOSE_DEBUG"
./configure --enable-freebsdkm --enable-cryptonly --enable-crypttests \
  --enable-kernel-benchmarks --enable-all-crypto --enable-aesni \
  --enable-aesni-with-avx --enable-sp-asm \
  CFLAGS="$BSDKM_CFLAGS" && make \
  || exit 1
file bsdkm/libwolfssl.ko && sudo kldload bsdkm/libwolfssl.ko || exit 1

@philljj philljj self-assigned this Aug 10, 2026
Copilot AI lite review requested due to automatic review settings August 10, 2026 03:57

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.

Pull request overview

This PR performs cleanup and robustness improvements in the BSD kernel module integration, focusing on safer macro wrapping and better AES session lifecycle handling (including cipher lifecycle debug initialization and avoiding frees of unused contexts).

Changes:

  • Wrap wolfkmod_fpu_kern_enter/leave macros in do { ... } while (0) to behave safely in all statement contexts.
  • Refine AES context cleanup so GCM sessions don’t free the never-initialized aes_decrypt context.
  • Initialize wc_debug_CipherLifecycleInit for local AES copies used in CBC/GCM work paths (when enabled).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
bsdkm/x86_vecreg.c Wraps FPU enter/leave wrapper macros to be safe as single statements.
bsdkm/wolfkmod.c Adjusts AES context cleanup behavior and adds cipher lifecycle debug initialization in CBC/GCM paths.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread bsdkm/wolfkmod.c
Comment on lines +681 to +684
case CRYPTO_AES_CBC:
wolfkdriv_aes_ctx_clear(&session->aes_ctx, 1);
default:
break;
Comment thread bsdkm/wolfkmod.c
Comment on lines +386 to +390
/* clean up allocated km_aes_ctx struct.
* - cbc allocates both encrypt and decrypt, and frees both.
* - gcm uses only aes_encrypt.
* */
static void wolfkdriv_aes_ctx_clear(km_aes_ctx * ctx, int free_decrypt)
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