ocaml-uring icon indicating copy to clipboard operation
ocaml-uring copied to clipboard

FD passing `sendmsg` fails on WSL2

Open patricoferris opened this issue 3 years ago • 2 comments

At the moment using the latest WSL kernel, the fd passing sendmsg examples are failing with EINVAL. Not sure if this is an issue in the C stubs or something quirky with WSL.

┌──────────────────────────────────────────────────────────────────────────────┐
│ [FAIL]        uring         12   send_msg.                                   │
└──────────────────────────────────────────────────────────────────────────────┘
File "ocaml-uring/tests/main.ml", line 387, character 13:

   Expected: `2'
   Received: `-22'

patricoferris avatar Mar 16 '22 15:03 patricoferris

https://github.com/Microsoft/WSL/issues/514 says:

We currently only have a support for passing just one file descriptor at a time via unix sockets. [...] Just FYI that this should be fixed in 15042.

Maybe that's the problem?

talex5 avatar Aug 25 '22 10:08 talex5

AFAICT, this functionality was broken on Linux proper too, at least for a while. Here's what I can make of this:

  • The original IORING_OP_SENDMSG implementation shipped in Linux 5.3 was found to have a security vulnerability related to SCM_CREDENTIALS ancillary data: https://bugs.chromium.org/p/project-zero/issues/detail?id=1975
  • As a first fix, ancillary data was banned altogether in Linux 5.4.2: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d69e07793f891524c6bbf1e75b9ae69db4450953
  • After some discussion, ancillary data was allowed again, but only "plain data", not fds in Linux 5.10: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/net/socket.c?id=583bbf0624dfd8fc45f1049be1d4980be59451ff
  • In Linux 5.12, the way the io_uring worker tasks get their creds was reworked, so the restriction could be dropped altogether: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e54937963fa249595824439dc839c948188dea83

@patricoferris when you opened this issue, the latest kernel for WSL2 was 5.10.93.2 in which fd passing was still banned. By now, you can get 5.15 kernels for WSL2. Can you try it with that?

whentze avatar Dec 30 '22 00:12 whentze