Fix apparmor_restrict_unprivileged_userns=1 with relaxed apparmor profile#143
Merged
akerouanton merged 1 commit intocontainerd:mainfrom Apr 3, 2026
Merged
Fix apparmor_restrict_unprivileged_userns=1 with relaxed apparmor profile#143akerouanton merged 1 commit intocontainerd:mainfrom
apparmor_restrict_unprivileged_userns=1 with relaxed apparmor profile#143akerouanton merged 1 commit intocontainerd:mainfrom
Conversation
akerouanton
reviewed
Apr 3, 2026
There was a problem hiding this comment.
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/logusage fromcloneMntNson Linux. - Suppress warning logs when userns restriction is detected or cannot be checked (shim proceeds without mount namespace isolation).
- Adjust
cloneMntNssignature usage to avoid the now-unusedctxvariable.
💡 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
approved these changes
Apr 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: