Prevent binfmt_misc unmount propagation across distros#40614
Conversation
There was a problem hiding this comment.
Pull request overview
This PR is a minimal backport for the 2.7 release branch to prevent binfmt_misc unmount propagation across distros, which can otherwise clear global binfmt registrations and break Windows interop (Exec format error) when a peer systemd-enabled distro shuts down.
Changes:
- Mark the
binfmt_miscmount asMS_PRIVATEafter mounting to isolate it from peer namespace unmount propagation. - Add a WSL2 regression test that imports a peer distro, enables systemd, terminates it, and validates interop/binfmt state survives.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/linux/init/main.cpp |
Marks the binfmt_misc mount private to prevent shutdown unmount propagation from affecting other distros. |
test/windows/UnitTests.cpp |
Adds a regression test intended to validate interop survives a peer systemd distro termination. |
When multiple WSL2 distros share a VM, binfmt_misc inherits shared mount propagation from /proc. If a peer distro running systemd shuts down, its final unmount of binfmt_misc propagates back through the shared peer group to the init namespace, destroying all interop registrations globally and causing 'Exec format error' for every running distro. Mark binfmt_misc as MS_PRIVATE immediately after mounting so that child namespace unmounts are isolated and cannot propagate back. Fixes #13885 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
15c5dac to
5ee1442
Compare
|
Closing in favor of #14443, which is the correct fix and has CI passing. Our MS_PRIVATE approach was wrong: binfmt_misc entries are scoped per user-namespace (or effectively global), not per mount-namespace. WSL peer distros share the root user-ns (no CLONE_NEWUSER), so peer's Once #14443 merges to master, we'll do a clean cherry-pick backport to release/2.7. |
Summary
Minimal cherry-pick of #40612 for the 2.7 release branch.
Fixes an
Exec format errorbug where Windows interop breaks in all running distros when a peer distro with systemd shuts down.Root Cause
/procis mounted withMS_SHARED, sobinfmt_miscinherits shared mount propagation. When a peer distro's systemd shuts down and unmountsbinfmt_miscin its namespace, the unmount propagates back through the shared peer group to init's namespace, wiping ALL registrations globally.Fix
One additional
mount()call withMS_PRIVATEimmediately after mounting binfmt_misc. This is the minimal version — the master branch PR also extendsUtilMountto handle propagation flags generically.PR Checklist
InteropSurvivesPeerDistroShutdown)Fixes #13885