Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Genie 2.4 breaks WSL interop on Windows 10 #287

Closed
1 task done
Elberet opened this issue Jun 29, 2022 · 7 comments
Closed
1 task done

Genie 2.4 breaks WSL interop on Windows 10 #287

Elberet opened this issue Jun 29, 2022 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@Elberet
Copy link

Elberet commented Jun 29, 2022

Windows version (build number): Windows 10 21H2 (19044.1766)

Linux distribution: Ubuntu 20.04

Kernel version: 5.10.102.1-microsoft-standard-WSL2

Genie version: genie 2.4

Describe the bug
Genie 2.4 by default installs /usr/lib/binfmt.d/WSLInterop.conf. This file is used by systemd to register the miscellaneous binary wrapper for WSL interop in the kernel. The registration includes a set of flags that tell the kernel how to interact with the wrapper. At least for my local Windows machine, these flags are wrong and result in WSL Linux becoming unable to launch any Windows binaries through the WSL /init wrapper.

To Reproduce
Steps to reproduce the behavior:

  1. Create new WSL space:
    wsl --unregister Ubuntu-20.04
    wsl --install -d Ubuntu-20.04
    
  2. Install genie (wsl -u root or sudo su -):
    curl -Ls -o /etc/apt/trusted.gpg.d/wsl-transdebian.gpg "https://arkane-systems.github.io/wsl-transdebian/apt/wsl-transdebian.gpg"
    echo "deb https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main" >/etc/apt/sources.list.d/wsl-transdebian.list
    echo "deb-src https://arkane-systems.github.io/wsl-transdebian/apt/ $(lsb_release -cs) main" >>/etc/apt/sources.list.d/wsl-transdebian.list
    ssh-keygen -A
    awk -i inplace '($2=="/" && /^[^#]/){ print "#"$0; next } 1' /etc/fstab
    systemctl mask getty.target
    systemctl mask multipathd.service
    systemctl mask multipathd.socket
    systemctl mask apport-forward.
    systemctl mask iscsid.socket
    systemctl mask apport-autoreport.path
    systemctl mask systemd-modules-load.service
    systemctl set-default multi-user.target
    systemctl disable sshd.service
    systemctl disable ModemManager.service
    systemctl disable ufw.service
    systemctl disable apport.service
    systemctl disable unattended-upgrades.service
    apt-get update && apt-get install -y systemd-genie
    
  3. Check WSL interop binfmt_misc configuration:
    # genie -b
    no-bottle
    # cat /proc/sys/fs/binfmt_misc/WSLInterop
    enabled
    interpreter /tools/init
    flags: F
    offset 0
    magic 4d5a
    
  4. Start genie and repeat above:
    # genie -s
    Waiting for systemd....!!
    # genie -b
    inside
    # cat /proc/sys/fs/binfmt_misc/WSLInterop
    enabled
    interpreter /init
    flags: PF
    offset 0
    magic 4d5a
    
    Note that the flags have changed.
  5. Attempt to run any Windows binary from within WSL:
    $ genie -b
    inside
    $ /mnt/c/Windows/System32/reg.exe "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Nls\\CodePage"
    FEHLER: Ungültiges Argument/Option - '/mnt/c/Windows/System32/reg.exe'.
    Geben Sie "REG /?" ein, um die Syntax anzuzeigen.
    
    Due to the altered binfmt flags, reg.exe ended up being called with the Linux argv[0] as an additional command line argument, preceding the expected arguments, and failed with an error message.

Expected behavior
Genie should not break WSL interop. Specifically, if the binfmt misc configuration depends on the Windows version, Genie should detect the version it is running on and adjust the binfmt configuration to match. If the Windows version is not or no longer supported, Genie should at least emit a noticeable warning.

Additional context
The change to /usr/lib/binfmt.d/WSLInterop.conf was introduced in response to #267, where a user on Windows 10.0.22598.200 reported a problem with WSL interop. Build 22598 is a Windows 11 insider preview build, not a full release.

I confirm that I have read the ENTIRE supplied readme file and checked for relevant information on the repository wiki before raising this issue, and that if the solution to this issue is found in either location, it will be closed without further comment:

  • Yes.
@Elberet Elberet added the bug Something isn't working label Jun 29, 2022
@Elberet
Copy link
Author

Elberet commented Jun 29, 2022

I just noticed #264. Apparently, the binfmt wrapper's behaviour is inconsistent between Windows 10 and release versions of Windows 11, not just insider previews. So for Windows 10 users (like myself, because my perfectly good i7 7700K is not recent enough for Windows 11 😖), the change introduced in ebca3e3 straight up breaks WSL, while it is absolutely required on Windows 11...

@denskh
Copy link

denskh commented Jun 30, 2022

Manual update of /usr/lib/binfmt.d/WSLInterop.conf to revert change mentioned above seems to fix issue on Win10/Debian.

@NotTheDr01ds
Copy link

NotTheDr01ds commented Jul 17, 2022

@Elberet Not that it has anything to do with your issue, but I'm curious about the following in your installation procedure:

systemctl mask apport-forward.

Where does that come from? I see the same in another bug report, but is that the correct syntax? Shouldn't it be?

systemctl mask apport-forward.socket
# or
systemctl mask apport-forward@

The line as it is creates:

/etc/systemd/system/apport-forward..service -> /dev/null

With double-dots, which doesn't seem correct, right?

@Elberet
Copy link
Author

Elberet commented Jul 17, 2022

You're right, that's probably a simple typo in my script. It shouldn't have any effect on the interop issue, tho.

@YenLegion
Copy link

Trying to parse this, so to fix /usr/lib/binfmt.d/WSLInterop.conf is set with P or PF?

@Elberet
Copy link
Author

Elberet commented Jul 31, 2022

The correct set of flags depends on the Windows version:

  • Windows 10 21H2 requires F.
  • Windows 11 requires PF.

Genie 2.4 now defaults to PF. If you are running Windows 10, set the flags field in /usr/lib/binfmt.d/WSLInterop.conf to F.

The reason for this difference is that the behaviour of the WSL helper binary (/init) changes. It is not known exactly when that change was or will be introduced, only that it's sometime between Windows versions 19044.1826 (mine) and 22598.200 (as per #267).

A full explanation of what these flags mean can be found at https://www.kernel.org/doc/Documentation/admin-guide/binfmt-misc.rst.

@cerebrate
Copy link
Member

Fixed in 2.5, shipping as soon as a psutil issue is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants