Skip to content

apparmor: allow change_profile for nested container runtimes#942

Open
Mohataseem89 wants to merge 1 commit into
podman-container-tools:mainfrom
Mohataseem89:main
Open

apparmor: allow change_profile for nested container runtimes#942
Mohataseem89 wants to merge 1 commit into
podman-container-tools:mainfrom
Mohataseem89:main

Conversation

@Mohataseem89

Copy link
Copy Markdown

Problem

Fixes: podman-container-tools/podman#28992"

On kernel 6.17, starting a container via the Docker-compat API
(docker compose / docker CLI pointed at the podman socket) from inside a
systemd/Quadlet-launched container fails with:

crun: `/proc/thread-self/attr/apparmor/exec`: OCI runtime error:
unable to assign security attribute

The outer container runs under containers-default-*. When crun inside
that container tries to write an AppArmor profile name to
/proc/thread-self/attr/apparmor/exec for the child container, the
kernel rejects it because change_profile is not permitted by the outer
container's profile.

Native podman run from the host is unaffected (process is unconfined).
podman --remote is also unaffected. Only the compat API path from
inside a confined systemd container triggers this.

Reported: podman-container-tools/podman#28992
Downstream: moghtech/komodo#1488

Fix

add change_profile -> **, inside the >= 208096 version guard,
alongside the existing signal rules for crun/runc/podman. This gives
OCI runtimes running inside a container permission to assign AppArmor
profiles to their child processes.

Testing

reproduction:

  1. launch a container via Quadlet with --cgroups=split --sdnotify=conmon
    and the host's rootful podman socket bind-mounted.
  2. drom inside that container run docker run alpine echo hi against the
    socket.
  3. without this fix: crun: unable to assign security attribute
  4. with this fix: container starts successfully

@mtrmac mtrmac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/podman-container-tools/container-libs/blob/main/CONTRIBUTING.md#sign-your-prs please, we can’t even really look at PRs with unclear copyright status.

When the podman socket is bind-mounted into a systemd/Quadlet-launched
container and a Docker-compat client (docker compose, docker CLI) inside
that container starts a new container, crun writes the AppArmor profile
name to /proc/thread-self/attr/apparmor/exec. On kernel >= 6.17 this
write fails with 'unable to assign security attribute' because the outer
container's AppArmor profile does not permit change_profile.

Signed-off-by: Mohataseem Khan <mohataseem89@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to "common" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker-compat API container start fails AppArmor assignment (crun: unable to assign security attribute) on kernel 6.17 while native podman works

2 participants