apparmor unconfined profile blocks pivot_root
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
AppArmor |
Confirmed
|
Undecided
|
Unassigned | ||
apparmor (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
SRU Justification:
[Impact]
Ubuntu sauce commit "apparmor: convert easy uses of unconfined() to label_mediates()" was applied to Noble and Oracular respectively as dc757a645cfa ("UBUNTU: SAUCE: apparmor4.0.0 [81/90]: apparmor: convert easy uses of unconfined() to label_mediates()") and 621bcec8dae4 ("UBUNTU: SAUCE: apparmor4.0.0 [80/99]: apparmor: convert easy uses of unconfined() to label_mediates()"). This commit prevents the launching of Docker containers inside a LXC container because apparmor unconfined profile blocks pivot_root. It also blocks containers that uses an old apparmor version (e.g. 2.7) to get an IPV4 address through DHCP.
[Fix]
Noble:
- Backport a revert of commit dc757a645cfa ("UBUNTU: SAUCE: apparmor4.0.0 [81/90]: apparmor: convert easy uses of unconfined() to label_mediates()")
Oracular:
- Backport a revert of commit 621bcec8dae4 ("UBUNTU: SAUCE: apparmor4.0.0 [80/99]: apparmor: convert easy uses of unconfined() to label_mediates()")
[Test Plan]
This fix can be tested in Noble and Oracular by running docker in LXC and checking how they behave, as below:
1/ Install LXD on a 24.04 machine
2/ Run a LXD container with support for security.nesting
3/ In the LXD container install docker.io
4/ Run a Docker container
With this patch applied, the docker container will work instead of failing with the following error:
```
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error jailing process inside rootfs: pivot_root .: permission denied: unknown.
ERRO[0000] error waiting for container:
```
The other issue related to old apparmor versions not supporting ABIs can be tested by running:
```
$ lxc launch ubuntu:12.04
$ lxc list status=running
```
and checking that the IPV4 field is non-null in the newly-started container
[Where problems could occur]
This revert backport is small and returns to the old tested behavior. Hence, this SRU should not cause problems.
[Changes between v2 and v3]
- Create separate patches for Noble and Oracular.
- Fix patch corruption in v2.
[Other Info]
External links:
- https:/
- https:/
-------
Original description:
LXD team have got a report (https:/
After some investigation, it was discovered that problem connected with AppArmor profile which is shipped by default /etc/apparmor.
This profile is unconfined and should give all permissions to the runc daemon. But it does not work.
Manual adding of "pivot_root," line and executing "systemctl reload apparmor.service" makes it work.
After some further investigation it was found that on upstream Linux kernel problem is not reproducible.
Our team was able to find a problematic commit:
https:/
The following (partial) revert helps to solve the issue on Ubuntu kernel:
diff --git a/security/
index 74b7293ab971.
--- a/security/
+++ b/security/
@@ -678,7 +678,7 @@ static struct aa_label *build_
- if (!RULE_
+ if (profile_
error = aa_path_
System info:
# uname -a
Linux ubuntu 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04 LTS"
<CUT>
tags: |
added: verification-done-noble-linux removed: verification-needed-noble-linux |
This requires a v4.0 apparmor parser and Ubuntu not upstream kernel.
The ubuntu kernel carries a patch that is work toward splitting unconfined and making so it can replaced and only cause mediation overhead for the classes being mediated.
The 4.0 parser is setting mediated classes in unconfined profiles when it shouldn't, causing pivot root to fail.