Skip to content

[release/2.7] Make sure that message structures are correctly zero-initialized - #41524

Open
Ben Hillis (benhillis) wants to merge 1 commit into
release/2.7from
backport-41373-release-2.7
Open

[release/2.7] Make sure that message structures are correctly zero-initialized#41524
Ben Hillis (benhillis) wants to merge 1 commit into
release/2.7from
backport-41373-release-2.7

Conversation

@benhillis

Copy link
Copy Markdown
Member

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 TrimDistribution hunk from the original PR is omitted because that function is not present in release/2.7.

)

* 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
Copilot AI lite review requested due to automatic review settings September 4, 2026 16:32
@benhillis
Ben Hillis (benhillis) requested a review from a team as a code owner September 4, 2026 16:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 several LX_* message structs in Windows service VM code paths.
  • Adds {} value-initialization for MESSAGE_HEADER and 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.

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.

2 participants