Re: [PATCH 4/4] qemu_passt: Don't let passt fork off

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/14/23 8:02 AM, Stefano Brivio wrote:
On Tue, 14 Feb 2023 12:51:22 +0100
Michal Privoznik <mprivozn@xxxxxxxxxx> wrote:

When passt starts it tries to do some security measures to
restrict itself. For instance, it creates its own namespaces,
umounts basically everything, drops capabilities, forks off to
further restrict itself (the child is where all interesting work
takes place now). This is sound, except it's causing two
problems:

1) the PID file FD, which we leak into the passt process, gets
    closed (and thus our virPidFile*() helpers see unlocked PID
    file, which makes them think the process is gone),

I didn't realise this was the case, but giving passt write (unless I'm
missing something) access to a file created by libvirtd doesn't look
desirable to me.


2) the PID file no longer reflects true PID of the process.

Worse, the child calls setsid() so we can't even kill the whole
process group. I mean, we can but it won't be any good.

I think that (incorrect PID in the pidfile) is happening because Michal is using the original version of my patches that were pushed - I had mimicked the behavior of slirp, where libvirt deamonizes the new process. If that process then daemonizes itself, we have some sort of "double daemon"; libvirt has saved off the pid of what it thinks is going to be the final process, but then that process further forks and exits from the process whose pid libvirt saved. But because passt was cleaning up after itself I hadn't noticed the discrepancy in pids when testing.

Without going into all the details of the pidfile and locking and etc, I just want to say that if we can fork/exec dnsmasq and let it daemonize itself and create its own pidfile, then certainly we can do the same thing for passt. (and if there's a fundamental problem, then it's a fundamental problem for dnsmasq as well).


Fortunately, passt has '--foreground' argument, which causes it
to undergo the same security measures but without forking off the
child.

But if we do --foreground in combination with calling virCommandDaemonize(), then won't we still have the problem that libvirt won't know whether or not passt has failed to start (not unless we want to put in a bunch of gorp to continue grabbing stderr while watching to see if the passt process has exited, etc. It's going to take some convincing for me to think we should run passt with --foreground rather than letting it daemonize itself.


They're not the same -- unfortunately they can't be, because, on Linux,
you can't change the PID of an existing process, so there's no way to
enter a new PID namespace without clone().

If passt remains in the same PID namespace, it's still able to see PIDs
of other processes, which is not desirable from a security perspective.

Again from a security perspective, this is probably a small impact, so
I guess it's fine if there's no other way around it. But I see a lot of
ways around it...





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux