]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu_cgroup: Don't deny devices from cgroupDeviceACL
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 15 Mar 2022 11:45:54 +0000 (12:45 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 16 Mar 2022 12:22:17 +0000 (13:22 +0100)
On domain startup a couple of devices are allowed in the devices
controller no matter the domain configuration. The aim is to
allow devices crucial for QEMU or one of its libraries, or user
is passing through a device (e.g. through additional cmd line
arguments) and wants QEMU to access it.

However, during unplug it may happen that a device is configured
to use one of such devices and since we deny /dev nodes on
hotplug we would deny such device too. For example,
/dev/urandom belongs onto the list of implicit devices and users
can hotplug and hotunplug an RNG device with /dev/urandom as
backend.

The fix is fortunately simple - just consult the list of implicit
devices before removing the device from the namespace.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/qemu/qemu_cgroup.c

index c46e7878bce2c19a24328ebbf3e152b9364d64c3..aa0c927578eb1e84f1fd6c55d4ddada6275c8e53 100644 (file)
@@ -81,8 +81,19 @@ qemuCgroupDenyDevicePath(virDomainObj *vm,
                          bool ignoreEacces)
 {
     qemuDomainObjPrivate *priv = vm->privateData;
+    g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
+    const char *const *deviceACL = (const char *const *)cfg->cgroupDeviceACL;
     int ret;
 
+    if (!deviceACL)
+        deviceACL = defaultDeviceACL;
+
+    if (g_strv_contains(deviceACL, path)) {
+        VIR_DEBUG("Skipping deny of path %s in CGroups because it's in cgroupDeviceACL",
+                  path);
+        return 0;
+    }
+
     VIR_DEBUG("Deny path %s, perms: %s",
               path, virCgroupGetDevicePermsString(perms));