public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* pasta: patches for --pass-fds (fix) and --ready-fd (new)
@ 2026-11-23 22:11 Lisanna Dettwyler
  2026-11-24 18:20 ` Stefano Brivio
  0 siblings, 1 reply; 11+ messages in thread
From: Lisanna Dettwyler @ 2026-11-23 22:11 UTC (permalink / raw)
  To: passt-dev; +Cc: pennae, raito, sergei

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

Hello!

I have a couple patches that makes pasta easier for us to use. --ready-fd
allows us to wait on fd activity rather than sleep polling with an ioctl
(we do not want to let pasta daemonize itself). --pass-fds is fixed to
allow opening namespaces by inherited parent fd.

https://github.com/lisanna-dettwyler/passt/compare/master...dev-nix

Please let me know if these can be merged! We are interested as both
https://nixos.org and https://lix.systems/

Thanks,
Lisanna

[-- Attachment #2: Type: text/html, Size: 823 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: pasta: patches for --pass-fds (fix) and --ready-fd (new)
  2026-11-23 22:11 pasta: patches for --pass-fds (fix) and --ready-fd (new) Lisanna Dettwyler
@ 2026-11-24 18:20 ` Stefano Brivio
  2026-11-24 18:46   ` Sergei Zimmerman
  2026-11-26 19:04   ` eldritch horrors
  0 siblings, 2 replies; 11+ messages in thread
From: Stefano Brivio @ 2026-11-24 18:20 UTC (permalink / raw)
  To: Lisanna Dettwyler; +Cc: passt-dev, pennae, raito, sergei

Hi Lisanna,

On Mon, 23 Nov 2026 17:11:39 -0500
Lisanna Dettwyler <lisanna.dettwyler@gmail.com> wrote:

> Hello!
> 
> I have a couple patches that makes pasta easier for us to use.

...and that's indeed a relevant goal for passt as a project, by all
means, but I still have some questions about this:

> --ready-fd
> allows us to wait on fd activity rather than sleep polling with an ioctl
> (we do not want to let pasta daemonize itself). --pass-fds is fixed to
> allow opening namespaces by inherited parent fd.
> 
> https://github.com/lisanna-dettwyler/passt/compare/master...dev-nix

We discussed about this some months ago, remember?

  https://archives.passt.top/passt-dev/CAC-VXLYqvXu+yHsM=DUt-7MSGp_+o8Wt5zgGYzi1gdNvtoRK-A@mail.gmail.com/

...and at that point it looked like you could just let pasta do its job
and daemonise itself, but there were some residual issues with
capabilities you were investigating.

Did you find out anything else?  Is there another way we can fix this?

My concerns from back then remain.  I would like to keep pasta's
interfaces as simple, limited, conventional, and boring as possible,
for ease of auditing and also for the sake of LSM policies, and the
current model just works for Podman and moby / rootlesskit.

> Please let me know if these can be merged! We are interested as both
> https://nixos.org and https://lix.systems/

If this is the only way you can fix things up, sure... but there seemed
to be hope?

-- 
Stefano


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: pasta: patches for --pass-fds (fix) and --ready-fd (new)
  2026-11-24 18:20 ` Stefano Brivio
@ 2026-11-24 18:46   ` Sergei Zimmerman
  2026-11-24 21:32     ` Stefano Brivio
  2026-11-26 19:04   ` eldritch horrors
  1 sibling, 1 reply; 11+ messages in thread
From: Sergei Zimmerman @ 2026-11-24 18:46 UTC (permalink / raw)
  To: Stefano Brivio; +Cc: Lisanna Dettwyler, passt-dev, pennae, raito

> and at that point it looked like you could just let pasta do its job
and daemonise itself

Forgive me if I’m slightly incorrect on the details, but here’s the simplification that can be done in the lix build launcher: https://gerrit.lix.systems/c/lix/+/6897

There’s several arguments I see for the ready pipe:

* Asynchronous waiting for the child exit is painful without pidfd. This seems relevant for lix.

* The setup completion is waited upon in another child process of lix while the parent that spawned pasta goes off on its merry way, so I’m not even sure you *could* wait for the daemonization to complete in this process setup? I’d need to brush up on pidfd polling and whether it can work around wait4 limiting you to child processes.

As for the other commit, fd inheritance seems like a useful simplification. Closing leaked FDs is the parent’s responsibility that cppnix and lix* already handle so whatever is inherited is done intentionally.

Best regards,
Sergei

-------- Original Message --------
On Tuesday, 11/24/26 at 22:20 Stefano Brivio <sbrivio@redhat.com> wrote:
Hi Lisanna,

On Mon, 23 Nov 2026 17:11:39 -0500
Lisanna Dettwyler <lisanna.dettwyler@gmail.com> wrote:

> Hello!
>
> I have a couple patches that makes pasta easier for us to use.

...and that's indeed a relevant goal for passt as a project, by all
means, but I still have some questions about this:

