Skip to content

refactor(dstack-util): parse LUKS2 headers without the luks2 crate - #1496

Merged
kvinwang merged 1 commit into
nextfrom
refactor/drop-luks2
Oct 28, 2026
Merged

kvinwang merged 1 commit into
nextfrom
refactor/drop-luks2

Conversation

@kvinwang

Copy link
Copy Markdown
Collaborator

luks2 0.5.0 is unmaintained and is the only path to mio 0.7.14 (Dependabot alert, dismissed as Windows-only in #1494). dstack-util only uses it to decode headers in validate_luks2_headers, so this replaces it with a small system_setup/luks.rs that models just the fields that function checks. The validation logic is unchanged.

  • Checks luks2 did implicitly at parse time are kept; keyslots_size % 4096 is now explicit.
  • Unknown KDF types still decode and are rejected with Invalid LUKS keyslot KDF, so existing tests keep their error messages.
  • A differential run of 30 header mutations (type tags, priority, flags, integrity, tokens, digest refs, unaligned sizes, numeric-vs-string offsets, trailing garbage, ...) gives identical accept/reject results to the old code.
  • Relaxed: KDF/digest salt, iterations, digest and config.json_size no longer have to be present. The validator never inspected them and cryptsetup rejects headers without them.

Drops crossterm, mio 0.7, and the old aes/hmac/pbkdf2/sha2 0.9 crates from Cargo.lock.

luks2 0.5.0 is unmaintained and pulls crossterm 0.19 and mio 0.7.14,
which carries a Dependabot advisory (Windows named pipes). dstack-util
only uses it to decode headers for validate_luks2_headers, so model the
fields that function checks in a small local module instead.

The checks luks2 applied implicitly at parse time are kept: string-
encoded numbers, internally tagged types, keyslots_size alignment
(now an explicit check), stripes and sector size (already pinned).
A differential run of 30 header mutations against the previous code
gives the same accept/reject result for each.

Fields the validator never inspected (KDF and digest salt, iterations,
digest, config.json_size) are no longer required to be present. They
carry no security parameter, and cryptsetup refuses a header without
them, so this still fails closed.

Signed-off-by: Kevin Wang <wy721@qq.com>
@kvinwang
kvinwang force-pushed the refactor/drop-luks2 branch from 10bf32f to c03d541 Compare October 28, 2026 05:12
@kvinwang
kvinwang enabled auto-merge October 28, 2026 05:12
@kvinwang
kvinwang merged commit 5d116bd into next Oct 28, 2026
13 checks passed
@kvinwang
kvinwang deleted the refactor/drop-luks2 branch October 28, 2026 05:22
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