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: Sun, 06 Dec 2026 00:30:48 +0100 (CET)	[thread overview]
Message-ID: <20261206003047.4edf4ce9@elisabeth> (raw)
In-Reply-To: <2b7695c7-dff6-43c0-bb31-dffa097714a9@lix.systems>

[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

      parent reply	other threads:[~2026-12-05 23:30 UTC|newest]

Thread overview: 11+ 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
2026-12-04 18:42           ` eldritch horrors
2026-12-05  1:14             ` eldritch horrors
2026-12-05 23:30             ` 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=20261206003047.4edf4ce9@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).