Re: [RFC] connectat()/bindat() or an alternative design
From: John Ericson <hidden>
Date: 2026-06-23 17:40:30
Hi Cong, Sorry I have taken so long to respond. Rest assured, I still wish to put in the work discussing this and (if there is agreement) implementing it. On Fri, Jun 12, 2026, at 2:50 PM, Cong Wang wrote:
"Nix needs it" is a much better justification than "BSD already has it". :) So please add this to your patch description/cover letter.
Well, to be clear, the motivation goes beyond Nix's immediate needs. I think the Nix ecosystem would be interested in my object capability / "zero trust" experiments that this (and other things) would enable, but this is farther afield.
Just curious: any reason not to use TCP loopback here?
Sending file descriptors over sockets is very important to me, so TCP is ruled out.
Any reason not to use abstract socket?
I wrote a bit about that but perhaps it got buried:
quoted
But I really don't like this because we have just replaced one ambient authority contraption (the root filesystem) with another (the abstract socket name space in the network namespace). The problems with ambient authority remain all the same (and indeed, our experience with Nix has been that network namespace unsharing when you do want to do some outside world network access is much more work than filesystem namespace unsharing).
To make that more concrete, connecting to an abstract socket by name has similar TOCTOU issues. For example, it is possible that the original server disconnected and something else "stole" the name in the meantime. With file descriptors there is no name reuse issue --- the `O_PATH` open file must point to the original socket. I don't want the socket to have to live in the file system *or* the abstract socket namespace. I want it to be truly anonymous, and only referred to by file descriptors. (Also note, the mechanisms described in my last email go further than the original patch's, but also subsume them. If it would be helpful to illustrate exactly what I mean, I would be happy to share a new patch implementing them instead.)
Indeed, it would be very hard to change since it is coded in UDS API since probably day 1.
Just to be clear, I don't consider things so hard to change, because the bad UDS UAPI stuff is rather "cosmetic". "Anonymous listening sockets" (let's call them) can be retrofitted fairly easily, just as abstract sockets were retrofitted fairly easily. Thanks, John