Adjust privileges allowed to the libvirt management daemon and QEMU processes to improve security and features
- Name: Daniel Berrange
- email: firstname.lastname@example.org
- Targeted release: Fedora 12
- Last updated: 2009-07-15
- Percentage of completion: 50%
The libvirtd daemon and QEMU driver has two modes of operation:
- A single system instance per machine, that runs with root privileges, launches QEMU instances as root, can use TAP device networking for QEMU, and has full storage and network management capabilities
- Fully unprivileged instances, which run as the same UID as the user accessing the API, but have a significantly reduced level of functionality.
The goals of this feature are to reduce the privileges of the system instance to improve its security, and increase the functionality of the per-user session instances to enable their use in preference to the system instance where practical.
Benefit to Fedora
Reducing the privileges of the libvirt system instance will improve the security of a critical piece of infrastructure. Increasing the functionality of the session instance, will allow more widespread usage. By reducing the scenarios in which the system instance is needed, it will also improve security, since the session instance has far less privileges. Running everything as the same user account will also allow for better desktop session integration, particularly for the sound daemon, and facilitate usage of user home directories for disk image storage.
At this point in F12 schedule, the plan is to run QEMU instances fully unprivileged (non-root, no capabilities), leave libvirtd itself will full capabilities, but a non-root user. Fine grained privileges for libvirtd will be re-examined for F13
- cap-ng: get this new library to be added to Fedora [DONE]
- libvirt: Audit code to determine all files / resources accessed, and document per driver [POSTPONED]
- libvirt: Audit code to determine which capabilities are required for each operation [POSTPONED]
- libvirt: Document functionality vs capability vs user ID tradeoff [POSTPONED]
- libvirtd: ability to switch from root to a less privileged 'libvirtd' account [TODO]
- libvirtd: ability to drop capabilities not used by any driver [POSTPONED]
- libvirtd: configurable ability to drop even more capabilities used by certain drivers, reducing available functionality [POSTPONED]
- libvirt QEMU: ability to spawn QEMU instances as a non-root user / group ID (requires chown'ing of resources) [TODO]
- libvirt QEMU: ability to drop capabilities before exec'ing QEMU instances. [DONE]
- qemu: add a kvm or qemu user and group ID, and use to set /dev/kvm group ownership [TODO]
- qemu: make /dev/kvm mod 666 by default to allow any user access to hardware acceleration [TODO]
- libvirt QEMU: figure out a way to allow use of TAP devices for networking of non-root guests by non-root unprivileged libvirtd [POSTPONED]
- virt-manager: switch to using qemu:///session by default to local desktop scenarios [POSTPONED]
How To Test
XXX this is too simplistic. When capabilities are in use, user ID is not good enough check of actual privileges,cf /proc/$PID/status CapXXX fields
- Verify that when using 'qemu:///system', no QEMU processes run as root
- Verify that the 'libvirtd' daemon started from init is not running as root
- Using qemu:///session provision a new guest, and verify that it is able to use hardware acceleration
- Verify that when running virt-manager for first time as a new user, it defaults to qemu:///session
All virtual machines run by virt-manager on a local desktop install will be running under their user account. All virt-manager machiens run on a server install will running as an reduced privilege system account.
Scope extends to at last
This functionality is incrementally building on existing functionality. No existing functionality will be lost, so if problems are encountered, new features can be dropped or postponed to later Fedora releases.
Documentation will magically come into existance as the features are developed in the upstream apps
FIXME To be written once the new features actually exist.