Skip to content

Fix a 1-in-256 flake in the salt-label selftest - #765

Merged
samgbafa merged 1 commit into
mainfrom
bot/tc-4444-salt-selftest-flake
Nov 27, 2026
Merged

samgbafa merged 1 commit into
mainfrom
bot/tc-4444-salt-selftest-flake

Conversation

@samgbafa

@samgbafa samgbafa commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

selftest_salt_piece_labels_do_not_depend_on_filler_bytes failed about 1 run in 256. The selftest builds a salt whose random filler byte 14 can equal the DEK's byte 14. The salt scan reports the first 16-byte DEK window it finds, so in that case the window starting at byte 14 matches and the label becomes 14..31, not 15..31, which fails the first ensure!.

The fix is one added line, old_half_b[14] = !dek[14];, which forces filler byte 14 to differ from the DEK.

This changes an existing test, by adding one line and changing no assertion. The 15..31 assertion and the 20,000-trial loop are untouched. The test-edit guard's advisory asks for this explanation.

Verification: 2000 runs of the test binary with the fix, 0 failures (about 0.5 s per run). Without the line, 2000 runs gave 8 failures. cargo fmt --all -- --check is clean.

Details: TC-4444

The selftest reported the first 16-byte DEK window in the salt, so when random filler byte 14 equalled dek[14] (1 in 256) the label became 14..31 and the first assertion failed. Setting that byte to differ from dek[14] makes the 15..31 label deterministic.

Details: TC-4444
@samgbafa
samgbafa merged commit 0c11386 into main Nov 27, 2026
36 of 38 checks passed
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.

1 participant