public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Paul Holzinger <pholzing@redhat.com>
To: Stefano Brivio <sbrivio@redhat.com>, Johannes Segitz <jsegitz@suse.de>
Cc: passt-dev@passt.top
Subject: Re: [PATCH] SELinux: Dontaudit access to dri devices
Date: Tue, 7 Apr 2026 19:51:42 +0200	[thread overview]
Message-ID: <fa5c90ef-90e9-44f1-a651-d154881bded6@redhat.com> (raw)
In-Reply-To: <20260407111110.4153e21b@elisabeth>


On 07/04/2026 11:11, Stefano Brivio wrote:
> On Tue, 7 Apr 2026 10:27:04 +0200
> Johannes Segitz <jsegitz@suse.de> wrote:
>
>> On Thu, Apr 02, 2026 at 03:36:58PM +0200, Paul Holzinger wrote:
>>> I did a quick spot check in Podman and found a few places where a fd might
>>> be leaked: https://github.com/containers/podman/pull/28434
>>>
>>> That said I do not think any of these would explain an open /dev/dri path.
>> I build podman with the change (and passt with the broader fd closing
>> logic) and asked the reporter to test them. The denial is still shown with
>> this unfortunately
> Johannes, thanks for reporting back.
>
> Paul, I was wondering: would there be a way to do something equivalent
> to that close_range() directly in Podman, before it starts pasta? I
> think it's a separate thread (or even a forked process) starting it,
> but I haven't really checked.

So this is the problem, because the golang runtime manages its own epoll 
fds. It is not safe to close all fds within go code.

We have some work around, custom c init code which counts the fds before 
the go runtime kicks in but it is kinda fragile and the bigger issue is 
that we have many commands that may need access to leaked fds, i.e.:

- podman run --preserve-fds
- systemd socket activition
- shell expansion via `<(<<<"somestring")` passes us a string such as 
"/dev/fd/63", useful to inline a string on a command which only reads a 
file.

It is basically impossible to correctly figure this all out on the 
podman side without breaking certain use cases.

The other issue is that in theory yes lets just close all fds after 
fork() and before calling exec() but again the go runtime does not allow 
us to simply fork/exec. Due its nature we are limited to just an exec 
API with little control over the steps between a fork() (well clone() 
actually) and exec(). There are ways to pass down fds via that API which 
the go std code will dup at the right fd numbers but it will by default 
not close all other fds.

Ok, well there is a way using the go std lib, the ExtraFiles array 
accepts nil entries which means close this fd at this place, i.e. 
`ExtraFiles = []*os.File{nil,nil}` would result in closing fd 3 and 4. 
So in order to close all fds we would have to pass a slice with the size 
of all possible fds on linux which is just not great. And well the go 
runtime code then calls close() on every single one of them which would 
just add to much unnecessary overhead for each pasta start.

-- 
Paul Holzinger


  reply	other threads:[~2026-04-07 17:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-30 11:05 Johannes Segitz
2026-03-30 15:15 ` Stefano Brivio
2026-03-31  7:00   ` Johannes Segitz
2026-03-31 19:47     ` Stefano Brivio
2026-04-01 12:12       ` Johannes Segitz
2026-04-02 12:24       ` Paul Holzinger
2026-04-02 13:36         ` Paul Holzinger
2026-04-07  8:27           ` Johannes Segitz
2026-04-07  9:11             ` Stefano Brivio
2026-04-07 17:51               ` Paul Holzinger [this message]
2026-04-02 13:46         ` Stefano Brivio
2026-04-02 14:07           ` Johannes Segitz

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=fa5c90ef-90e9-44f1-a651-d154881bded6@redhat.com \
    --to=pholzing@redhat.com \
    --cc=jsegitz@suse.de \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /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).