Skip to content

Windows/WSL AF_UNIX Interop doesn't work in WSL2 #5961

Description

@conioh

Environment

Windows build number: 10.0.19041.508
Your Distribution version: Ubuntu 18.04
Whether the issue is on WSL 2 and/or WSL 1: Regression in WSL2

Steps to reproduce

  1. Launch Ubuntu 18.04 in WSL2.
  2. Run python3 -c "import socket; sock = socket.socket(socket.AF_UNIX); sock.bind('/mnt/d/test.sock')"

python_unix_socket.strace.txt

WSL logs:
https://aka.ms/AA9q0yn

Expected behavior

As In WSL1, I expect no error and the D:\test.sock file created:

image

Actual behavior

Error and no file created:

image

Activity

  1. therealkenc commented on Sep 21, 2020

    @therealkenc

    image

    Ref #4240 (message) but that is a different ask for abstract.

  2. conioh commented on Sep 21, 2020

    @conioh
    Author

    therealkenc Thanks for pointing me to the comment. I've seen the issue but didn't go through all the comments as the issue itself was limited to abstract addresses.

    I'm no expert but I see no obvious reason why the enlightened WSL kernel shouldn't be able to communicate with the host and afunix.sys would handle these files on the host too.

    Since I'm interested in existing binaries, using AF_INET (or anything else that requires source change) doesn't help me. I used Python just because it was easier to reproduce. Even if it did, I opened this issue for the broader issue and not just to solve my problem with this or that program.

    At one point I even considered a temporary solution of hooking both sides and using AF_HYPERV as the underlying transport, but it requires some work and by the time I'm done you might just implement the real deal.

  3. ivan046 commented on Nov 5, 2020

    @ivan046

    conioh did you get a chance to enable AF_UNIX in WSL2 ?

  4. conioh commented on Nov 21, 2020

    @conioh
    Author

    conioh did you get a chance to enable AF_UNIX in WSL2 ?

    Ivan Pashin (@ivan046), unfortunately I haven't. It's not a matter of simply enabling something. I'd have to multiplex multiple UNIX socket connections over a VSOCK connection. It's not that simple and it wasn't important enough yet. For specific cases there may be simple workarounds like using netcat/socat.

  5. conioh commented on Dec 8, 2022

    @conioh
    Author

    Now that the official way to install WSL means install only WSL2, it is a good time to ask again support for AF_UNIX interop with WSL2.

    Sure, WSL1 isn't deprecated and "we currently have no plans to deprecate WSL 1", but we all know what that means:

    image

    There's no reason to treat WSL2 as a second-class citizen, especially since Microsoft is promoting it so much and since implementing it is basically the same as the current implementation, just with a different enlightenment on the Linux kernel side.

  6. magoerlich commented on Feb 19, 2024

    @magoerlich

    Another 2 years later...
    RollingToasterGIF (2)

  7. maartenvanmalland commented on Feb 20, 2024

    @maartenvanmalland
  8. magoerlich commented on Feb 20, 2024

    @magoerlich

    Latest Version i can get from the store is 2.0.9.0

    psh ❯ wsl -v -l
    WSL-Version: 2.0.9.0
    Kernelversion: 5.15.133.1-1
    WSLg-Version: 1.0.59
    MSRDC-Version: 1.2.4677
    Direct3D-Version: 1.611.1-81528511
    DXCore-Version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
    Windows-Version: 10.0.22631.3155
    
    psh ❯ wsl
    
    zsh ❯ python3 -c "import socket; sock = socket.socket(socket.AF_UNIX); sock.bind('/mnt/c/test.sock')"
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    OSError: [Errno 95] Operation not supported
    
  9. iongion commented on Sep 29, 2024

    @iongion

    Are there any recommendations to this ? Some mitigations ? I am trying to relay unix sockets to named pipes, but I have to spawn an additional program and use its stdin and stdout, even that is difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions