apparmor should be allowed to start in containers
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
apparmor (Ubuntu) |
Fix Released
|
High
|
Tyler Hicks | ||
Trusty |
Fix Released
|
High
|
Unassigned | ||
Xenial |
Fix Released
|
High
|
Tyler Hicks | ||
upstart (Ubuntu) |
Invalid
|
Undecided
|
Unassigned | ||
Trusty |
Won't Fix
|
High
|
Unassigned |
Bug Description
=apparmor and upstart 14.04 SRU=
[Impact]
A recent 16.04 kernel (4.4.0-46.67) and the lxd (2.0.5-
[Test Case]
Install the latest Xenial kernel and lxd. Reboot into the new kernel and set up a new 14.04 lxd container (MUST be an unprivileged container):
$ lxc launch ubuntu-daily:14.04 t
Install apparmor from trusty-proposed (2.10.95-
Verify that the container's dhclient is confined inside of an AppArmor namespace with a stacked profile that was loaded inside of the container:
$ ps auxZ | grep '^lxd-t_
lxd-t_<
Verify that aa-status works inside of the container:
$ lxc exec t -- aa-status
apparmor module is loaded.
4 profiles are loaded.
4 profiles are in enforce mode.
/sbin/dhclient
/usr/
/usr/
/usr/
0 profiles are in complain mode.
1 processes have profiles defined.
1 processes are in enforce mode.
/sbin/dhclient (518)
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.
Now, examine the output of aa-status to verify that the /usr/sbin/tcpdump profile is loaded.
To validate the upstart change, use apparmor-
$ echo "profile lp1628285-test {} " | lxc exec t -- tee /etc/apparmor.
$ lxc exec t -- /lib/init/
$ lxc exec t -- aa-status
apparmor module is loaded.
5 profiles are loaded.
5 profiles are in enforce mode.
/sbin/dhclient
/usr/
/usr/
/usr/
lp1628285-test
0 profiles are in complain mode.
1 processes have profiles defined.
1 processes are in enforce mode.
/sbin/dhclient (518)
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.
$ lxc exec t -- ls /etc/apparmor.
/etc/apparmor.
Now, reboot and then run aa-status again to verify that the output is the same (except for the process ID numbers).
It is also a good test to install ntp and cups-daemon, use aa-status to verify that their profiles are in enforce mode and that their processes are confined. Then reboot and use aa-status to verify the same thing.
[Regression Potential]
The regression potential is relatively high because processes inside of Ubuntu containers can be confined with an additional profile that is loaded inside of the container. This feature was released in Ubuntu 16.10 and 16.04 with no known serious issues so far.
IMPORTANT: There is a known regression that may be seen by users of `lxc exec`. See bug #1641236 for details. Bug #1640868 is pre-existing, doesn't seem to have any negative side-effects, and is not caused by this SRU.
=apparmor 16.04 SRU=
[Impact]
The kernel in xenial-proposed (4.4.0-46.67) and the lxd that has recently migrated from xenial-proposed (2.0.5-
[Test Case]
Install the kernel from xenial-proposed (4.4.0-46.67). Reboot into the new kernel and set up a new xenial lxd container (MUST be an unprivileged container):
$ lxc start ubuntu:16.04 x
Install apparmor from xenial-proposed (2.10.95-
Verify that the container's dhclient is confined inside of an AppArmor namespace with a stacked profile that was loaded inside of the container:
$ ps auxZ | grep '^lxd-x_
lxd-x_<
[Regression Potential]
The regression potential is relatively high because processes inside of Ubuntu containers can be confined with an additional profile that is loaded inside of the container. However, this feature was released in Ubuntu 16.10 with no known issues so far.
=Original Description=
Now that we have support for apparmor namespacing and stacking, unprivileged containers can and should be allowed to load apparmor profiles.
The following changes are needed at least:
- Change the systemd unit to remove the "!container" condition
- Change the apparmor init script, replacing the current simple container check for something along the lines of:
- If /proc/self/
- And /sys/kernel/
- And /sys/kernel/
- Then continue execing the script, otherwise exit 0
John suggested he could add a file which would provide a more reliable way to do this check ^
In either case, we need this change so that containers can behave more like normal systems as far as apparmor is concerned. That change should also be SRUed back to Xenial at the same time the kernel support for stacking is pushed.
This bug is effectively a blocker for snapd inside LXD as without this, snap-confine and snapd itself will not be confined after container restart.
Related branches
Changed in apparmor (Ubuntu): | |
importance: | Undecided → High |
tags: | added: lxd |
Changed in apparmor (Ubuntu): | |
status: | New → Incomplete |
Changed in apparmor (Ubuntu): | |
status: | New → In Progress |
assignee: | nobody → Tyler Hicks (tyhicks) |
Changed in apparmor (Ubuntu): | |
status: | In Progress → Fix Committed |
description: | updated |
Changed in apparmor (Ubuntu Trusty): | |
assignee: | nobody → Tyler Hicks (tyhicks) |
importance: | Undecided → High |
status: | New → In Progress |
no longer affects: | upstart (Ubuntu Xenial) |
Changed in upstart (Ubuntu): | |
status: | New → Invalid |
Changed in upstart (Ubuntu Trusty): | |
status: | New → In Progress |
importance: | Undecided → High |
assignee: | nobody → Tyler Hicks (tyhicks) |
description: | updated |
description: | updated |
description: | updated |
slight revision
/sys/kernel/ security/ apparmor/ features/ domain/ ns_stacked contains yes/no if stacked across policy namespace
/sys/kernel/ security/ apparmor/ features/ domain/ ns_name contains the name of the namespace
as long as lxc sets up a detectable namespace ns_name can be used to detect if it should load or not, as stacking, and stacking across namespaces will start to be used in other ways. So testing for just stack or ns_stack might not be enough