Fix: Add -Wa,--noexecstack to cc_builder for assembly files (resolves #939) #940
+8
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes missing
.note.GNU-stacksections in ML-KEM assembly object files when usingcc_builder, which causes executable stacks on older Linux systems.Problem
ML-KEM native x86_64 assembly files compiled by
cc_builderare missing.note.GNU-stacksections. On older Linux systems, this results in executable stacks, bypassing DEP/NX protections.Root Cause
-Wa,--noexecstack(crypto/CMakeLists.txt:77)cmake_builderpasses this through correctly ✓cc_builderwas missing this flag ✗ML-KEM assembly files rely on the build system to add
.note.GNU-stacksections via assembler flags (unlike s2n-bignum which has them in source).Solution
Add
-Wa,--noexecstackusingcc-rs'sasm_flag()method inprepare_builder().Verification
Tested on x86_64 Linux:
Before fix:
After fix:
Full verification script available: verify-execstack-fix.sh
Impact
cc_builderReferences
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.