> --ready-fd
> allows us to wait on fd activity rather than sleep polling with an ioctl
> (we do not want to let pasta daemonize itself). --pass-fds is fixed to
> allow opening namespaces by inherited parent fd.
>
> https://github.com/lisanna-dettwyler/passt/compare/master...dev-nix

We discussed about this some months ago, remember?

  https://archives.passt.top/passt-dev/CAC-VXLYqvXu+yHsM=DUt-7MSGp_+o8Wt5zgGYzi1gdNvtoRK-A@mail.gmail.com/

...and at that point it looked like you could just let pasta do its job
and daemonise itself, but there were some residual issues with
capabilities you were investigating.

Did you find out anything else?  Is there another way we can fix this?

My concerns from back then remain.  I would like to keep pasta's
interfaces as simple, limited, conventional, and boring as possible,
for ease of auditing and also for the sake of LSM policies, and the
current model just works for Podman and moby / rootlesskit.

> Please let me know if these can be merged! We are interested as both
> https://nixos.org and https://lix.systems/

If this is the only way you can fix things up, sure... but there seemed
to be hope?

--
Stefano


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: pasta: patches for --pass-fds (fix) and --ready-fd (new)
  2026-11-24 18:46   ` Sergei Zimmerman
@ 2026-11-24 21:32     ` Stefano Brivio
  0 siblings, 0 replies; 11+ messages in thread
From: Stefano Brivio @ 2026-11-24 21:32 UTC (permalink / raw)
  To: Sergei Zimmerman; +Cc: Lisanna Dettwyler, passt-dev, pennae, raito

On Tue, 24 Nov 2026 18:46:29 +0000
Sergei Zimmerman <sergei@zimmerman.foo> wrote:

> > and at that point it looked like you could just let pasta do its job  
> > and daemonise itself
> 
> Forgive me if I’m slightly incorrect on the details, but here’s the
> simplification that can be done in the lix build launcher:
> https://gerrit.lix.systems/c/lix/+/6897

Sure, I understand that's a significant simplification.  It's the same
as what we discussed back in June, though.

I'm just suggesting that you can get the same simplification by letting
pasta do its course, that is, drop the '--foreground' option, and it
will behave like all regular UNIX daemons do: it forks to background
once it's ready, and not a moment before:

  https://archives.passt.top/passt-dev/cbe5ab63-3266-4234-8745-5a6583039809@redhat.com/

  https://archives.passt.top/passt-dev/20260527213924.2586bca5@elisabeth/

No reason for a side channel just because slirp4netns had it.  And yes,
Podman used to do that too, but eventually I convinced them to fix that.
:)

When you're done with the namespace, you don't need to track pasta at
all: just remove the namespace handle, and pasta goes away.

I saw the "We don't let it daemonize itself for process managements
reasons" comment, it was the same in June, but when Lisanna checked it
appeared to be a left-over.  Or at least we couldn't figure out what
those particular "process managements reason" were.

If you want something explicit for corner cases, though:

> There’s several arguments I see for the ready pipe:
> 
> * Asynchronous waiting for the child exit is painful without pidfd.
>   This seems relevant for lix.

...we discussed providing a pidfd for some particular use cases in
Podman as well.  All pasta can do (on top of automatic exit) is to
write a PID file, but it's racy, strictly speaking.

If that solves a problem for Lix as well, let's implement that
instead.

This --ready-fd option scares me enough (both in terms of letting
something "wrong" slip in now, as well as hours of fun with AppArmor /
SELinux once others start using it) that I'd rather be inclined in
investing a bit of time in the pidfd thing myself.

Of course, I don't want to force that option if it's really not
suitable for your purposes... but perhaps it is?

> * The setup completion is waited upon in another child process of lix
>   while the parent that spawned pasta goes off on its merry way, so I’m
>   not even sure you *could* wait for the daemonization to complete in
>   this process setup?

Just fork(), exec(), and wait for the child to exit before proceeding,
instead of keeping a separate child process around implementing more
specific synchronisation.  Even with a file descriptor indicating
readiness, you would need to wait anyway, right?

>   I’d need to brush up on pidfd polling and whether
>   it can work around wait4 limiting you to child processes.

I think you could still use wait4() or similar.

> As for the other commit, fd inheritance seems like a useful
> simplification. Closing leaked FDs is the parent’s responsibility that
> cppnix and lix* already handle so whatever is inherited is done
> intentionally.

Until you forget to do that, and then it's our responsibility. :) And
even if it's not, it risks getting catastrophically bad.

I mean, if people want to run Bubblewrap *inside* pasta, ouch... but
fine, there I understand the need to pass file descriptors down to the
spawned command.

But if you don't need to let pasta spawn any command, if the only
purpose is to pass a network namespace without using a filesystem path,
then give pasta your PID?  Wouldn't that work?

If, for some reason I'm missing, you really need to pass the namespace
as file descriptor, I'd rather implement that as a special option that
only applies to network namespaces and nothing else, and keep closing
any (otherwise) leaked file descriptor.

I really would like to avoid the risk of having anything unnecessary
and potentially dangerous in pasta's descriptor table, *if possible*.

