Skip to content

Restore the logic to re-create the WSL binfmt_misc entry if it's overriden by systemd-binfmt - #41780

Merged
Blue (OneBlue) merged 1 commit into
masterfrom
user/oneblue/fix-binfmt-fallback
Oct 3, 2026
Merged

Blue (OneBlue) merged 1 commit into
masterfrom
user/oneblue/fix-binfmt-fallback

Conversation

@OneBlue

Copy link
Copy Markdown
Collaborator

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

@OneBlue
Blue (OneBlue) requested a review from a team as a code owner October 2, 2026 21:52
Copilot AI balanced review requested due to automatic review settings October 2, 2026 21:52

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.

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 High severity · 2 Medium severity

Open (3)
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 WSLInterop is 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.conf options (boot.protectBinfmt and 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.

Comment thread src/linux/init/init.cpp
[Service]
ExecStop=
ExecStartPost=/bin/sh -c '{0}'
ExecStopPost=/bin/sh -c 'if [ "$$SERVICE_RESULT" != "success" ]; then {0}; fi')",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Comment thread src/linux/init/init.cpp
Comment thread test/windows/UnitTests.cpp
@OneBlue
Blue (OneBlue) merged commit 0dc1bc1 into master Oct 3, 2026
12 checks passed
@OneBlue
Blue (OneBlue) deleted the user/oneblue/fix-binfmt-fallback branch October 3, 2026 00:10
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.

3 participants