Skip to content

Fix apparmor_restrict_unprivileged_userns=1 with relaxed apparmor profile#143

Merged
akerouanton merged 1 commit intocontainerd:mainfrom
vvoland:shim-nomsg
Apr 3, 2026
Merged

Fix apparmor_restrict_unprivileged_userns=1 with relaxed apparmor profile#143
akerouanton merged 1 commit intocontainerd:mainfrom
vvoland:shim-nomsg

Conversation

@vvoland
Copy link
Copy Markdown
Contributor

@vvoland vvoland commented Apr 3, 2026

When AppArmor restricts user namespace creation or checking the restriction fails, the logging calls in cloneMntNs break the TTRPC protocol by writing to stderr during shim initialization.

This causes the shim to fail:

ERROR: failed to create sandbox: create sandbox: create sandbox: run sandbox: start container: container start: Error response from daemon: creating containerd task for container 4677c157669e: failed to start shim: start failed: failed to create TTRPC connection: unsupported protocol: time="2026-04-03T10:29:20+02:00" level=warning msg="apparmor_restrict_unprivileged_userns=1 prevents user namespace creation; shim will run without mount namespace isolation" runtime=io.containerd.nerdbox.v1
{"version":3,"address":"unix

@vvoland vvoland self-assigned this Apr 3, 2026
Copilot AI review requested due to automatic review settings April 3, 2026 08:59
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent shim startup/bootstrap failures when AppArmor restricts unprivileged user namespace creation (or when checking the restriction fails), by avoiding log output during shim initialization that can corrupt the shim bootstrap output consumed by containerd.

Changes:

  • Remove github.com/containerd/log usage from cloneMntNs on Linux.
  • Suppress warning logs when userns restriction is detected or cannot be checked (shim proceeds without mount namespace isolation).
  • Adjust cloneMntNs signature usage to avoid the now-unused ctx variable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

When AppArmor restricts user namespace creation or checking the
restriction fails, the logging calls in cloneMntNs break the TTRPC
protocol by writing to stderr during shim initialization.

This causes the shim to fail:

```
ERROR: failed to create sandbox: create sandbox: create sandbox: run sandbox: start container: container start: Error response from daemon: creating containerd task for container 4677c157669e: failed to start shim: start failed: failed to create TTRPC connection: unsupported protocol: time="2026-04-03T10:29:20+02:00" level=warning msg="apparmor_restrict_unprivileged_userns=1 prevents user namespace creation; shim will run without mount namespace isolation" runtime=io.containerd.nerdbox.v1
{"version":3,"address":"unix
```

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@akerouanton akerouanton merged commit 28c7f89 into containerd:main Apr 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants