]> xenbits.xensource.com Git - libvirt.git/commitdiff
apparmor: allow getattr on usb devices
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>
Thu, 17 Nov 2022 08:35:05 +0000 (09:35 +0100)
committerChristian Ehrhardt <christian.ehrhardt@canonical.com>
Tue, 22 Nov 2022 08:44:16 +0000 (09:44 +0100)
For the handling of usb we already allow plenty of read access,
but so far /sys/bus/usb/devices only needed read access to the directory
to enumerate the symlinks in there that point to the actual entries via
relative links to ../../../devices/.

But in more recent systemd with updated libraries a program might do
getattr calls on those symlinks. And while symlinks in apparmor usually
do not matter, as it is the effective target of an access that has to be
allowed, here the getattr calls are on the links themselves.

On USB hostdev usage that causes a set of denials like:
 apparmor="DENIED" operation="getattr" class="file"
 name="/sys/bus/usb/devices/usb1" comm="qemu-system-x86"
 requested_mask="r" denied_mask="r" ...

It is safe to read the links, therefore add a rule to allow it to
the block of rules that covers the usb related access.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Reviewed-by: Michal Privoznik <mprivozn at redhat.com>
src/security/apparmor/libvirt-qemu

index 02ee273e7e1eb84914bad1e168a4b3bed7ee0320..d0289b8943d01f8f776f6c1a4635ce980d83402a 100644 (file)
@@ -42,6 +42,7 @@
 
   # For hostdev access. The actual devices will be added dynamically
   /sys/bus/usb/devices/ r,
+  /sys/bus/usb/devices/* r,
   /sys/devices/**/usb[0-9]*/** r,
   # libusb needs udev data about usb devices (~equal to content of lsusb -v)
   /run/udev/data/+usb* r,