* 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; 6+ 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] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ 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; 6+ 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] 6+ 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 0 siblings, 0 replies; 6+ 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] 6+ messages in thread
end of thread, other threads:[~2026-11-27 22:25 UTC | newest] Thread overview: 6+ 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
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).