[PATCH 0/2] apparmor: add missing permissions for passt-backed net interface
Hi, This short series fixes two AppArmor denials that stop <interface> devices using <backend type='passt'/> from working when libvirt confines QEMU with AppArmor. Both changes are in src/security/apparmor/libvirt-qemu. Patch 1: Allow passt to mmap its own binary. Once libvirt runs passt, it transitions into the "passt" subprofile. That subprofile only grants 'r' on /usr/bin/passt, but the binary also has to be memory-mapped. AppArmor mediates this with 'm', so passt was denied (operation="file_mmap", requested_mask="rm") and the interface could not be set up. The patch changes the rule to 'rm'. Patch 2: Allow QEMU to access the passt socket. passt creates its unix socket (path from qemuPasstCreateSocketPath()) under /run/libvirt/qemu/passt/. The "passt" subprofile lets passt create it, but the libvirt-qemu profile did not let QEMU connect to it. QEMU was denied 'wr' on /run/libvirt/qemu/passt/*.socket. The patch adds "/run/libvirt/qemu/passt/*.socket rw," to the main profile. Together, the two patches let a VM with a passt-backed network device start under AppArmor. Hector Cao (2): apparmor: Allow passt to mmap its own binary apparmor: Allow QEMU to access the passt socket src/security/apparmor/libvirt-qemu | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.53.0
From: Hector Cao <hector.cao@canonical.com> The passt subprofile only grants read access to /usr/bin/passt. Once libvirt executes passt and it transitions into this subprofile, the binary also needs to be memory-mapped, which AppArmor mediates with the 'm' permission. Without it, passt is denied and the passt-backed interface cannot be set up: apparmor="DENIED" operation="file_mmap" class="file" profile="libvirt-794a597c-8a5d-436f-b13e-60c348b048f1" name="/usr/bin/passt" pid=18206 comm="passt" requested_mask="rm" denied_mask="rm" fsuid=64055 ouid=0 Grant 'm' in addition to 'r' on /usr/bin/passt in the passt subprofile. Signed-off-by: Hector Cao <hector.cao@canonical.com> --- src/security/apparmor/libvirt-qemu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/security/apparmor/libvirt-qemu b/src/security/apparmor/libvirt-qemu index 4c6e5689c8..c977424023 100644 --- a/src/security/apparmor/libvirt-qemu +++ b/src/security/apparmor/libvirt-qemu @@ -210,7 +210,7 @@ /usr/bin/passt Cx -> passt, profile passt flags=(attach_disconnected) { - /usr/bin/passt r, + /usr/bin/passt rm, signal (receive) set=("term") peer=/usr/sbin/libvirtd, signal (receive) set=("term") peer=libvirtd, -- 2.53.0
From: Hector Cao <hector.cao@canonical.com> For network device with <backend type='passt'/>, QEMU VM needs to connect to the unix socket created by passt (the socket path is created at qemuPasstCreateSocketPath()). The passt subprofile allows passt itself to create the socket, but the libvirt-qemu profile does not allow QEMU to connect to it, resulting in: apparmor="DENIED" operation="connect" class="file" profile="libvirt-d0132c94-8f89-4117-b668-9bfbb2902a0a" name="/run/libvirt/qemu/passt/5-ubuntu-cloud-vm-pass-net0.socket" pid=6995 comm="io-task-worker" requested_mask="wr" denied_mask="wr" fsuid=64055 ouid=64055 Signed-off-by: Hector Cao <hector.cao@canonical.com> --- src/security/apparmor/libvirt-qemu | 1 + 1 file changed, 1 insertion(+) diff --git a/src/security/apparmor/libvirt-qemu b/src/security/apparmor/libvirt-qemu index c977424023..5e70b5daa1 100644 --- a/src/security/apparmor/libvirt-qemu +++ b/src/security/apparmor/libvirt-qemu @@ -208,6 +208,7 @@ # support for passt network back-end /usr/bin/passt Cx -> passt, + /run/libvirt/qemu/passt/*.socket rw, profile passt flags=(attach_disconnected) { /usr/bin/passt rm, -- 2.53.0
participants (1)
-
Hector Cao