[release/2.7] Make sure that message structures are correctly zero-initialized - #41524
Open
Ben Hillis (benhillis) wants to merge 1 commit into
Open
[release/2.7] Make sure that message structures are correctly zero-initialized#41524Ben Hillis (benhillis) wants to merge 1 commit into
Ben Hillis (benhillis) wants to merge 1 commit into
Conversation
) * Make sure that message structures are correctly zero-initialized Several message structures were declared without value-initialization before their fields were assigned. Use {} consistently at the declaration so the structures start out zeroed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Drop redundant initializers from WSLC message declarations The WSLC_* message types declare a default constructor via DECLARE_MESSAGE_CTOR, so adding {} at the declaration has no effect for them. Limit the change to the aggregate message types, where {} actually initializes the structure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> (cherry picked from commit 5106ffe) Copilot-Session: 35c940dc-b8de-495b-b9c6-b33f4fa16030
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The changes are narrow, consistent with existing message struct definitions (POD-style aggregates), and directly address indeterminate-field/padding risks without altering intended behavior.
Pull request overview
Backports a correctness fix to the release/2.7 branch to ensure various WSL init/mini_init message structures are value-initialized ({}) before selective field assignment, preventing indeterminate padding/unused fields from being transmitted.
Changes:
- Adds
{}value-initialization for severalLX_*message structs in Windows service VM code paths. - Adds
{}value-initialization forMESSAGE_HEADERand related message structs in Linux init/interop communication paths. - Value-initializes a union reply buffer used for reading mixed message types in
binfmt.cpp.
File summaries
| File | Description |
|---|---|
| src/windows/service/exe/WslCoreVm.cpp | Zero-initializes mini_init request messages before setting header/body fields. |
| src/windows/common/interop.cpp | Zero-initializes LX_INIT_PROCESS_EXIT_STATUS messages before sending exit status. |
| src/linux/init/util.cpp | Zero-initializes MESSAGE_HEADER queries sent over the init interop socket. |
| src/linux/init/main.cpp | Zero-initializes mount result message before populating fields and sending. |
| src/linux/init/init.cpp | Zero-initializes session response and process-exit-status message structs before use. |
| src/linux/init/drvfs.cpp | Zero-initializes a MESSAGE_HEADER request used to query elevated drvfs behavior. |
| src/linux/init/binfmt.cpp | Zero-initializes a reply union and window resize message prior to I/O and field assignment. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Backport of #41373 to
release/2.7.Several aggregate message structures were declared without value-initialization before their fields were assigned, leaving unassigned fields and padding indeterminate. This applies the original zero-initialization fix to the message types present in the release branch.
The
TrimDistributionhunk from the original PR is omitted because that function is not present inrelease/2.7.