-- 
Stefano

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: pasta: patches for --pass-fds (fix) and --ready-fd (new)
  2026-11-24 18:20 ` Stefano Brivio
  2026-11-24 18:46   ` Sergei Zimmerman
@ 2026-11-26 19:04   ` eldritch horrors
  2026-11-27 22:25     ` Stefano Brivio
  1 sibling, 1 reply; 11+ messages in thread
From: eldritch horrors @ 2026-11-26 19:04 UTC (permalink / raw)
  To: Stefano Brivio, Lisanna Dettwyler; +Cc: passt-dev, raito, sergei

hi,

On 24/11/2026 19:20, Stefano Brivio wrote:
> ...and at that point it looked like you could just let pasta do its job
> and daemonise itself, but there were some residual issues with
> capabilities you were investigating.
> 
> Did you find out anything else?  Is there another way we can fix this?
> 
> My concerns from back then remain.  I would like to keep pasta's
> interfaces as simple, limited, conventional, and boring as possible,
> for ease of auditing and also for the sake of LSM policies, and the
> current model just works for Podman and moby / rootlesskit.

that just doesn't seem to work for us. we can't pass a PID for pasta to 
pull namespaces from because it'll fail to adopt user namespaces when 
run with non-root credentials. we can't pass procfs paths to namespace 
descriptors on other processes because pasta can't even open them in 
that case for some reason? when running pasta with high capabilities and 
letting it drop privs this works reasonably well, but we must also 
support unprivileged instances with user namespaces. some sort of fd 
passing seems to be essential to make our use case work at all.

we also need to tear down pasta *quickly* once our processes using the 
isolated network terminate. we can run hundreds of them per second, 
leaving pasta instances around until they find the namespace gone is the 
kind of drain on resources our scheduler wants to avoid, and on highly 
loaded system we can't even guarantee that any given pasta instance can 
check whether its namespaces are still live in any reasonable amount of 
time. we could probably get around *that* by shoving pasta into a fresh 
pid namespace under a manager as pid1, then killing that manager and 
having the manager wait for pasta to fork.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: pasta: patches for --pass-fds (fix) and --ready-fd (new)
  2026-11-26 19:04   ` eldritch horrors
@ 2026-11-27 22:25     ` Stefano Brivio
  2026-11-29 20:11       ` eldritch horrors
  0 siblings, 1 reply; 11+ messages in thread
From: Stefano Brivio @ 2026-11-27 22:25 UTC (permalink / raw)
  To: eldritch horrors
  Cc: Lisanna Dettwyler, passt-dev, raito, sergei, Paul Holzinger

[Cc'ing Paul who knows better how Podman does some of this]

Hi,

Thanks for the details, that starts looking like a more precise list of
requirements.  Some comments and some questions for now:

On Thu, 26 Nov 2026 20:04:34 +0100
eldritch horrors <pennae@lix.systems> wrote:

> hi,
> 
> On 24/11/2026 19:20, Stefano Brivio wrote:
> > ...and at that point it looked like you could just let pasta do its job
> > and daemonise itself, but there were some residual issues with
> > capabilities you were investigating.
> > 
> > Did you find out anything else?  Is there another way we can fix this?
> > 
> > My concerns from back then remain.  I would like to keep pasta's
> > interfaces as simple, limited, conventional, and boring as possible,
> > for ease of auditing and also for the sake of LSM policies, and the
> > current model just works for Podman and moby / rootlesskit.  
> 
> that just doesn't seem to work for us. we can't pass a PID for pasta to 
> pull namespaces from because it'll fail to adopt user namespaces when 
> run with non-root credentials.

I think we had some issue with this at some point, it works for me now,
but I have a vague memory of another use case (probably Buildah?) where
this wasn't a possibility at all.  I tried both:

- detaching user and network namespaces first, then joining them from
  pasta (I guess that would be the case for Nix / Lix?):

  $ unshare -rUn
  # echo $$
  1090417

  [from another terminal]
  $ pasta -f --config-net 1090417
  Template interface: enp9s0 (IPv4), enp9s0 (IPv6)
  [...]

- detaching just a user namespace first, running pasta from there, and
  having it detach the network namespace:

  $ unshare -rU
  # ./pasta --config-net --netns-only -- ping -qc1 2600::
  PING 2600:: (2600::) 56 data bytes
  
  --- 2600:: ping statistics ---
  1 packets transmitted, 1 received, 0% packet loss, time 0ms
  rtt min/avg/max/mdev = 35.498/35.498/35.498/0.000 ms

If this doesn't work for you for some reason:

> we can't pass procfs paths to namespace 
> descriptors on other processes because pasta can't even open them in 
> that case for some reason?

...this is what Buildah or podman-build do.  We had an issue with
SELinux recently:

  e74a7c2c1824 ("selinux: Access to netns for podman-build, read access for netns in general")

and one with inotify a couple of years ago:

  ff22a78d7b52 ("pasta: Don't try to watch namespaces in procfs with inotify, use timer instead")

but it should all be solved now.  Do you happen to remember the
issue you were getting with this?

> when running pasta with high capabilities and 
> letting it drop privs this works reasonably well,

Ouch, definitely not the intended usage.

> but we must also 
> support unprivileged instances with user namespaces.

Right, yes, absolutely.

> some sort of fd 
> passing seems to be essential to make our use case work at all.

If this is needed anyway: I'd suggest that instead of using --pass-fds
for that (and changing it as Lisanna's patch is doing), we add a
separate --netns-fd option, so that we join that network namespace
(that's the only one you need, right?) and close it, together with any
possibly leaked file descriptor.

If the other options above don't work for you, would this one work?

> we also need to tear down pasta *quickly* once our processes using the 
> isolated network terminate. we can run hundreds of them per second, 
> leaving pasta instances around until they find the namespace gone is the 
> kind of drain on resources our scheduler wants to avoid, and on highly 
> loaded system we can't even guarantee that any given pasta instance can 
> check whether its namespaces are still live in any reasonable amount of 
> time.

Hmm, okay, if you can't give pasta a namespace handle, then pasta's own
clean-up mechanism won't be quick (see commit I mentioned above
introducing a timer for that).

I think the most appropriate solution would be the pidfd idea outlined
here as "option 2":

  https://github.com/podman-container-tools/podman/pull/27901#issuecomment-3819074744

which could actually be entirely race-free:

  https://github.com/podman-container-tools/podman/pull/27901#issuecomment-3823473179

...so that you can keep the clean synchronisation / demonisation on
start-up, and still have a fast and robust mechanism to terminate it.
What do you think?

> we could probably get around *that* by shoving pasta into a fresh 
> pid namespace under a manager as pid1, then killing that manager and 
> having the manager wait for pasta to fork.

That looks complicated.  Somewhat related, by the way:

  https://bugs.passt.top/show_bug.cgi?id=225#c6

but that won't really help in your case.

-- 
Stefano

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: pasta: patches for --pass-fds (fix) and --ready-fd (new)
  2026-11-27 22:25     ` Stefano Brivio
