Repository navigation
Restore the logic to re-create the WSL binfmt_misc entry if it's overriden by systemd-binfmt - #41780
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 1
Open (3)
The generated unit content forExecStopPostappears malformed in two ways: (1)$$SERVICE_RESULT… · New The comment says “ExecStop is required…”, but the generated override setsExecStop=(empty) which… · New This assertion hard-codes a newline of\n, while earlier in the same testcmd.exeoutput is… · New
What changed in this PR
Restores WSL’s protection of its binfmt_misc entry when systemd-managed binfmt services override it, and adds coverage to validate interop remains functional across systemd-binfmt lifecycle events.
Changes:
- Add a Windows unit test that exercises systemd-binfmt overrides/restarts and validates
WSLInteropis restored. - Reintroduce/initiate generation of systemd override drop-ins to re-register WSL’s binfmt handler when it’s replaced.
- Gate the behavior behind
wsl.confoptions (boot.protectBinfmtand interop enablement).
| File | Description |
|---|---|
| test/windows/UnitTests.cpp | Adds a new test validating binfmt restoration and interop stability across systemd-binfmt events. |
| src/linux/init/init.cpp | Adds config parsing and generates systemd drop-in overrides to restore WSL’s binfmt registration. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| [Service] | ||
| ExecStop= | ||
| ExecStartPost=/bin/sh -c '{0}' | ||
| ExecStopPost=/bin/sh -c 'if [ "$$SERVICE_RESULT" != "success" ]; then {0}; fi')", |
Collaborator
Author
There was a problem hiding this comment.
Ben Hillis (benhillis)
approved these changes
Oct 2, 2026
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 change is a partial revert of https://github.com/microsoft/WSL/pull/40621/changes, to restore the logic to re-create our binfmt_misc entry if something like mono overrides it.
While working on this, I noticed that the read-only mount actually causes the systemd-binfmt unit to fail to start, but that's a pre-existing issue so we can investigate that in a separate change
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed