<div dir="ltr"><div>Hi guys,</div><div><br></div><div>Thank you very much for the detailed explanation.</div><div><br></div><div>With the mount namespace feature turned off, there were no SELinux denials.<br></div><div><br></div><div>Michal I saw your<a href="https://gitlab.com/libvirt/libvirt/-/commit/22188790cad490f51e73dabcac65736c3b8871a7"> commit</a>, where firstly the existence of devices is checked. <span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b"><span>I assume when some correction is required</span></span></span>, virtqemud will still need unlink permission, right?<br></div><div><br></div><div>Nikola<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 14, 2022 at 1:12 PM Michal Prívozník <<a href="mailto:mprivozn@redhat.com">mprivozn@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 3/14/22 12:45, Martin Kletzander wrote:<br>
> [adding back libvir-list to the Cc]<br>
> <br>
> On Fri, Mar 11, 2022 at 03:55:03PM +0100, Nikola Knazekova wrote:<br>
>> Hey Martin,<br>
>><br>
>> thanks for your resposne.<br>
>><br>
>> I don't know if it is happening in the mount namespace. Can you look<br>
>> at the<br>
>> logs in attachment?<br>
>><br>
>> It was happening on clear install on F35, F36 and on older versions<br>
>> probably too.<br>
>> But it is only an issue in the new selinux policy for libvirt. In old<br>
>> selinux policy is allowed for virtd to unlink /dev/urandom char files.<br>
>> I just wanted to be sure if it is ok to allow it for virtqemud.<br>
>><br>
> <br>
> That actually might be the case, that it actually does set the context<br>
> on /dev/urandom correctly and then the unlink fails for virtqemud since<br>
> the selinux policy only accounts for libvirtd even though we switched to<br>
> modular daemons making virtqemud the one to do the work.<br>
> <br>
> @Michal can you confirm what I'm guessing here since you did a lot of<br>
> the mount namespace work which I presume is what contributes to the<br>
> issue here.<br>
> <br>
> In the meantime, would you mind trying this with the mount namespace<br>
> feature turned off in /etc/libvirt/qemu.conf like this:<br>
> <br>
> namespaces = []<br>
> <br>
<br>
Yeah, this will definitely help. So, a short introduction into how<br>
libvirt starts a QEMU guest. It creates a mount namespace so that QEMU<br>
doesn't have access to all the files in the system. In this namespace<br>
(which is per each QEMU process) firstly very few paths are populated<br>
independent of guest configuration (like /dev/null, /dev/random/,<br>
/dev/urandom, etc.) - the full list is accessible here:<br>
<br>
<a href="https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu.conf#L565" rel="noreferrer" target="_blank">https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu.conf#L565</a><br>
<br>
(yes, it's the cgroup_device_acl list - because what you want to enable<br>
in CGroups you want to expose in the namespace)<br>
<br>
Then, the paths from domain XML are created using the following function:<br>
<br>
<a href="https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu_namespace.c#L931" rel="noreferrer" target="_blank">https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu_namespace.c#L931</a><br>
<br>
This function is written in a fashion that allows files to exist and if<br>
needed [1] it simply unlink()-s existing file and creates it from<br>
scratch again. Now, since you configured TPM for your guest with<br>
/dev/urandom as a backend, this node is created twice. The first time<br>
among with other cgroup_device_acl files, the second because of TPM from<br>
your domain config.<br>
<br>
1: needed is probably a bad word, and in fact we can be more clever<br>
about it. We might check whether given device already exists and if it<br>
has the same MAJ:MIN and act accordingly. The same applies for symlinks.<br>
<br>
Let me see if I can cook up a patch that implements this idea.<br>
<br>
Michal<br>
<br>
</blockquote></div>