Skip to content

fix(migtd): avoid sending uninitialized ExchangeInformation padding#914

Open
kali834x wants to merge 1 commit into
intel:mainfrom
kali834x:exchange-info-padding
Open

fix(migtd): avoid sending uninitialized ExchangeInformation padding#914
kali834x wants to merge 1 commit into
intel:mainfrom
kali834x:exchange-info-padding

Conversation

@kali834x

Copy link
Copy Markdown

ExchangeInformation carries the negotiated version range and the migration session key, and the source and destination MigTDs exchange it over the RA-TLS channel by writing the struct's raw bytes through as_bytes(). The struct had no repr(C), so the layout was the compiler's choice, and with the two u16 version fields in front of the 8-byte-aligned key there are four bytes of trailing padding after max_ver. as_bytes() copies the whole struct including that padding, and nothing writes those bytes when the value is built, so each side hands the peer four uninitialized bytes of its own memory during the key exchange. I noticed it while checking why this struct alone among the wire types in this module has no repr(C). Adding repr(C) and turning the implicit padding into an explicit zeroed reserved field closes that, and the field order keeps key, min_ver and max_ver at the offsets the compiler was already giving them, so the on-wire bytes are unchanged for peers running the current code.

ExchangeInformation is exchanged with the migration peer byte-for-byte via as_bytes(), but it had no repr(C) and the four bytes of trailing padding after max_ver were copied to the peer uninitialized during the key exchange. Pin the layout with repr(C) and replace the implicit padding with an explicit zeroed reserved field; field order keeps key/min_ver/max_ver at their existing offsets so the wire format is unchanged.

Signed-off-by: Zibran Khan <kali834x@gmail.com>
@kali834x kali834x requested review from jyao1 and sgrams as code owners June 25, 2026 20:37
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