Skip to content

Add m4 Code to Insecure Scrubs Fix#105

Open
Lightning11wins wants to merge 15 commits into
masterfrom
fix-insecure-scrubs-m4
Open

Add m4 Code to Insecure Scrubs Fix#105
Lightning11wins wants to merge 15 commits into
masterfrom
fix-insecure-scrubs-m4

Conversation

@Lightning11wins
Copy link
Copy Markdown
Contributor

Add m4 macros to detect shred functions, which are used in the C code, if available.

Supported shred functions:

  • memset_explicit()
  • memset_s()
  • explicit_bzero()

The code falls back to the original volatile memset only if none of the above functions are available. (This happens to be the case on my dev VM, so this PR doesn't actually change anything. However, in an ideal environment, one of the functions would be available, and this code would use it.)

This PR is blocked behind #104, which will need to be merged before this PR can be reviewed.

Add cxsecShred() to cxsec.c and cxsec.h.
Clean up newline spacing in cxsec.c.
Update cxssShred() to use cxsecShred() instead of memset().
Improve the signature of cxssShred().
Improve the doc comment on cxssShred().
Clean up.
Remove #include "cxss/cxss.h".
Add #include directives to include only the things that policy.h actually needs.
Clean up.
Add code to use memset_explicit(), if available.
Add code to use memset_s(), if available.
Add code to use explicit_bzero(), if available.
Add code to fall back to the original volatile memset if no other options are available.
@Lightning11wins Lightning11wins self-assigned this May 15, 2026
@Lightning11wins Lightning11wins added ai-review Request AI review for PRs. size: trivial Easy to review, probably ~100 lines or fewer. labels May 15, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 15, 2026

Greptile Summary

This PR introduces autoconf detection for secure memory-scrubbing functions (memset_explicit, memset_s, explicit_bzero) and a new cxsecShred() primitive in centrallix-lib, then routes all existing cxssShred() callers through it. On systems where none of the preferred functions are available, a volatile-loop fallback is used.

  • aclocal.m4 / configure.ac: Adds CHECK_MEMSET macro with correctly double-bracketed array indices and per-function AC_RUN_IFELSE probes; the generated configure looks correct.
  • cxsec.c: Implements cxsecShred() with the right __STDC_WANT_LIB_EXT1__ guard placed before <string.h>; uses independent #ifdef sentinels rather than #if/#elif which causes multiple branches to be compiled when a platform advertises more than one supported function.
  • Callers (mtsession.c, xringqueue.c, net_http_sess.c, objdrv_mysql.c, cxss_*): All memset calls on sensitive buffers are consistently replaced with cxssShred / cxsecShred; includes are correctly added where needed.

Confidence Score: 5/5

The change is safe to merge; it correctly wires up autoconf detection and routes all sensitive-buffer zeroing through the new abstraction without altering any security-critical logic paths.

The autoconf probes are well-formed, the generated configure looks correct, and all call sites are consistently updated. The only findings are style-level: independent #ifdef blocks instead of #if/#elif in the fallback chain, and a misnamed doc comment.

centrallix-lib/src/cxsec.c — the #ifdef sentinel pattern and doc comment typo are minor but worth tidying before this lands.

Important Files Changed

Filename Overview
centrallix-lib/aclocal.m4 Adds CHECK_MEMSET macro that probes for memset_explicit, memset_s (with STDC_WANT_LIB_EXT1), and explicit_bzero using AC_RUN_IFELSE; array indices correctly double-bracketed.
centrallix-lib/src/cxsec.c Adds cxsecShred() with correct STDC_WANT_LIB_EXT1 guard; uses independent #ifdef blocks with a CXSEC_FOUND sentinel instead of #if/#elif which compiles dead branches when multiple HAVE_* macros are set; doc comment names function cxssShred instead of cxsecShred.
centrallix/cxss/cxss_utility.c cxssShred now delegates to cxsecShred; signature updated from int/unsigned char* to void/void*; correct include of cxlib/cxsec.h added.
centrallix-lib/src/mtsession.c All seven memset(s, 0, sizeof(MtSession)) calls replaced with cxsecShred; cxsec.h include added.
centrallix/netdrivers/net_http_sess.c memset replaced with cxssShred; cxss/cxss.h already transitively included via net_http.h so no new include needed.

Reviews (2): Last reviewed commit: "Clean up code that defined things we did..." | Re-trigger Greptile

Comment thread centrallix-lib/src/cxsec.c Outdated
Comment thread centrallix-lib/aclocal.m4 Outdated
Comment thread centrallix-lib/src/cxsec.c
@Lightning11wins
Copy link
Copy Markdown
Contributor Author

This PR is ready for human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request AI review for PRs. size: trivial Easy to review, probably ~100 lines or fewer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant