Repository navigation
apparmor: allow signals and ptrace for stacked profile peers - #14487
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
The AppArmor signal and ptrace changes need runtime validation on an affected Ubuntu host and compatibility checks with supported older parsers, since string-rendering tests cannot verify wildcard stacked-peer matching or enforcement.
No open issues 🎉
What changed in this PR
Updates containerd’s default AppArmor profile to allow signaling and tracing between stacked-profile peers, addressing the Ubuntu behavior reported in #14485.
Changes:
- Adds
{{.Name}}//&*peer rules for signal and ptrace permissions while retaining existing unstacked rules. - Adds a template-generation test checking both stacked rules and the existing unstacked signal rule.
| File | Description |
|---|---|
contrib/apparmor/template.go |
Allows signal and ptrace permissions for stacked-profile peers. |
contrib/apparmor/template_test.go |
Tests generation of stacked-peer rules and preservation of the unstacked signal rule. |
Review effort: Balanced
|
FYI - Ran into this after kernel upgrade and cnpg set-up, verified the fix on Ubuntu 26.04 / apparmor 5.0.2 / kernel 7.0.0-42 that peer={{.Name}}//&* matches the stacked peer — signals succeed in both pre-existing and fresh containers, and CloudNativePG's PostgreSQL 18 bootstraps without any per-workload AppArmor override. |
|
I ran into this today on a single-node k3s box (k3s v1.37.1, containerd v2.3.4-k3s1, Ubuntu 26.04). After a reboot my CloudNativePG primary never came back. Postgres logged "ready to accept connections", but every new connection got stuck in What confused me at first was that I hadn't changed anything AppArmor-related. For now I've set Since the review note asked about older parsers, I cherry-picked this PR onto current main (aefce4e). It applies cleanly and the package tests pass. I then rendered the default profile with the same inputs
A couple of small things I noticed:
Also, would it be possible to backport this to 2.3.x? That's what k3s ships, and they closed k3s-io/k3s#13625 until there's an upstream release with the fix. |
Kernel 7.0.0-42 makes runc stack the containerd profile with unconfined, so processes in a container cannot signal each other and Postgres never starts (authentik, immich, n8n, sonarqube down). Set kernel.apparmor_restrict_unprivileged_unconfined=0 until k3s ships the containerd fix (containerd/containerd#14487, k3s-io/k3s#13625). Co-authored-by: Yanis Kouidri <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
|
/cherry-pick release/2.4 |
|
@AkihiroSuda: new pull request created: #14589 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@AkihiroSuda: new pull request created: #14590 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@AkihiroSuda: new pull request created: #14591 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Fixes #14485
On Ubuntu,
apparmor_restrict_unprivileged_unconfined=1turns runc'schange_onexecinto a stack. Container tasks are then labeledcri-containerd.apparmor.d//&unconfined. The default profile only allowssignalandptracefor the literal profile name, so processes in the same container cannot signal each other (could not signal for checkpoint: Permission deniedfrom PostgreSQL).Allow the exact stacked peer
{{.Name}}//&unconfinedfor the samesignalandptracepermissions the unstacked name already has. The test requires both exact stacked rules, preserves the unstacked permissions, and rejects wildcard stacked peers. The template comment now describes the kernel restriction instead of tying the behavior to a userspace AppArmor version.Validation on Linux/arm64 with Go 1.24.13:
The updated regression test fails against the previous wildcard rules and passes with the narrowed rules. Formatting and whitespace checks pass. AppArmor parsers 2.13.6, 3.0.8, and 4.1.0 each accept 16 generated profiles covering two profile names, two daemon profiles, optional RootlessKit, and optional policy includes (48 parser checks in total, using
apparmor_parser -Q -K).Runtime enforcement on an affected Ubuntu kernel has not been revalidated for the narrowed rules.
AI assistance: Codex.