From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=fail (p=quarantine dis=none) header.from=redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 241CB5A0269 for ; Sun, 06 Dec 2026 00:30:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796513452; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0KWEFzz5+Lwnh1m4wlnhwsdC06boRDfKwARwx4/ERoE=; b=ae2UMV1lVdiCbq8ksvm40TX8PU+WdiYfiUC1DqHYu33xmrtnM0izEZ7K/O6ZizcN4DCsDv tz7HYAArYHyUHKcv+ZYULWq778nMV0I/lv6dRrqQ9AtTJvQNqyyPAxmYo1G2TY51rUjmrN l+lsxMdTSvixwvz+eqIn9RYtjhQ0WWg= X-MC-Rep: binary re single Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-232-WY49LYDMMfW7F2F4zdyoXQ-1; Sat, 5 Dec 2026 23:30:51 +0000 X-MC-Unique: WY49LYDMMfW7F2F4zdyoXQ-1 X-Mimecast-MFC-AGG-ID: WY49LYDMMfW7F2F4zdyoXQ_1796513450 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4bba5f21b85so13123425e9.1 for ; Sat, 05 Dec 2026 15:30:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796513450; x=1797118250; h=date:content-transfer-encoding:content-type:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=0KWEFzz5+Lwnh1m4wlnhwsdC06boRDfKwARwx4/ERoE=; b=YU61qCB9mFP+Wpq5qTlZF5TkqEEHOiPZEdbWTF3n9mD1SknM1RmLhlGIv4v+6Ogf83 NOnUALQbx3iv9PvZyPIb6t94iuDa9EUq/dHP7wDIV4yMVEVlzHc7i694Gjzm3eZ6V//C SfXAZk7nqROma2ZdDs8X9X4RDtw2/DifpaQ/Zy4ky5/PiPAkQkPhoXxirAiySexvODuG 9elpp8CdKNS6wpG68fzy0LG9GkePJ/U3WLa0L9ZJQl8FpWEUaA56xHNE2uxuwAmMhaNz rw5RRCwSFTB19wnstNNk32CeFIp5GQCtiktHVnieDYNJe3c02/Clj1URZXGR+4fKJJh/ DQTA== X-Forwarded-Encrypted: i=1; AL+hErHxU4H2Ckqnt4wH9ZgmfAfP6nMC/3HwxHqzK47piTgiBFQZyiJPW9eUBiV14foj777p3mSN3oSNDZk=@passt.top X-Gm-Message-State: APuU4Z9dsDewce6FX5Nr1gbkP2Vg/4VSs+LXFKKhI5/RY+vZgQIloVsY hiRrVZwzmNDQnx541fmyieheTCZfj5XKO8d0fhn9104NDkV91T19DPj2P47R775q1EgtY//KEJX yBI2qPcHMpVMWprHieMfhe9/WI9KjY7imXU4k2d8981zNJNYcUrW9Dw== X-Gm-Gg: AZFdTZeOh0UEXfcreFxX87/48fphnJBqd50cHK6NVd18jwYkWX4k/MB9veVzxLcGYbL 7/H3dhdCEqDMSXmJbB887COzuMpYr3vD7r2ov4a2Nj/njDgY+56qj8WSQ3hT4Qi5enhGR0gSPob lj/zQArtqK88v9KImP9Fyu2OUyWVUENlGQ2aIke1tbhPud9pOuQZBjuGLci/wCBHpwGU9w55BY9 vQ0Qnp29NV2JHdI9z9/lvxkL/yxg6urMiSiwvS8RIwlgrKgsytaEcfpuuWLBwQaGwvZ0LJf248s s5+dG5OW5qw4h9gQpFzhYt+rdUEctGKRqI2/TrkAHXwv2182NCLaF6LOVvdwMR4IOSQjx3VEyLE 1jV1lNuWtaXcd9LY/BWDQRbGDClzDXziEU2qeVm5mDrUWBLbqo9GZKorakMVfAgk8bU6TsoJsm3 Q3CY/PKRCv X-Received: by 2002:a05:600c:45c3:b0:49e:65f2:db64 with SMTP id 5b1f17b1804b1-4bbeb851340mr133553395e9.5.1796513449684; Sat, 05 Dec 2026 15:30:49 -0800 (PST) X-Received: by 2002:a05:600c:45c3:b0:49e:65f2:db64 with SMTP id 5b1f17b1804b1-4bbeb851340mr133552845e9.5.1796513449172; Sat, 05 Dec 2026 15:30:49 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe06edeb7sm445263705e9.11.2026.12.05.15.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:30:48 -0800 (PST) From: Stefano Brivio To: eldritch horrors Subject: Re: pasta: patches for --pass-fds (fix) and --ready-fd (new) Message-ID: <20261206003047.4edf4ce9@elisabeth> In-Reply-To: <2b7695c7-dff6-43c0-bb31-dffa097714a9@lix.systems> References: <20261124192024.0e16f855@elisabeth> <6a3d919f-8fe9-4473-ac11-7d3d1a4b6173@lix.systems> <20261127232541.2474fc81@elisabeth> <6d2ed11c-0109-409c-b584-adbdc43fb862@lix.systems> <20261202124901.0ab686fd@elisabeth> <2b7695c7-dff6-43c0-bb31-dffa097714a9@lix.systems> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Sun, 06 Dec 2026 00:30:48 +0100 (CET) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MkY77LdNM4EfdOoZXCRt9WCekHLQuxQEWcJ24sc8QH4_1796513450 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: DVYQ3PX5W55ADEU3MOWXQJH3EO5H3M6R X-Message-ID-Hash: DVYQ3PX5W55ADEU3MOWXQJH3EO5H3M6R X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Lisanna Dettwyler , passt-dev@passt.top, raito@lix.systems, sergei@zimmerman.foo, Paul Holzinger X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: [Two replies in one] On Fri, 4 Dec 2026 19:42:16 +0100 eldritch horrors 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 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