Repository navigation
ctutils: fix Choice::to_*_mask constant-time; add checkct - #1567
Merged
Merged
Conversation
Note: this is a security-critical fix. Uses `to_u8` when generating various width masks which goes through `black_box`. This wasn't possible before because these are `const fn` and `black_box` couldn't be used in `const fn` until MSRV 1.86. This is a similar problem to the other mask generation bugs we've had that have been worked around using `asm!` falling back to `black_box` in the `cmov` crate (#1332, #1336) except we can't use `asm!` in a `const fn`, so `black_box` and validation of the generated ASM with `cargo checkct` (a BINSEC wrapper) is the best we can do here.
tarcieri
force-pushed
the
ctutils/fix-maskgen+checkct
branch
from
October 23, 2026 00:10
5f115d6 to
0cbebd6
Compare
Merged
tarcieri
added a commit
that referenced
this pull request
Oct 23, 2026
2 tasks done
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.
Note: this is a security-critical fix.
Uses
to_u8when generating various width masks which goes throughblack_box. This wasn't possible before because these areconst fnandblack_boxcouldn't be used inconst fnuntil MSRV 1.86.This is a similar problem to the other mask generation bugs we've had that have been worked around using
asm!falling back toblack_boxin thecmovcrate (#1332, #1336) except we can't useasm!in aconst fn, soblack_boxand validation of the generated ASM withcargo checkct(a BINSEC wrapper) is the best we can do here.