Enforce ML-DSA x86 native assumptions#1244
Open
tob-joe wants to merge 2 commits into
Open
Conversation
| * in proofs/hol_light/x86_64/proofs/poly_caddq_avx2_asm.ml */ | ||
| __contract__( | ||
| requires(memory_no_alias(r, sizeof(int32_t) * MLDSA_N)) | ||
| requires(((uintptr_t)r % MLD_DEFAULT_ALIGN) == 0) |
Contributor
There was a problem hiding this comment.
Unfortunately, this doesn't work. There is no way to guarantee alignment with CBMC iirc.
Contributor
|
As far as I know, there is no way to model an alignment precondition in CBMC. Maybe we can consider not using |
Contributor
CBMC Results (ML-DSA-44)Full Results (205 proofs)
|
Contributor
CBMC Results (ML-DSA-44, REDUCE-RAM)Full Results (205 proofs)
|
Contributor
CBMC Results (ML-DSA-65, REDUCE-RAM)Full Results (205 proofs)
|
Contributor
CBMC Results (ML-DSA-87, REDUCE-RAM)Full Results (205 proofs)
|
Contributor
CBMC Results (ML-DSA-65)Full Results (205 proofs)
|
Contributor
CBMC Results (ML-DSA-87)Full Results (205 proofs)
|
2848b20 to
81fab1d
Compare
Add assembly-time guards for AVX2 qdata offsets and make the x86 native entry contracts require the alignment assumed by the assembly implementations. This keeps the public native wrappers, implementation declarations, and proof-facing assumptions aligned for the affected x86 routines. Verification: - ./scripts/tests cbmc -kl ALL -p poly_use_hint_native --single-step -j1 - ./scripts/tests cbmc -kl ALL -p poly_caddq_native_x86_64 --single-step -j1 - ./scripts/tests cbmc -kl 44 -p polyz_unpack_native_x86_64 --single-step -j1 - ./scripts/tests cbmc -kl 65 -p polyz_unpack_native_x86_64 --single-step -j1 - ./scripts/tests cbmc -kl 87 -p polyz_unpack_native_x86_64 --single-step -j1 - ./scripts/tests cbmc -kl ALL -p polyz_unpack_native --single-step -j1 Co-authored-by: Codex <[email protected]> Signed-off-by: Joe Doyle <[email protected]>
Move the AVX2 qdata layout assertions out of the simpasm header region. The assertions still check the dev assembly source against consts.h, but simpasm no longer carries them into the generated assembly it reassembles without that macro context. Regenerate the affected x86_64 native and HOL-Light assembly copies so lint and the x86_64 Intel-syntax autogen job can run past assembly generation. Co-authored-by: Codex <[email protected]> Signed-off-by: Joe Doyle <[email protected]>
81fab1d to
fe9c7ce
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Enforce ML-DSA x86 native assumptions
Summary
poly_caddq,poly_use_hint, andpolyz_unpack.Why
The x86_64 NTT/INTT assembly uses fixed qdata displacements after simplification. The dev source includes the symbolic layout, but the checked-in simplified assembly has numeric offsets; the new assembler guards make a future qdata layout mismatch fail at build time instead of silently preserving stale displacements.
Several AVX2 polynomial routines also use aligned loads or stores, and the HOL/CBMC proof assumptions already model aligned polynomial buffers. The in-tree typed callers pass
mld_polystorage, which is declared with the project alignment attribute; this patch makes that precondition explicit at the native API and raw x86 contract boundary.Verification
./scripts/tests cbmc -kl ALL -p poly_use_hint_native --single-step -j1./scripts/tests cbmc -kl ALL -p poly_caddq_native_x86_64 --single-step -j1./scripts/tests cbmc -kl 44 -p polyz_unpack_native_x86_64 --single-step -j1./scripts/tests cbmc -kl 65 -p polyz_unpack_native_x86_64 --single-step -j1./scripts/tests cbmc -kl 87 -p polyz_unpack_native_x86_64 --single-step -j1./scripts/tests cbmc -kl ALL -p polyz_unpack_native --single-step -j1Co-authored-by: Codex [email protected]
Signed-off-by: Joe Doyle [email protected]
This work was completed by Trail of Bits as part of the Patch The Planet project in collaboration with OpenAI. The issue was identified primarily by the Codex coding agent, and manually reviewed before submission.