libvirt fails with failure to open mount namespace
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libvirt (Debian) |
Fix Released
|
Unknown
|
|||
libvirt (Ubuntu) |
Fix Released
|
Critical
|
Unassigned | ||
Bionic |
Fix Released
|
Undecided
|
Unassigned | ||
Cosmic |
Fix Released
|
Critical
|
Unassigned | ||
linux (Ubuntu) |
In Progress
|
High
|
Thadeu Lima de Souza Cascardo | ||
Bionic |
Confirmed
|
Undecided
|
Unassigned | ||
Cosmic |
In Progress
|
High
|
Thadeu Lima de Souza Cascardo |
Bug Description
[Impact]
* Libvirt will no more be able to start guests with newer kernels
(>=4.18)
* We brought a fix upstream that we want to backport to potentially
affected releases (B+C)
[Test Case]
Note: This can but does not have to be tested in nested virtualization (Since we need to change the kernel it is probably the preferred way to do it in nested, so this is what I describe)
1. Get a KVM guest with the Release to test (Cosmic as an example) and give it a size to be able to host a nested guest
$ sudo apt install uvtool-libvirt
$ uvt-simplestrea
$ uvt-kvm create --cpu 8 --memory 4096 --password ubuntu c-nested-kvm-4.18 arch=amd64 release=cosmic label=daily
$ uvt-kvm ssh c-nested-kvm-4.18
2. In the guest set up another guest
$ uvt-kvm ssh c-nested-kvm-4.18
$ uvt-simplestrea
$ uvt-kvm create --password ubuntu c-nested-guest arch=amd64 release=cosmic label=daily
$ sudo apt install uvtool-libvirt
3. The above will work, now get a kernel >=4.18 e.g. the mainline kernels at
https:/
$ wget (link of the day)
$ sudo dpkg -i *.deb
4. reboot into the 4.18 kernel
$ sudo reboot
5. Start the guest again
$ virsh start c-nested-guest
Without fix this will fail like:
error: Failed to start domain c-nested-guest
error: internal error: child reported: Kernel does not provide mount namespace: Permission denied
And an associated Dmesg/Apparmor entry:
[ 519.529760] audit: type=1400 audit(153536482
6. In the guest update from PPA/Proposed that you want to test to bring in the libvirt package with the updated rules (Example with the PPA).
$ sudo add-apt-repository ppa:ci-
$ sudo apt upgrade
7. Start the guest again and it will now work
$ virsh start c-nested-guest
[Regression Potential]
* The change is "only" opening up the apparmor profile for libvirt a
little bit for the access now being reported as read in addition.
That should in itself be rather regression free, but in addition it has
an ack of Jamie Strandboge to be sure from Securities POV (you can
follow the upstreaming thread at to check:
https:/
[Other Info]
* This is no issue "yet" but would be one when the Cosmic Kernel becomes available as HWE kernel. We'd want to have the apparmor profile in libvirt ready at the time so that we never have users see this error in the Field on a Released Ubuntu version.
---
$ virsh start cosmic-i386
error: Failed to start domain cosmic-i386
error: internal error: child reported: Kernel does not provide mount namespace: Permission denied
Happens with 4.18 only, 4.17 is fine.
27013 openat(AT_FDCWD, "/proc/
Opening a self or parent mount namespace works fine as tested with cat /proc/self/ns/mnt and cat /proc/self/$$/mnt. Still investigating.
Changed in linux (Ubuntu): | |
assignee: | nobody → Thadeu Lima de Souza Cascardo (cascardo) |
importance: | Undecided → High |
status: | New → Confirmed |
status: | Confirmed → In Progress |
description: | updated |
Changed in libvirt (Debian): | |
status: | Unknown → Fix Released |
tags: | added: cscc |
So, investigated this into an apparmor difference between 4.17 and 4.18. This is due to commit 338d0be437ef10e 247a35aed83dbab 182cf406a2 ("apparmor: fix ptrace read check").
libvirtd here is using only trace, and not read. The patch below for libvirtd apparmor policy fixes it for me.
--- /etc/apparmor. d/usr.sbin. libvirtd 2018-08-23 14:52:04.574252908 -0300 sbin.libvirtd 2018-08-23 14:51:46.773728841 -0300 unconfined addr=none),
+++ ../usr.
@@ -50,10 +50,10 @@
# for --p2p migrations
unix (send, receive) type=stream addr=none peer=(label=
- ptrace (trace) peer=unconfined, sbin/libvirtd, sbin/dnsmasq, sbin/libvirtd, sbin/dnsmasq,
- ptrace (trace) peer=/usr/
- ptrace (trace) peer=/usr/
- ptrace (trace) peer=libvirt-*,
+ ptrace (read,trace) peer=unconfined,
+ ptrace (read,trace) peer=/usr/
+ ptrace (read,trace) peer=/usr/
+ ptrace (read,trace) peer=libvirt-*,
signal (send) peer=/usr/ sbin/dnsmasq,
signal (read, send) peer=libvirt-*,