Skip to content

shim/manager: Detect custom AppArmor profile to allow userns creation#144

Merged
akerouanton merged 1 commit intocontainerd:mainfrom
vvoland:detect-apparmor
Apr 3, 2026
Merged

shim/manager: Detect custom AppArmor profile to allow userns creation#144
akerouanton merged 1 commit intocontainerd:mainfrom
vvoland:detect-apparmor

Conversation

@vvoland
Copy link
Copy Markdown
Contributor

@vvoland vvoland commented Apr 3, 2026

When kernel.apparmor_restrict_unprivileged_userns=1, check /proc/self/attr/current for a profile name containing the binary name.

If found, we are likely running under a custom AppArmor profile that relaxes the userns restriction, so proceed with namespace creation instead of skipping it.

When kernel.apparmor_restrict_unprivileged_userns=1, check
/proc/self/attr/current for a profile name containing the binary name.

If found, we are likely running under a custom AppArmor profile that
relaxes the userns restriction, so proceed with namespace creation
instead of skipping it.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@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 updates the Linux shim manager’s mount namespace setup logic to better handle Ubuntu-style AppArmor gating of unprivileged user namespace creation, by attempting to detect when the shim is running under a custom AppArmor profile that may allow userns even when the global sysctl is enabled.

Changes:

  • Extend apparmorRestrictsUserns() to treat kernel.apparmor_restrict_unprivileged_userns=1 as non-blocking when a “custom” AppArmor profile is detected.
  • Add runningUnderCustomProfile() to inspect /proc/self/attr/current and heuristically match the profile name against the current binary name.

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

@akerouanton akerouanton merged commit 78e2732 into containerd:main Apr 3, 2026
16 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