libvirt/src/security
Jim Fehlig 2e8ebfe3fa qemu: Set label on vhostuser net device when hotplugging
Attaching a newly created vhostuser port to a VM fails due to an
apparmor denial

internal error: unable to execute QEMU command 'chardev-add': Failed
to bind socket to /run/openvswitch/vhu838c4d29-c9: Permission denied

In the case of a net device type VIR_DOMAIN_NET_TYPE_VHOSTUSER, the
underlying chardev is not labeled in qemuDomainAttachNetDevice prior
to calling qemuMonitorAttachCharDev.

A simple fix would be to call qemuSecuritySetChardevLabel using the
embedded virDomainChrSourceDef in the virDomainNetDef vhostuser data,
but this incurs the risk of incorrectly restoring the label. E.g.
consider the DAC driver behavior with a vhostuser net device, which
uses a socket for the chardev backend. The DAC driver uses XATTRS to
store original labelling information, but XATTRS are not compatible
with sockets. Without the original labelling information, the socket
labels will be restored with root ownership, preventing other
less-privileged processes from connecting to the socket.

This patch avoids overloading chardev labelling with vhostuser net
devices by introducing virSecurityManager{Set,Restore}NetdevLabel,
which is currently only implemented for the apparmor driver. The
new APIs are then used to set and restore labels for the vhostuser
net devices.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2021-08-26 16:06:45 -06:00
..
apparmor Apparmor: Add profile for virtxend 2021-07-14 09:16:58 -06:00
meson.build meson: Always use the / operator to join paths 2021-08-11 09:16:36 +02:00
security_apparmor.c qemu: Set label on vhostuser net device when hotplugging 2021-08-26 16:06:45 -06:00
security_apparmor.h
security_dac.c util: alloc: Reimplement VIR_APPEND_ELEMENT using virAppendElement 2021-08-06 08:53:25 +02:00
security_dac.h lib: Drop internal virXXXPtr typedefs 2021-04-13 17:00:38 +02:00
security_driver.c lib: Drop internal virXXXPtr typedefs 2021-04-13 17:00:38 +02:00
security_driver.h qemu: Set label on vhostuser net device when hotplugging 2021-08-26 16:06:45 -06:00
security_manager.c qemu: Set label on vhostuser net device when hotplugging 2021-08-26 16:06:45 -06:00
security_manager.h qemu: Set label on vhostuser net device when hotplugging 2021-08-26 16:06:45 -06:00
security_nop.c lib: Drop internal virXXXPtr typedefs 2021-04-13 17:00:38 +02:00
security_nop.h
security_selinux.c security: fix use-after-free in virSecuritySELinuxReserveLabel 2021-08-17 12:07:36 +02:00
security_selinux.h
security_stack.c qemu: Set label on vhostuser net device when hotplugging 2021-08-26 16:06:45 -06:00
security_stack.h lib: Drop internal virXXXPtr typedefs 2021-04-13 17:00:38 +02:00
security_util.c
security_util.h
virt-aa-helper.c Remove redundant labels 2021-08-17 18:27:13 +02:00