@ 2026-11-29 20:11       ` eldritch horrors
  2026-12-02 11:49         ` Stefano Brivio
  0 siblings, 1 reply; 11+ messages in thread
From: eldritch horrors @ 2026-11-29 20:11 UTC (permalink / raw)
  To: Stefano Brivio
  Cc: Lisanna Dettwyler, passt-dev, raito, sergei, Paul Holzinger

hi,

On 27/11/2026 23:25, Stefano Brivio wrote:
> I think we had some issue with this at some point, it works for me now,
> but I have a vague memory of another use case (probably Buildah?) where
> this wasn't a possibility at all.  I tried both:

we've retested these, and today they work. we can totally pass a PID to 
pasta and have it open its namespace files, so that's no longer a 
problem. excellent :) we're no longer sure what the original problem was 
here, but that bit does look solved without any sort of fd passing.

>> we also need to tear down pasta *quickly* once our processes using the
>> isolated network terminate. we can run hundreds of them per second,
>> leaving pasta instances around until they find the namespace gone is the
>> kind of drain on resources our scheduler wants to avoid, and on highly
>> loaded system we can't even guarantee that any given pasta instance can
>> check whether its namespaces are still live in any reasonable amount of
>> time.
> 
> Hmm, okay, if you can't give pasta a namespace handle, then pasta's own
> clean-up mechanism won't be quick (see commit I mentioned above
> introducing a timer for that).
> 
> I think the most appropriate solution would be the pidfd idea outlined
> here as "option 2":
> 
>    https://github.com/podman-container-tools/podman/pull/27901#issuecomment-3819074744
> 
> which could actually be entirely race-free:
> 
>    https://github.com/podman-container-tools/podman/pull/27901#issuecomment-3823473179
> 
> ...so that you can keep the clean synchronisation / demonisation on
> start-up, and still have a fast and robust mechanism to terminate it.
> What do you think?

that could be workable, but "works since 6.14" is a caveat we currently 
can't work with. we've checked the linux source, and 6.14 is indeed a 
lower bound for when this trick would work.

we don't fully understand why a readiness fd is scary here, but we're 
also not that well-versed in how the different LSMs treat inherited file 
descriptors. we'd be totally happy if pasta just kept an fd to close 
where it would normally fork, with nothing else done to the fd under any 
circumstances.

all this aside it seems that we could use the pidfile option to have 
pasta write its pid to a fifo and use the appearance of data as a "would 
have daemonized here" signal. this feels strictly inferior to a 
readiness fd passed via inheritance[1], but we do suppose (without 
having tested it yet) that this should work. if it does we'd have a 
significantly less crimes-y solution with current pasta versions, but 
we'd still prefer a readiness fd for signaling. that just seems like the 
much cleaner solution on the consumer side, with no filesystem pollution 
or other interference to worry about.

