<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 31 May 2016 at 09:36, Daniel P. Berrange <span dir="ltr"><<a href="mailto:berrange@redhat.com" target="_blank">berrange@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon, May 30, 2016 at 01:27:46PM -0700, Ansis Atteka wrote:<br>
> On Mon, May 30, 2016 at 12:29 AM, Christian Ehrhardt<br>
> <<a href="mailto:christian.ehrhardt@canonical.com">christian.ehrhardt@canonical.com</a>> wrote:<br>
> > On Tue, May 24, 2016 at 4:10 PM, Aaron Conole <<a href="mailto:aconole@redhat.com">aconole@redhat.com</a>> wrote:<br>
> ><br>
> >> Daniele Di Proietto <<a href="mailto:diproiettod@vmware.com">diproiettod@vmware.com</a>> writes:<br>
> >><br>
> >> > Hi Aaron,<br>
> >> ><br>
> >> > I'm still a little bit nervous about calling chown on a (partially)<br>
> >> > user controlled file name.<br>
> >><br>
> >> I agree, that always seems scary.<br>
> >><br>
> >> > Before moving forward I wanted to discuss a couple of other options:<br>
> >> ><br>
> >> > * Ansis (in CC) suggested using -runas parameter in qemu.  This way<br>
> >> > qemu can open the socket as root and drop privileges before starting<br>
> >> > guest execution.<br>
> >><br>
> >> I'm not sure how to do this with libvirt, or via the OpenStack Neutron<br>
> >> plugin.  I also don't know if it would be an acceptable workaround for<br>
> >> users.  Additionally, I recall there being something of a "don't even<br>
> >> know if this works" around it.  Maybe Christian or Ansis (both in CC)<br>
> >> can expound on it.<br>
> >><br>
><br>
> Cross-posting to libvirt mailing list to hear opinion from libvirt developers.<br>
><br>
> In short - the problem is that libvirtd process starts qemu process<br>
> under non-root user. Since qemu starts under non-root process, then<br>
> qemu can't connect to DPDK unix domain sockets created by ovs-vswitcd<br>
> process that runs under "root". There are two solutions to this<br>
> problem:<br>
> 1. let ovs-vswitchd process to chown its socket from "root" to<br>
> "libvirt" group and/or user (this is what Aarons patch proposes)<br>
> 2. make libvirtd process to start qemu process under "root" but then<br>
> let qemu to downgrade via "-run-as" flag after qemu has opened the<br>
> Unix Domain socket.<br>
><br>
> Regarding solution #2. I think the necessary changes roughly would be to:<br>
> 1. invoke virCommandAddArgPair(cmd, "-runas", "libvirt") before<br>
> starting qemu process; AND<br>
> 2. revert virCommandSetUID() that automatically downgrades user from<br>
> "root" to "libvirt" even before qemu starts.<br>
> I would like to hear feasibility of such solution from libvirt<br>
> developers? Or maybe there is even a better solution that I am<br>
> missing?<br>
<br>
</div></div>That's not going to happen.  Libvirt consider QEMU to be untrustworthy<br>
in general and so apply multiple techniques to confine QEMU before it is<br>
exec'd. This include dropping to non-0 uid/gid, applying apparmour/selinux<br>
policies, putting it in restricted cgroups, and potentially more in the<br>
future such as putting it in custom namespaces. We've no desire to use<br>
qemu's -runas, as that means we're trusting QEMU to actually drop privileges<br>
as it claims to.<br></blockquote><div><br></div><div>Thanks for reply, Daniel! Yes, with -run-as flag it would be left at qemu's discretion to give up 'root' privileges and I understand you that it may not fit into security model chosen by libvirt.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Libvirt's model is that libvirt will setup policies to allow QEMU access<br>
to the specific resources that it needs. so eg libvirt will chown the<br>
disk images associated with the VM to give it access.<br>
<br>
I'm missing history of this thread, but IIUC, the issue here is access<br>
to the UNIX domain socket associated with the vhost-user network backend<br>
for QEMU. If so, then I think it is a case where libvirt should be setting<br>
ownershup on that socket before starting QEMU, in order to grant access.<br>
This of course assumes there is a separate UNIX domain socket per VM<br>
that is launched.<br></blockquote><div> </div><div>If the current libvirt security model is that libvirt is already chown()'ing resources needed by qemu, then perhaps vhost user socket may be another thing that libvirt needs to chown()? Or do you think that it would be better for libvirt to tell the user to which Open vSwitch needs to chown the socket (via the ovs-vsctl call in libvirt/src/util/virnetdevopenvswitch.c)?</div><div><br></div><div>Also, did I understand it correctly that libvirt also changes SELinux context for resources that qemu would be consuming so that qemu would be confined by additional Mandatory Access Control layer? If so, then I think the current libvirt security model suggests that chown()'ing and chcon()'ing should happen from libvirt and should not use Open vSwitch as a proxy to do that, because otherwise Open vSwitch SELinux policy would need to be loosened up to do such things.</div><div><br></div><div>Also, what got me concerned is that Open vSwitch already has a Mandatory Access Control enforced under RHEL and Fedora distributions. For example, if libvirt changes SELinux context for files and sockets created by Open vSwitch then I am not sure how Open vSwitch would be able to cleanup them without getting permission denied errors. I will try this out on Fedora to see if my concern is justified.</div><div> <br></div><div>Thanks,</div><div>Ansis</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Regards,<br>
Daniel<br>
<span class="HOEnZb"><font color="#888888">--<br>
|: <a href="http://berrange.com" rel="noreferrer" target="_blank">http://berrange.com</a>      -o-    <a href="http://www.flickr.com/photos/dberrange/" rel="noreferrer" target="_blank">http://www.flickr.com/photos/dberrange/</a> :|<br>
|: <a href="http://libvirt.org" rel="noreferrer" target="_blank">http://libvirt.org</a>              -o-             <a href="http://virt-manager.org" rel="noreferrer" target="_blank">http://virt-manager.org</a> :|<br>
|: <a href="http://autobuild.org" rel="noreferrer" target="_blank">http://autobuild.org</a>       -o-         <a href="http://search.cpan.org/~danberr/" rel="noreferrer" target="_blank">http://search.cpan.org/~danberr/</a> :|<br>
|: <a href="http://entangle-photo.org" rel="noreferrer" target="_blank">http://entangle-photo.org</a>       -o-       <a href="http://live.gnome.org/gtk-vnc" rel="noreferrer" target="_blank">http://live.gnome.org/gtk-vnc</a> :|<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
dev mailing list<br>
<a href="mailto:dev@openvswitch.org">dev@openvswitch.org</a><br>
<a href="http://openvswitch.org/mailman/listinfo/dev" rel="noreferrer" target="_blank">http://openvswitch.org/mailman/listinfo/dev</a><br>
</div></div></blockquote></div><br></div></div>