Fix minor issues found during code review#41104
Open
chemwolf6922 wants to merge 10 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a set of small correctness and robustness issues across both the Linux init components and the Windows VM/service code paths, plus adds a regression test for invalid wsl --mount --name values.
Changes:
- Tighten validation and fix revert/cleanup logic around disk attach/mount and VHD move operations (Windows service).
- Improve robustness of Linux init execution and SIGCHLD handling (drain
waitpid, fix exec-result read condition, avoid offset overflow). - Add a Windows mount regression test for invalid mount names.
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/MountTests.cpp | Adds a new test for invalid --mount --name inputs. |
| src/windows/service/exe/WslCoreVm.cpp | Fixes disk online revert behavior and blocks additional invalid mount names. |
| src/windows/service/exe/LxssUserSession.cpp | Fixes execution context ordering and ensures VHD revert is not skipped on ownership failure. |
| src/windows/common/WslCoreMessageQueue.h | Adjusts threadpool work submission placement to reduce a submit/cancel race. |
| src/linux/init/util.cpp | Fixes an incorrect condition when interpreting exec-status pipe reads. |
| src/linux/init/init.cpp | Drains pending SIGCHLD children to avoid missing coalesced signals. |
| src/linux/init/DnsServer.h | Changes request-offset type to avoid potential overflow for valid TCP DNS requests. |
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 a batch of minor issues found during AI code review.
src/linux/init/DnsServer.h:48Change the data type from uint16_t to size_t to avoid a potential counter overflow on valid data. As the counter needs to hold at most 2 + 65535.
src/linux/init/init.cpp:2575Drain the pending pids on SIGCHLD. Multiple SIGCHLD will only trigger the signalfd once if not processed fast enough:
https://man7.org/linux/man-pages/man7/signal.7.html
src/linux/init/util.cpp:3497Fix a wrong condition. The old logic will mask most of the errors as EINVAL.
src/windows/common/WslCoreMessageQueue.h:174Avoid a tight race condition between submit and cancel on m_tpHandle.
src/windows/service/exe/LxssUserSession.cpp:897Avoid wrong context order. The order is asserted in debug builds. The old wrong MountDisk -> CreateVm context will crash the debug service.
src/windows/service/exe/LxssUserSession.cpp:980Put the set owner after the revert. So, a failed set owner does not skip the revert.
src/windows/service/exe/WslCoreVm.cpp:1003Fix a wrong revert logic. Where the disk will be reverted to offline if it was online.
src/windows/service/exe/WslCoreVm.cpp:2755Block more invalid mount names.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Add test:
MountTests::MountTests::SpecifyInvalidMountName