Re: qemu-ga guest-exec & SELinux

Renaud Métrich <[email protected]> Tue, 21 Jun 2022 10:42:39 +0200
Newsgroups gmane.comp.emulators.qemu,gmane.linux.redhat.fedora.selinux
Message-ID <[email protected]>
Hi there,

I'm the BZ reporter.

I think the safe solution is to provide something similar to what was 
done for vmtools: have a context switching to become sort of 
"unconfined" domain.

This context switch has to happen only the executor and we already have 
a solution, I documented it in the BZ.

I don't think having an additional boolean is necessary, unless we want 
to restrict the commands the guest can execute.

Note that on RHEL the functionality is disabled by default ("guest-exec" 
is blacklisted), we may add a note in the /etc/sysconfig/qemu-ga file 
stating that allowing such command is risky.

Renaud.

Le 6/20/22 à 12:06, Daniel P. Berrangé a écrit :
> On Mon, Jun 20, 2022 at 01:44:05PM +0400, Marc-André Lureau wrote:
>> Hi!
>>
>> https://bugzilla.redhat.com/show_bug.cgi?id=2093355 ("AVCs when trying to
>> execute a command through qemu-ga ("guest-exec" command)") describes an
>> issue with fedora/rhel SELinux rules, where some program executions are
>> denied.
>>
>> qemu-ga has "virt_qemu_ga_t" context, and is not allowed to execute
>> binaries that are not "bin_t", iiuc. The suggestion from Renaud Métrich is
>> for qemu-ga exec command to launch the user program through an helper
>> program that would have the virt_qemu_ga_unconfined_exec_t context, and
>> appropriate rules in selinux (similar to fsfreeze-hook rules), so any
>> program can be executed. qemu-ga would thus ship and use that helper, in
>> all OS, to avoid varying code paths.
>>
>> Does that sound reasonable or should we try to find a solution with SELinux
>> rules instead?
> I thought was did not allow qemu-ga to execute binaries at all, regardless
> of whether they're bin_t or not.  The 'guest-exec' command is essentially
> a giant hole that defeats the purpose of confining qemu-ga with SELinux
> at all IMHO.
>
> IMHO execution of external commands should only be allowed after toggling
> a SELinux boolean tunable.
>
>
> With regards,
> Daniel
OpenPGP_signature (application/pgp-signature, 840 B) - not displayed