apparmor: no working rule to allow making a mount private
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
AppArmor |
Invalid
|
Medium
|
Unassigned | ||
lxc (Ubuntu) |
Fix Released
|
High
|
Stéphane Graber |
Bug Description
NOTE: This bug will be fixed with an update to lxc. However, two AppArmor bugs (bug #1401619 and bug #1401621) were identified as a result of triaging this bug and they will both be fixed in upstream AppArmor.
When the file system is mounted as MS_SHARED by default (such as under systemd, or when the admin configures it so), things like schroot or LXC need to make their "guest" mounts private. This currently fails under utopic:
$ sudo lxc-create -t busybox -n c1
$ sudo mount --make-rshared /
$ sudo strace -fvvs1024 -e mount lxc-start -n c1
[...]
[pid 10749] mount(NULL, "/", NULL, MS_SLAVE, NULL) = -1 EACCES (Permission denied)
lxc-start: Permission denied - Failed to make / rslave
dmesg says:
audit: type=1400 audit(140682500
unt" info="failed flags match" error=-13 profile=
mm="lxc-start" flags="rw, slave"
(This happens for all mount points on your system, I'm just showing the first one)
This will leave a couple of leaked mounts on your system. This is an useful rune to clean them up:
$ for i in 1 2 3; do sudo umount `mount|grep lxc|awk '{print $3}'`; done
(needs to be done several times; check with "mount |grep lxc" that it's clean)
I tried to allow that by adding this to /etc/apparmor.
mount options=(rw, slave) -> **,
then reload the policy and rety with
$ sudo stop lxc; sudo start lxc; sudo lxc-start -n c1
(and again clean up the mounts with above rune)
I tried some variations of this, like
mount options in (rw, slave, rslave, shared, rshared) -> **,
but none of them worked. The only things that do work are one of
mount,
mount -> **,
but those are too lax to be an effective security restriction.
WORKAROUND
==========
(Attention: insecure! Don't use for production machines)
Add this to /etc/apparmor.
mount,
ProblemType: Bug
DistroRelease: Ubuntu 14.10
Package: linux-image-
ProcVersionSign
Uname: Linux 3.16.0-6-generic x86_64
ApportVersion: 2.14.5-0ubuntu1
Architecture: amd64
AudioDevicesInUse:
USER PID ACCESS COMMAND
/dev/snd/
CurrentDesktop: Unity
Date: Thu Jul 31 18:58:18 2014
EcryptfsInUse: Yes
InstallationDate: Installed on 2014-02-27 (154 days ago)
InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Alpha amd64 (20140224)
MachineType: LENOVO 2324CTO
ProcFB: 0 inteldrmfb
ProcKernelCmdLine: BOOT_IMAGE=
RelatedPackageV
linux-
linux-
linux-firmware 1.132
SourcePackage: linux
UpgradeStatus: No upgrade log present (probably fresh install)
dmi.bios.date: 07/09/2013
dmi.bios.vendor: LENOVO
dmi.bios.version: G2ET95WW (2.55 )
dmi.board.
dmi.board.name: 2324CTO
dmi.board.vendor: LENOVO
dmi.board.version: 0B98401 Pro
dmi.chassis.
dmi.chassis.type: 10
dmi.chassis.vendor: LENOVO
dmi.chassis.
dmi.modalias: dmi:bvnLENOVO:
dmi.product.name: 2324CTO
dmi.product.
dmi.sys.vendor: LENOVO
Changed in linux (Ubuntu): | |
assignee: | nobody → John Johansen (jjohansen) |
status: | New → Confirmed |
description: | updated |
Changed in apparmor: | |
importance: | Undecided → Medium |
status: | New → Confirmed |
Changed in linux (Ubuntu): | |
importance: | Undecided → Medium |
Changed in lxc (Ubuntu): | |
importance: | Undecided → Medium |
tags: | added: smoosh |
tags: | added: canonical-bootstack |
Changed in lxc (Ubuntu): | |
status: | Triaged → Fix Committed |
no longer affects: | linux (Ubuntu) |
I tested this on trusty's 3.13.0-32, and the previous utopic 3.15.0-6, same result. So it's not a regression apparently; although I tried "mount options=(rw, slave) -> /" some weeks ago and it appeared to work, but apparently I did something weird back then which made it work, but I can't remember how any more.