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

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

Open
conioh opened this issue Sep 21, 2020 · 9 comments
Open

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

conioh opened this issue Sep 21, 2020 · 9 comments
Labels

Comments

@conioh
Copy link

conioh commented Sep 21, 2020

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

@therealkenc
Copy link
Collaborator

image

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

@conioh
Copy link
Author

conioh commented Sep 21, 2020

@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.

@ivan046
Copy link

ivan046 commented Nov 5, 2020

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

@conioh
Copy link
Author

conioh commented Nov 21, 2020

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

@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.

@conioh
Copy link
Author

conioh commented Dec 8, 2022

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.

@magoerlich
Copy link

magoerlich commented Feb 19, 2024

Another 2 years later...
RollingToasterGIF (2)

@maartenvanmalland
Copy link

Isn't this fixed now..see https://github.com/microsoft/WSL/releases/tag/2.0.14 ?

@magoerlich
Copy link

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

@iongion
Copy link

iongion commented Sep 29, 2024

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
Labels
Projects
None yet
Development

No branches or pull requests

6 participants