Skip to contentSkip to conversation

Per-guest configurable user/group for QEMU processes

PATCH Corey Bryant 3 participants 6 messages Sep 11, 2012 – Sep 14, 2012 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Are there any other requirements that need to be taken care of to enable execution of QEMU guests under separate unprivileged user IDs (ie. DAC isolation)?

At this point, this patch series (Per-guest configurable user/group for QEMU processes) is upstream, allowing libvirt to execute guests under separate unprivileged user IDs. Additionally, the QEMU bridge helper series is upstream, allowing QEMU to allocate a tap device and attach it to a bridge when run under an unprivileged user ID (http://www.redhat.com/archives/libvir-list/2012-August/msg00277.html).

Is there any other feature in QEMU that requires QEMU to be run as root?

Signature · 2 lines
Regards,
Corey
Quoted 53 lines · Marcelo Cerri

This is a v4 patch series that updates the libvirt's security driver mechanism to support per-guest configurable user and group for QEMU processes running together with other security drivers, such as SELinux and AppArmor.

Marcelo Cerri (5):
Internal refactory of data structures
Multiple security drivers in XML data
Update security layer to handle many security labels Support for multiple default security drivers in QEMU config Update the remote API

  daemon/remote.c                                    |   63 ++++
  docs/formatdomain.html.in                          |   11 +-
  docs/schemas/capability.rng                        |   18 +-
  docs/schemas/domaincommon.rng                      |   30 ++-
  include/libvirt/libvirt.h.in                       |    2 +
  python/generator.py                                |    1 +
  src/conf/capabilities.c                            |   17 +-
  src/conf/capabilities.h                            |    6 +-
  src/conf/domain_audit.c                            |   14 +-
  src/conf/domain_conf.c                             |  343 +++++++++++++++-----
  src/conf/domain_conf.h                             |   20 +-
  src/driver.h                                       |    4 +
  src/libvirt.c                                      |   47 +++
  src/libvirt_private.syms                           |    5 +
  src/libvirt_public.syms                            |    1 +
  src/lxc/lxc_conf.c                                 |    8 +-
  src/lxc/lxc_controller.c                           |    8 +-
  src/lxc/lxc_driver.c                               |   11 +-
  src/lxc/lxc_process.c                              |   23 +-
  src/qemu/qemu.conf                                 |    6 +-
  src/qemu/qemu_conf.c                               |   38 ++-
  src/qemu/qemu_conf.h                               |    2 +-
  src/qemu/qemu_driver.c                             |  218 +++++++++++---
  src/qemu/qemu_process.c                            |   50 ++-
  src/remote/remote_driver.c                         |   46 +++
  src/remote/remote_protocol.x                       |   17 +-
  src/remote_protocol-structs                        |   11 +
  src/security/security_apparmor.c                   |  118 +++++--
  src/security/security_dac.c                        |  324 +++++++++++++++++--
  src/security/security_manager.c                    |  101 +++++--
  src/security/security_manager.h                    |    8 +-
  src/security/security_selinux.c                    |  263 +++++++++++-----
  src/security/security_stack.c                      |  237 +++++++++-----
  src/security/security_stack.h                      |   13 +
  src/test/test_driver.c                             |   11 +-
  .../qemuxml2argv-seclabel-dynamic-override.xml     |    4 +-
  .../qemuxml2argv-seclabel-dynamic.xml              |    2 +-
  37 files changed, 1653 insertions(+), 448 deletions(-)

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

#2 lore raw

Hi,

Any comments about that?

Regards,
Marcelo

Quoted 70 lines · Corey Bryant

Are there any other requirements that need to be taken care of to enable execution of QEMU guests under separate unprivileged user IDs (ie. DAC isolation)?

At this point, this patch series (Per-guest configurable user/group
for QEMU processes) is upstream, allowing libvirt to execute guests
under separate unprivileged user IDs. Additionally, the QEMU bridge
helper series is upstream, allowing QEMU to allocate a tap device
and attach it to a bridge when run under an unprivileged user ID (http://www.redhat.com/archives/libvir-list/2012-August/msg00277.html).

Is there any other feature in QEMU that requires QEMU to be run as root?

Signature · 2 lines
Regards,
Corey
Quoted 53 lines · Marcelo Cerri

This is a v4 patch series that updates the libvirt's security driver mechanism to support per-guest configurable user and group for QEMU processes running together with other security drivers, such as SELinux and AppArmor.

Marcelo Cerri (5):
Internal refactory of data structures
Multiple security drivers in XML data
Update security layer to handle many security labels Support for multiple default security drivers in QEMU config Update the remote API

 daemon/remote.c                                    |   63 ++++
 docs/formatdomain.html.in                          |   11 +-
 docs/schemas/capability.rng                        |   18 +-
 docs/schemas/domaincommon.rng                      |   30 ++-
 include/libvirt/libvirt.h.in                       |    2 +
 python/generator.py                                |    1 +
 src/conf/capabilities.c                            |   17 +-
 src/conf/capabilities.h                            |    6 +-
 src/conf/domain_audit.c                            |   14 +-
 src/conf/domain_conf.c                             |  343 +++++++++++++++-----
 src/conf/domain_conf.h                             |   20 +-
 src/driver.h                                       |    4 +
 src/libvirt.c                                      |   47 +++
 src/libvirt_private.syms                           |    5 +
 src/libvirt_public.syms                            |    1 +
 src/lxc/lxc_conf.c                                 |    8 +-
 src/lxc/lxc_controller.c                           |    8 +-
 src/lxc/lxc_driver.c                               |   11 +-
 src/lxc/lxc_process.c                              |   23 +-
 src/qemu/qemu.conf                                 |    6 +-
 src/qemu/qemu_conf.c                               |   38 ++-
 src/qemu/qemu_conf.h                               |    2 +-
 src/qemu/qemu_driver.c                             |  218 +++++++++++---
 src/qemu/qemu_process.c                            |   50 ++-
 src/remote/remote_driver.c                         |   46 +++
 src/remote/remote_protocol.x                       |   17 +-
 src/remote_protocol-structs                        |   11 +
 src/security/security_apparmor.c                   |  118 +++++--
 src/security/security_dac.c                        |  324 +++++++++++++++++--
 src/security/security_manager.c                    |  101 +++++--
 src/security/security_manager.h                    |    8 +-
 src/security/security_selinux.c                    |  263 +++++++++++-----
 src/security/security_stack.c                      |  237 +++++++++-----
 src/security/security_stack.h                      |   13 +
 src/test/test_driver.c                             |   11 +-
 .../qemuxml2argv-seclabel-dynamic-override.xml     |    4 +-
 .../qemuxml2argv-seclabel-dynamic.xml              |    2 +-
 37 files changed, 1653 insertions(+), 448 deletions(-)

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

#3 lore raw
In reply to Corey Bryant
Quoted 11 lines · Corey Bryant

Are there any other requirements that need to be taken care of to enable execution of QEMU guests under separate unprivileged user IDs (ie. DAC isolation)?

At this point, this patch series (Per-guest configurable user/group
for QEMU processes) is upstream, allowing libvirt to execute guests
under separate unprivileged user IDs. Additionally, the QEMU bridge
helper series is upstream, allowing QEMU to allocate a tap device
and attach it to a bridge when run under an unprivileged user ID (http://www.redhat.com/archives/libvir-list/2012-August/msg00277.html).

Is there any other feature in QEMU that requires QEMU to be run as root?

Well those features you mention are for two separate issues. When running libvirt privileged (qemu:///system), QEMU was already run as non-root (qemu:qemu). The per-guest user/group was just making sure that QEMU VMs were isolated from each other using user IDs. Since libvirtd is running privileged, it can either set permissions or open things on QEMU's behalf. All this side of things really works already.

The TAP device bridge helper is something that's needed when running libvirtd itself unprivileged (eg the per user qemu:///session libvirtd). In this case libvirtd can't access privileged resources at all, hence the setuid TAP helper was required.

So I guess this is a roundabout way of saying that I'm not really clear what you're asking about ? If you're using qemu:///system there has never been any problem with running QEMU unprivileged. When using qemu:///session you're obviously limited to whatever resources the user is allowed to access.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#4 lore raw
Quoted 13 lines · Daniel P. Berrange
Quoted 11 lines · Corey Bryant

Are there any other requirements that need to be taken care of to enable execution of QEMU guests under separate unprivileged user IDs (ie. DAC isolation)?

At this point, this patch series (Per-guest configurable user/group
for QEMU processes) is upstream, allowing libvirt to execute guests
under separate unprivileged user IDs. Additionally, the QEMU bridge
helper series is upstream, allowing QEMU to allocate a tap device
and attach it to a bridge when run under an unprivileged user ID (http://www.redhat.com/archives/libvir-list/2012-August/msg00277.html).

Is there any other feature in QEMU that requires QEMU to be run as root?

Quoted 7 lines

Well those features you mention are for two separate issues. When running libvirt privileged (qemu:///system), QEMU was already run as non-root (qemu:qemu). The per-guest user/group was just making sure that QEMU VMs were isolated from each other using user IDs. Since libvirtd is running privileged, it can either set permissions or open things on QEMU's behalf. All this side of things really works already.

Ok good. This is really what I was getting at and you answered my question. So we now have DAC isolation of QEMU guests when running with the qemu:///system URI and there shouldn't be any issues running unprivileged guests from a privileged libvirt.

Quoted 6 lines

The TAP device bridge helper is something that's needed when running libvirtd itself unprivileged (eg the per user qemu:///session libvirtd). In this case libvirtd can't access privileged resources at all, hence the setuid TAP helper was required.

Ah, that's right, the bridge helper is really only benefiting libvirt when running with the qemu:///session URI.

Is there a desire to get to a point where libvirt can do everything under a session URI that it can do today under a system URI? Then libvirt and guests could all run unprivileged. I'm sure it's a lot of work.. I'm just asking. :)

Quoted 5 lines

So I guess this is a roundabout way of saying that I'm not really clear what you're asking about ? If you're using qemu:///system there has never been any problem with running QEMU unprivileged. When using qemu:///session you're obviously limited to whatever resources the user is allowed to access.

Signature · 2 lines
Regards,
Corey Bryant
#5 lore raw
Quoted 36 lines · Corey Bryant
Quoted 13 lines · Daniel P. Berrange
Quoted 11 lines · Corey Bryant

Are there any other requirements that need to be taken care of to enable execution of QEMU guests under separate unprivileged user IDs (ie. DAC isolation)?

At this point, this patch series (Per-guest configurable user/group
for QEMU processes) is upstream, allowing libvirt to execute guests
under separate unprivileged user IDs. Additionally, the QEMU bridge
helper series is upstream, allowing QEMU to allocate a tap device
and attach it to a bridge when run under an unprivileged user ID (http://www.redhat.com/archives/libvir-list/2012-August/msg00277.html).

Is there any other feature in QEMU that requires QEMU to be run as root?

Quoted 7 lines

Well those features you mention are for two separate issues. When running libvirt privileged (qemu:///system), QEMU was already run as non-root (qemu:qemu). The per-guest user/group was just making sure that QEMU VMs were isolated from each other using user IDs. Since libvirtd is running privileged, it can either set permissions or open things on QEMU's behalf. All this side of things really works already.

Ok good. This is really what I was getting at and you answered my question. So we now have DAC isolation of QEMU guests when running with the qemu:///system URI and there shouldn't be any issues running unprivileged guests from a privileged libvirt.

Quoted 6 lines

The TAP device bridge helper is something that's needed when running libvirtd itself unprivileged (eg the per user qemu:///session libvirtd). In this case libvirtd can't access privileged resources at all, hence the setuid TAP helper was required.

Quoted 7 lines

Ah, that's right, the bridge helper is really only benefiting libvirt when running with the qemu:///session URI.

Is there a desire to get to a point where libvirt can do everything under a session URI that it can do today under a system URI? Then libvirt and guests could all run unprivileged. I'm sure it's a lot of work.. I'm just asking. :)

Well if you want to give a VM a raw block device someone/thing needs to be running privileged to set an ACL on the device to le the unprivileged VM use it. Similarly for PCI device passthrough. Traditionally in the qemu:///system case, libvirt can deal with this. In a qemu:///session case the sysadmin would have had to setup ACLs/permissions on the devices / files ahead of time.

Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#6 lore raw
Quoted 45 lines · Daniel P. Berrange
Quoted 36 lines · Corey Bryant
Quoted 13 lines · Daniel P. Berrange
Quoted 11 lines · Corey Bryant

Are there any other requirements that need to be taken care of to enable execution of QEMU guests under separate unprivileged user IDs (ie. DAC isolation)?

At this point, this patch series (Per-guest configurable user/group
for QEMU processes) is upstream, allowing libvirt to execute guests
under separate unprivileged user IDs. Additionally, the QEMU bridge
helper series is upstream, allowing QEMU to allocate a tap device
and attach it to a bridge when run under an unprivileged user ID (http://www.redhat.com/archives/libvir-list/2012-August/msg00277.html).

Is there any other feature in QEMU that requires QEMU to be run as root?

Quoted 7 lines

Well those features you mention are for two separate issues. When running libvirt privileged (qemu:///system), QEMU was already run as non-root (qemu:qemu). The per-guest user/group was just making sure that QEMU VMs were isolated from each other using user IDs. Since libvirtd is running privileged, it can either set permissions or open things on QEMU's behalf. All this side of things really works already.

Ok good. This is really what I was getting at and you answered my question. So we now have DAC isolation of QEMU guests when running with the qemu:///system URI and there shouldn't be any issues running unprivileged guests from a privileged libvirt.

Quoted 6 lines

The TAP device bridge helper is something that's needed when running libvirtd itself unprivileged (eg the per user qemu:///session libvirtd). In this case libvirtd can't access privileged resources at all, hence the setuid TAP helper was required.

Quoted 7 lines

Ah, that's right, the bridge helper is really only benefiting libvirt when running with the qemu:///session URI.

Is there a desire to get to a point where libvirt can do everything under a session URI that it can do today under a system URI? Then libvirt and guests could all run unprivileged. I'm sure it's a lot of work.. I'm just asking. :)

Quoted 6 lines

Well if you want to give a VM a raw block device someone/thing needs to be running privileged to set an ACL on the device to le the unprivileged VM use it. Similarly for PCI device passthrough. Traditionally in the qemu:///system case, libvirt can deal with this. In a qemu:///session case the sysadmin would have had to setup ACLs/permissions on the devices / files ahead of time.

Perhaps these are things that could eventually be taken care of by a setuid root helper with reduced capabilities, allowing libvirt to run unprivileged.

Signature · 2 lines
Regards,
Corey Bryant