public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: eldritch horrors <pennae@lix.systems>
Cc: Lisanna Dettwyler <lisanna.dettwyler@gmail.com>,
	passt-dev@passt.top, raito@lix.systems, sergei@zimmerman.foo,
	Paul Holzinger <pholzing@redhat.com>
Subject: Re: pasta: patches for --pass-fds (fix) and --ready-fd (new)
Date: Wed, 02 Dec 2026 12:49:03 +0100 (CET)	[thread overview]
Message-ID: <20261202124901.0ab686fd@elisabeth> (raw)
In-Reply-To: <6d2ed11c-0109-409c-b584-adbdc43fb862@lix.systems>

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

      reply	other threads:[~2026-12-02 11:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 22:11 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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202124901.0ab686fd@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=lisanna.dettwyler@gmail.com \
    --cc=passt-dev@passt.top \
    --cc=pennae@lix.systems \
    --cc=pholzing@redhat.com \
    --cc=raito@lix.systems \
    --cc=sergei@zimmerman.foo \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).