[1]: having a stable name in the filesystem would let other applications 
very easily signal pasta readiness and subsequently either have pasta 
hang (if we don't unlink the fifo as early as possible) or write junk to 
disk (if we do unlink the fifo early), though this is also a potential 
problem with inherited fds thanks to the /proc/*/fd/* links. closing an 
inherited fd is not vulnerable to this kind of interference; we can 
inject data via magic links, but not closes.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: pasta: patches for --pass-fds (fix) and --ready-fd (new)
  2026-11-29 20:11       ` eldritch horrors
@ 2026-12-02 11:49         ` Stefano Brivio
  2026-12-04 18:42           ` eldritch horrors
  0 siblings, 1 reply; 11+ messages in thread
From: Stefano Brivio @ 2026-12-02 11:49 UTC (permalink / raw)
  To: eldritch horrors
  Cc: Lisanna Dettwyler, passt-dev, raito, sergei, Paul Holzinger

On Sun, 29 Nov 2026 21:11:22 +0100
eldritch horrors <pennae@lix.systems> wrote:

> hi,
> 
> On 27/11/2026 23:25, Stefano Brivio wrote:
> > I think we had some issue with this at some point, it works for me now,
> > but I have a vague memory of another use case (probably Buildah?) where
> > this wasn't a possibility at all.  I tried both:  
> 
> we've retested these, and today they work. we can totally pass a PID to 
> pasta and have it open its namespace files, so that's no longer a 
> problem. excellent :) we're no longer sure what the original problem was 
> here, but that bit does look solved without any sort of fd passing.

Hah, great, thanks for re-testing!

> >> we also need to tear down pasta *quickly* once our processes using the
> >> isolated network terminate. we can run hundreds of them per second,
> >> leaving pasta instances around until they find the namespace gone is the
> >> kind of drain on resources our scheduler wants to avoid, and on highly
> >> loaded system we can't even guarantee that any given pasta instance can
> >> check whether its namespaces are still live in any reasonable amount of
> >> time.  
> > 
> > Hmm, okay, if you can't give pasta a namespace handle, then pasta's own
> > clean-up mechanism won't be quick (see commit I mentioned above
> > introducing a timer for that).
> > 
> > I think the most appropriate solution would be the pidfd idea outlined
> > here as "option 2":
> > 
> >    https://github.com/podman-container-tools/podman/pull/27901#issuecomment-3819074744
> > 
> > which could actually be entirely race-free:
> > 
> >    https://github.com/podman-container-tools/podman/pull/27901#issuecomment-3823473179
> > 
> > ...so that you can keep the clean synchronisation / demonisation on
> > start-up, and still have a fast and robust mechanism to terminate it.
> > What do you think?  
> 
> that could be workable, but "works since 6.14" is a caveat we currently 
> can't work with. we've checked the linux source, and 6.14 is indeed a 
> lower bound for when this trick would work.

Note that we strive to maintain compatibility with (much) older kernel
versions (4.18 or so).  If something works since 6.14, of course, we'd
make sure to have a workaround carrying some risk of an unlikely and
relatively harmless race condition on older kernels.

> we don't fully understand why a readiness fd is scary here

Because you can do a lot of things on a file descriptor, and it's one
more thing from the "outside world" pasta could touch.  It's not
particularly scary, it's just as scary as other interfaces.  And the
fewer interfaces we can have, the better.

> but we're 
> also not that well-versed in how the different LSMs treat inherited file 
> descriptors.

Actually, I had something completely unrelated in mind when I wrote
that.  I was mistakenly thinking of something path-based, sorry.  It
wouldn't be the case.  So, actually, policy-wise it's all unproblematic.

That's one aspect that makes it a bit more scary though: LSMs wouldn't
see that at all.  You can say stuff like "pasta is allowed to receive
SIGTERM from Podman" (and no other signals, from no other processes),
but you can't decide what pasta can do with that file descriptor at
all: everything goes, including, say, calling fsconfig(2) on it.

> we'd be totally happy if pasta just kept an fd to close 
> where it would normally fork, with nothing else done to the fd under any 
> circumstances.
>
> all this aside it seems that we could use the pidfile option to have 
> pasta write its pid to a fifo and use the appearance of data as a "would 
> have daemonized here" signal.

Hmm, what if pasta optionally writes its PID to stdout, as Paul was also
proposing on that ticket?  That's an interface we already have.

> this feels strictly inferior to a 
> readiness fd passed via inheritance[1], but we do suppose (without 
> having tested it yet) that this should work. if it does we'd have a 
> significantly less crimes-y solution with current pasta versions, but 
> we'd still prefer a readiness fd for signaling. that just seems like the 
> much cleaner solution on the consumer side, with no filesystem pollution 
> or other interference to worry about.
> 
> [1]: having a stable name in the filesystem would let other applications 
> very easily signal pasta readiness and subsequently either have pasta 
> hang (if we don't unlink the fifo as early as possible) or write junk to 
> disk (if we do unlink the fifo early), though this is also a potential 
> problem with inherited fds thanks to the /proc/*/fd/* links. closing an 
> inherited fd is not vulnerable to this kind of interference; we can 
> inject data via magic links, but not closes.

I see your point in general, except that a filesystem can be used to
police things using LSMs, *and* pasta could close the file before a
container starts interacting it.  At this point, I'm convinced enough
by your argument that I'm kind of ambivalent towards it.

 * * *

By the way, we eventually had to add another interface, recently, which
is a full-fledged (optional) control socket, because container runtimes
need to add and remove port mappings at runtime.

It can be accessed via pesto(1) using a simple binary protocol.  It's a
more involved interface, indeed, but we couldn't avoid it, and access
is policed via regular filesystem permissions as well as via LSMs.  On
top of that, pasta doesn't get any file descriptor from another
process: it's a UNIX domain socket with its abstraction, which also
offers some implicit isolation.

If there's the possibility that Lix might need to use it as well in the
future, then we could just use that right now to terminate pasta.  We
could even ship a minimal client, say, basta(1), whose only job is to
write a single "quit" command to the UNIX domain socket.  Would that be
appealing in any way?

-- 
Stefano

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: pasta: patches for --pass-fds (fix) and --ready-fd (new)
  2026-12-02 11:49         ` Stefano Brivio
@ 2026-12-04 18:42           ` eldritch horrors
  2026-12-05  1:14             ` eldritch horrors
  2026-12-05 23:30             ` Stefano Brivio
  0 siblings, 2 replies; 11+ messages in thread
From: eldritch horrors @ 2026-12-04 18:42 UTC (permalink / raw)
  To: Stefano Brivio
  Cc: Lisanna Dettwyler, passt-dev, raito, sergei, Paul Holzinger

On 02/12/2026 12:49, Stefano Brivio wrote:
>> we don't fully understand why a readiness fd is scary here
> 
> Because you can do a lot of things on a file descriptor, and it's one
> more thing from the "outside world" pasta could touch.  It's not
> particularly scary, it's just as scary as other interfaces.  And the
> fewer interfaces we can have, the better.
> 
>> but we're
>> also not that well-versed in how the different LSMs treat inherited file
>> descriptors.
> 
> Actually, I had something completely unrelated in mind when I wrote
> that.  I was mistakenly thinking of something path-based, sorry.  It
> wouldn't be the case.  So, actually, policy-wise it's all unproblematic.
> 
> That's one aspect that makes it a bit more scary though: LSMs wouldn't
> see that at all.  You can say stuff like "pasta is allowed to receive
> SIGTERM from Podman" (and no other signals, from no other processes),
> but you can't decide what pasta can do with that file descriptor at
> all: everything goes, including, say, calling fsconfig(2) on it.

the same thing goes for 0/1/2 though, and you don't close any of those 
despite not using them (which gave us the inheritance crimes in the 
first place), hence the confusion why adding one more would be such a 
big deal. but we guess you'd need to explicitly set pasta up for failure 
with those much more than with other fd numbers and treating those two 
sets as different interfaces for that reason does make sense

>> we'd be totally happy if pasta just kept an fd to close
>> where it would normally fork, with nothing else done to the fd under any
>> circumstances.
>>
>> all this aside it seems that we could use the pidfile option to have
>> pasta write its pid to a fifo and use the appearance of data as a "would
>> have daemonized here" signal.
> 
> Hmm, what if pasta optionally writes its PID to stdout, as Paul was also
> proposing on that ticket?  That's an interface we already have.

we've already tested this in principle, but haven't had the time to 
integrate it in lix and test it there. this does seem to work (thanks 
--pid /dev/stout), it just has the slight annoyance factor that stdout 
isn't closed once the pid is written. we can totally live with that 
though; pid on stdout is a fine signal for startup completion :)

> By the way, we eventually had to add another interface, recently, which
> is a full-fledged (optional) control socket, because container runtimes
> need to add and remove port mappings at runtime.
> 
> It can be accessed via pesto(1) using a simple binary protocol.  It's a
> more involved interface, indeed, but we couldn't avoid it, and access
> is policed via regular filesystem permissions as well as via LSMs.  On
> top of that, pasta doesn't get any file descriptor from another
> process: it's a UNIX domain socket with its abstraction, which also
> offers some implicit isolation.
> 
> If there's the possibility that Lix might need to use it as well in the
> future, then we could just use that right now to terminate pasta.  We
> could even ship a minimal client, say, basta(1), whose only job is to
> write a single "quit" command to the UNIX domain socket.  Would that be
> appealing in any way?

using the control interface isn't out of the question in the future, but 
we don't see any need for runtime configuration at this point. if pasta 
prefers to be shut down via the control socket we can do that, the 
protocol looks like something we could implement very easily (and would 
prefer to do so over using pesto for time being, our process 
abstractions are not currently well-suited for short-running utility 
commands. this'll change at some indeterminate point in the future)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: pasta: patches for --pass-fds (fix) and --ready-fd (new)
  2026-12-04 18:42           ` eldritch horrors
@ 2026-12-05  1:14             ` eldritch horrors
  2026-12-05 23:30             ` Stefano Brivio
  1 sibling, 0 replies; 11+ messages in thread
From: eldritch horrors @ 2026-12-05  1:14 UTC (permalink / raw)
  To: Stefano Brivio
  Cc: Lisanna Dettwyler, passt-dev, raito, sergei, Paul Holzinger

On 04/12/2026 19:42, eldritch horrors wrote:
> we've already tested this in principle, but haven't had the time to 
> integrate it in lix and test it there. this does seem to work (thanks -- 
> pid /dev/stout), it just has the slight annoyance factor that stdout 
> isn't closed once the pid is written. we can totally live with that 
> though; pid on stdout is a fine signal for startup completion :)
correction after further tests: this does not work under all 
circumstances. we've also rediscovered our original issue that led to 
the fd passing crimes.

pasta, when called with namespaces paths or a pid, must be able to read 
the namespace files in /proc. changing the owner of these files requires 
an exec transition *after* the namespaces have been unshared. requiring 
an exec transition introduces synchronization overhead because we can't 
simply wait for clone() to return and be sure to have access to all the 
namespaces we need, and we need something to exec in the first place, 
including a bunch of overhead for the exec process. passing namespace 
fds via inheritance solves all of these problems.

running pasta as root or with capabilities is not always possible, so 
having pasta open namespace files early will not help.

we're not fully positive that /dev/stdout is a viable target in all 
cases either, we've seen open failures for both that and /proc/self/fd/1 
in some tests. not sure where those came from, but a --pid-to-stdout 
option or similar would be greatly appreciated.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: pasta: patches for --pass-fds (fix) and --ready-fd (new)
  2026-12-04 18:42           ` eldritch horrors
  2026-12-05  1:14             ` eldritch horrors
@ 2026-12-05 23:30             ` Stefano Brivio
  1 sibling, 0 replies; 11+ messages in thread
From: Stefano Brivio @ 2026-12-05 23:30 UTC (permalink / raw)
  To: eldritch horrors
  Cc: Lisanna Dettwyler, passt-dev, raito, sergei, Paul Holzinger

[Two replies in one]

On Fri, 4 Dec 2026 19:42:16 +0100
eldritch horrors <pennae@lix.systems> wrote:

> On 02/12/2026 12:49, Stefano Brivio wrote:
> >> we don't fully understand why a readiness fd is scary here  
> > 
> > Because you can do a lot of things on a file descriptor, and it's one
> > more thing from the "outside world" pasta could touch.  It's not
> > particularly scary, it's just as scary as other interfaces.  And the
> > fewer interfaces we can have, the better.
> >   
> >> but we're
> >> also not that well-versed in how the different LSMs treat inherited file
> >> descriptors.  
> > 
> > Actually, I had something completely unrelated in mind when I wrote
> > that.  I was mistakenly thinking of something path-based, sorry.  It
> > wouldn't be the case.  So, actually, policy-wise it's all unproblematic.
> > 
> > That's one aspect that makes it a bit more scary though: LSMs wouldn't
> > see that at all.  You can say stuff like "pasta is allowed to receive
> > SIGTERM from Podman" (and no other signals, from no other processes),
> > but you can't decide what pasta can do with that file descriptor at
> > all: everything goes, including, say, calling fsconfig(2) on it.  
> 
> the same thing goes for 0/1/2 though, and you don't close any of those 
> despite not using them

If you don't pass --foreground, __daemon() in util.c closes them:

  https://passt.top/passt/tree/util.c?id=a39d958da8eb1ca6b582648f328408623f0a04e4#n523

...if you pass --foreground, they might be used instead, so we don't
close them.

> (which gave us the inheritance crimes in the 
> first place), hence the confusion why adding one more would be such a 
> big deal. but we guess you'd need to explicitly set pasta up for failure 
> with those much more than with other fd numbers and treating those two 
> sets as different interfaces for that reason does make sense
> 
> >> we'd be totally happy if pasta just kept an fd to close
> >> where it would normally fork, with nothing else done to the fd under any
> >> circumstances.
> >>
> >> all this aside it seems that we could use the pidfile option to have
> >> pasta write its pid to a fifo and use the appearance of data as a "would
> >> have daemonized here" signal.  
> > 
> > Hmm, what if pasta optionally writes its PID to stdout, as Paul was also
> > proposing on that ticket?  That's an interface we already have.  
> 
> we've already tested this in principle, but haven't had the time to 
> integrate it in lix and test it there. this does seem to work (thanks 
> --pid /dev/stout), it just has the slight annoyance factor that stdout 
> isn't closed once the pid is written. we can totally live with that 
> though; pid on stdout is a fine signal for startup completion :)

Grr, that makes --ready-fd almost elegant in comparison. :)

It really should be closed by pidfile_write() though:

  https://passt.top/passt/tree/util.c?id=a39d958da8eb1ca6b582648f328408623f0a04e4#n461

if that doesn't happen, unless I'm missing something, I guess that's a
bug.

> > By the way, we eventually had to add another interface, recently, which
> > is a full-fledged (optional) control socket, because container runtimes
> > need to add and remove port mappings at runtime.
> > 
> > It can be accessed via pesto(1) using a simple binary protocol.  It's a
> > more involved interface, indeed, but we couldn't avoid it, and access
> > is policed via regular filesystem permissions as well as via LSMs.  On
> > top of that, pasta doesn't get any file descriptor from another
> > process: it's a UNIX domain socket with its abstraction, which also
> > offers some implicit isolation.
> > 
> > If there's the possibility that Lix might need to use it as well in the
> > future, then we could just use that right now to terminate pasta.  We
> > could even ship a minimal client, say, basta(1), whose only job is to
> > write a single "quit" command to the UNIX domain socket.  Would that be
> > appealing in any way?  
> 
> using the control interface isn't out of the question in the future, but 
> we don't see any need for runtime configuration at this point. if pasta 
> prefers to be shut down via the control socket we can do that, the 
> protocol looks like something we could implement very easily (and would 
> prefer to do so over using pesto for time being, our process 
> abstractions are not currently well-suited for short-running utility 
> commands. this'll change at some indeterminate point in the future)

Perhaps it would be cleaner and safer, with well-defined isolation,
interfaces, and access policies.

The only problem that now occurs to me is that you can't make sure you
kill the process with it.  If we have an issue where pasta becomes
unresponsive, you won't be able to recover from that.

On Sat, 5 Dec 2026 02:14:39 +0100
eldritch horrors <pennae@lix.systems> wrote:

> On 04/12/2026 19:42, eldritch horrors wrote:
> > we've already tested this in principle, but haven't had the time to 
> > integrate it in lix and test it there. this does seem to work (thanks -- 
> > pid /dev/stout), it just has the slight annoyance factor that stdout 
> > isn't closed once the pid is written. we can totally live with that 
> > though; pid on stdout is a fine signal for startup completion :)  
> correction after further tests: this does not work under all 
> circumstances. we've also rediscovered our original issue that led to 
> the fd passing crimes.
> 
> pasta, when called with namespaces paths or a pid, must be able to read 
> the namespace files in /proc. changing the owner of these files requires 
> an exec transition *after* the namespaces have been unshared. requiring 
> an exec transition introduces synchronization overhead because we can't 
> simply wait for clone() to return and be sure to have access to all the 
> namespaces we need, and we need something to exec in the first place, 
> including a bunch of overhead for the exec process. passing namespace 
> fds via inheritance solves all of these problems.

Hmm, okay.  But instead of weakening --pass-fds further, can we at least
have a separate option doing only that, say, --netns-fd, so that we just
use it to set c->pasta_netns_fd and if anything "wrong" is passed we'll
notice and quit?

Would you need to pass a user namespace reference as well?

What happens if you pass the network namespace as a file descriptor, and
at some point close it from the caller?  Would pasta be able notice?  If
yes, can't we just quit on that?

> running pasta as root or with capabilities is not always possible, so 
> having pasta open namespace files early will not help.

I'd say it's anyway never desirable.

> we're not fully positive that /dev/stdout is a viable target in all 
> cases either, we've seen open failures for both that and /proc/self/fd/1 
> in some tests. not sure where those came from, but a --pid-to-stdout 
> option or similar would be greatly appreciated.

So the idea would be that pasta prints the PID to stdout, just before
daemonising (and closing it)?

Is that still needed if you pass the network namespace via file
descriptor?

In general, given that you're fairly deep into the topic, probably more
familiar with it than I am, and that you can quickly test what works for
Lix, at this point I'd be happy to take patches with whatever it takes
to fix things for you, but... I'd have a wishlist if possible :)

I think it would be nice if we could avoid additional (substantial)
implementations with a non-negligible attack surface, especially if
those can be triggered once networking is ready and usable by the
container / guest.

We already store the network namespace as a file descriptor, so if you
pass that in as an option it's not much extra code, the scope is fairly
restricted, and there isn't much else that can go wrong.

It would also be nice to make sure any proposed change is compatible
with the current patch from https://bugs.passt.top/show_bug.cgi?id=225,
and with current LSM policies.

Assuming we go with that solution, if root owns the namespace that's
passed in, it would be good to make it hard for pasta to gain any
additional permission using it.  I'm not sure how.  If we don't need to
join the target namespace after we start (no -[tTuU] auto,
--no-splice), maybe we can close that file descriptor as soon as
possible?

If possible, I would really prefer to avoid anything like --ready-fd or
--exit-fd, because it's an uncommon interface with additional
implementation behind it.  That's pretty much it.

-- 
Stefano

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-12-05 23:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-23 22:11 pasta: patches for --pass-fds (fix) and --ready-fd (new) Lisanna Dettwyler
2026-11-24 18:20 ` Stefano Brivio
2026-11-24 18:46   ` Sergei Zimmerman
2026-11-24 21:32     ` Stefano Brivio
2026-11-26 19:04   ` eldritch horrors
2026-11-27 22:25     ` Stefano Brivio
2026-11-29 20:11       ` eldritch horrors
2026-12-02 11:49         ` Stefano Brivio
2026-12-04 18:42           ` eldritch horrors
2026-12-05  1:14             ` eldritch horrors
2026-12-05 23:30             ` Stefano Brivio

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).