]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
apparmor: Allow bind-mounts and {r}shared/{r}private 1055/head
authorStéphane Graber <stgraber@ubuntu.com>
Thu, 23 Jun 2016 20:01:29 +0000 (16:01 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 23 Jun 2016 20:01:29 +0000 (16:01 -0400)
Bind-mounts aren't harmful in containers, so long as they're not used to
bypass MAC policies.

This change allows bind-mounting of any path which isn't a dangerous
filesystem that's otherwise blocked by apparmor.

This also allows switching paths {r}shared or {r}private.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
config/apparmor/abstractions/container-base
config/apparmor/abstractions/container-base.in

index fe24ff32b5d625d62e1268c5c50981daff4fa49d..9452f6608e3bd4879815a5b0c76085603b83d768 100644 (file)
   mount fstype=fuse,
   mount fstype=fuse.*,
 
-  # allow bind mount of /lib/init/fstab for lxcguest
-  mount options=(rw, bind) /lib/init/fstab.lxc/ -> /lib/init/fstab/,
-
-  # allow bind mounts of /run/{,lock} to /var/run/{,lock}
-  mount options=(rw, bind) /run/ -> /var/run/,
-  mount options=(rw, bind) /run/lock/ -> /var/lock/,
-
   # deny access under /proc/bus to avoid e.g. messing with pci devices directly
   deny @{PROC}/bus/** wklx,
 
   # deny reads from debugfs
   deny /sys/kernel/debug/{,**} rwklx,
 
+  # allow paths to be made shared, rshared, private or rprivate
+  mount options=(rw,shared) -> /,
+  mount options=(rw,shared) -> /**,
+
+  mount options=(rw,rshared) -> /,
+  mount options=(rw,rshared) -> /**,
+
+  mount options=(rw,private) -> /,
+  mount options=(rw,private) -> /**,
+
+  mount options=(rw,rprivate) -> /,
+  mount options=(rw,rprivate) -> /**,
+
+  # allow bind-mounts of anything except /proc, /sys and /dev
+  mount options=(rw,bind) /[^spd]*{,/**},
+  mount options=(rw,bind) /d[^e]*{,/**},
+  mount options=(rw,bind) /de[^v]*{,/**},
+  mount options=(rw,bind) /dev/.[^l]*{,/**},
+  mount options=(rw,bind) /dev/.l[^x]*{,/**},
+  mount options=(rw,bind) /dev/.lx[^c]*{,/**},
+  mount options=(rw,bind) /dev/.lxc?*{,/**},
+  mount options=(rw,bind) /dev/[^.]*{,/**},
+  mount options=(rw,bind) /dev?*{,/**},
+  mount options=(rw,bind) /p[^r]*{,/**},
+  mount options=(rw,bind) /pr[^o]*{,/**},
+  mount options=(rw,bind) /pro[^c]*{,/**},
+  mount options=(rw,bind) /proc?*{,/**},
+  mount options=(rw,bind) /s[^y]*{,/**},
+  mount options=(rw,bind) /sy[^s]*{,/**},
+  mount options=(rw,bind) /sys?*{,/**},
+
   # generated by: lxc-generate-aa-rules.py container-rules.base
   deny /proc/sys/[^kn]*{,/**} wklx,
   deny /proc/sys/k[^e]*{,/**} wklx,
index 550625c155378f820c302779f0bdf943a4ffee2e..68db43db4abcefb35884606c98290ea7d6c51c6a 100644 (file)
   mount fstype=fuse,
   mount fstype=fuse.*,
 
-  # allow bind mount of /lib/init/fstab for lxcguest
-  mount options=(rw, bind) /lib/init/fstab.lxc/ -> /lib/init/fstab/,
-
-  # allow bind mounts of /run/{,lock} to /var/run/{,lock}
-  mount options=(rw, bind) /run/ -> /var/run/,
-  mount options=(rw, bind) /run/lock/ -> /var/lock/,
-
   # deny access under /proc/bus to avoid e.g. messing with pci devices directly
   deny @{PROC}/bus/** wklx,
 
   # deny reads from debugfs
   deny /sys/kernel/debug/{,**} rwklx,
 
+  # allow paths to be made shared, rshared, private or rprivate
+  mount options=(rw,shared) -> /,
+  mount options=(rw,shared) -> /**,
+
+  mount options=(rw,rshared) -> /,
+  mount options=(rw,rshared) -> /**,
+
+  mount options=(rw,private) -> /,
+  mount options=(rw,private) -> /**,
+
+  mount options=(rw,rprivate) -> /,
+  mount options=(rw,rprivate) -> /**,
+
+  # allow bind-mounts of anything except /proc, /sys and /dev
+  mount options=(rw,bind) /[^spd]*{,/**},
+  mount options=(rw,bind) /d[^e]*{,/**},
+  mount options=(rw,bind) /de[^v]*{,/**},
+  mount options=(rw,bind) /dev/.[^l]*{,/**},
+  mount options=(rw,bind) /dev/.l[^x]*{,/**},
+  mount options=(rw,bind) /dev/.lx[^c]*{,/**},
+  mount options=(rw,bind) /dev/.lxc?*{,/**},
+  mount options=(rw,bind) /dev/[^.]*{,/**},
+  mount options=(rw,bind) /dev?*{,/**},
+  mount options=(rw,bind) /p[^r]*{,/**},
+  mount options=(rw,bind) /pr[^o]*{,/**},
+  mount options=(rw,bind) /pro[^c]*{,/**},
+  mount options=(rw,bind) /proc?*{,/**},
+  mount options=(rw,bind) /s[^y]*{,/**},
+  mount options=(rw,bind) /sy[^s]*{,/**},
+  mount options=(rw,bind) /sys?*{,/**},
+