Fix batch of minor issues - #41397
Open
Feng Wang (chemwolf6922) wants to merge 8 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR batches several targeted correctness and security hardening fixes across WSL’s Linux init and Windows client/service components, and adds/updates Windows unit tests to validate the behavior.
Changes:
- Hardened input/file handling on the Linux init side (sockaddr length validation; avoid clobbering symlink targets when creating the mini-init mount point).
- Tightened Windows CLI behavior (reject multiple export formats; avoid command injection when resolving
--manage --set-default-user). - Fixed service/network lifecycle issues (persist guest network service VM ID; ensure network endpoint move-assignment deletes the replaced endpoint to avoid leaking HNS endpoints).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/UnitTests.cpp | Adds regression coverage for invalid export format combinations and --set-default-user injection attempts. |
| src/windows/service/exe/WslCoreNetworkEndpoint.h | Adds explicit move-assignment to delete the replaced HNS endpoint and prevent endpoint leaks. |
| src/windows/service/exe/WslCoreGuestNetworkService.cpp | Stores VM ID after guest network service creation so deletion uses the correct identifier. |
| src/windows/common/WslClient.cpp | Uses std::popcount to reject multiple export format flags; switches --set-default-user UID lookup to argv-safe command line construction. |
| src/windows/common/precomp.h | Adds <bit> for std::popcount. |
| src/linux/init/main.cpp | Prevents symlink target overwrite by unlinking the target then using O_EXCL create for the init mount target. |
| src/linux/init/GnsPortTracker.cpp | Rejects oversized sockaddr lengths to avoid oversized allocations from malicious inputs. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Blue (OneBlue)
previously approved these changes
Aug 20, 2026
Blue (OneBlue)
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, feel free to address comments in a followup
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.
Summary of the Pull Request
This PR fixes batch of minor issues found during AI code review.
src/linux/init/GnsPortTracker.cpp: 378
Fixed oversized socket-address allocations from malicious inputs.
src/linux/init/main.cpp: 2173
Fixed mini init overwriting a distribution symlink target.
src/windows/common/WslClient.cpp: 259
src/windows/common/precomp.h: 100
test/windows/UnitTests.cpp: 172
Fixed conflicting export formats being accepted together.
src/windows/common/WslClient.cpp: 928
test/windows/UnitTests.cpp: 4371
Fixed command injection through --set-default-user.
src/windows/service/exe/WslCoreGuestNetworkService.cpp: 95
Fixed the guest network service VM ID not being stored.
src/windows/service/exe/WslCoreNetworkEndpoint.h: 20
Fixed network endpoint move assignment leaking the replaced endpoint.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Update tests:
UnitTests::ExportDistro
UnitTests::ManageDefaultUid