Skip to content

AppArmor: signal rule does not match stacked profile peer on kernel 6.17 #12886

Open

Description

@lexfrei

Description

On kernel 6.17 with AppArmor profile stacking enabled, processes created via CRI ExecSync (kubectl exec, exec-based liveness/readiness probes) run under a stacked profile cri-containerd.apparmor.d//&unconfined instead of plain cri-containerd.apparmor.d.

The signal rule from the AppArmor template (signal (send,receive) peer={{.Name}}) expands to peer=cri-containerd.apparmor.d which does not match the stacked peer name, causing DENIED audit events for SIGURG (Go runtime goroutine preemption).

The abi <abi/3.0> pin from #12864 is already on main and does not fix this issue.

Related to #12726 (same root cause: AppArmor behavior changes on kernel 6.17), different symptom.

Steps to reproduce the issue

  1. Run containerd on kernel 6.17+ with AppArmor stacking enabled (/sys/kernel/security/apparmor/features/domain/stack = yes)
  2. Start any container under the default cri-containerd.apparmor.d profile
  3. Compare AppArmor profiles of PID 1 vs an exec'd process:
$ kubectl exec <pod> -- cat /proc/1/attr/apparmor/current
cri-containerd.apparmor.d (enforce)

$ kubectl exec <pod> -- cat /proc/self/attr/apparmor/current
cri-containerd.apparmor.d//&unconfined (enforce)
  1. If the container has an exec probe that runs a Go binary (Go 1.14+, which uses SIGURG for goroutine preemption), observe AppArmor DENIED entries in dmesg

Tested on two different containers (OpenBao and Authelia) — both show the same profile divergence between PID 1 and exec'd processes.

Describe the results you received and expected

Received: exec'd processes get stacked profile cri-containerd.apparmor.d//&unconfined, and signal self-delivery is denied:

audit: type=1400 apparmor="DENIED" operation="signal" class="signal" profile="cri-containerd.apparmor.d" pid=1814255 comm="bao" requested_mask="send" denied_mask="send" signal=urg peer="cri-containerd.apparmor.d//&unconfined"

The main container process (PID 1) sends SIGURG successfully (verified with strace --trace=tgkill, returns 0). Only exec'd processes trigger denials.

Expected: exec'd processes should have the same effective profile as PID 1. Signal self-delivery within the same container should not be denied.

Verified fix

Adding one line to the AppArmor template in contrib/apparmor/template.go fixes the issue:

  # Container processes may send signals amongst themselves.
  signal (send,receive) peer={{.Name}},
+ # In stacking mode (kernel 6.7+), exec'd processes get a stacked profile.
+ signal (send,receive) peer={{.Name}}//&*,

Tested by manually loading the modified profile with apparmor_parser --replace. After loading, zero new DENIED entries over 56+ seconds (11+ probe cycles at 5s interval), whereas before the fix there were continuous denials every probe cycle.

Note: the same stacking issue likely affects the ptrace rule as well:

  ptrace (trace,tracedby,read,readby) peer={{.Name}},

What version of containerd are you using?

containerd github.com/k3s-io/containerd/v2 v2.1.5-k3s1

Any other relevant information

$ uname -a
Linux k8s-cp-01 6.17.0-1007-raspi #7-Ubuntu SMP PREEMPT_DYNAMIC aarch64 GNU/Linux

$ apparmor_parser --version
AppArmor parser version 5.0.0~alpha1

$ cat /sys/kernel/security/apparmor/features/domain/stack
yes

OS: Ubuntu 25.10 (questing), aarch64

Why only some containers are visibly affected: the issue affects ALL containers (confirmed on OpenBao and Authelia), but only manifests as dmesg spam when a container has an exec probe that spawns a Go binary. Long-running container processes (PID 1) are not affected because they run under the non-stacked profile.

Workaround: set AppArmor profile to Unconfined on affected pods via pod annotation.

Related: #12726, #12864, #4467

Activity

  1. added
    area/cri
    on Feb 10, 2026
  2. added 2 commits that reference this issue on Feb 10, 2026
    0318798
    b65590b
  3. achernya commented on Feb 14, 2026

    @achernya
    Contributor

    I can't reproduce this behavior with the same test harness in which I tested #12864 with the abi/3.0 fix applied.

    root@containerd-test:~# uname -a
    Linux containerd-test 6.17.9-1-pve #1 SMP PREEMPT_DYNAMIC PMX 6.17.9-1 (2026-01-12T16:25Z) x86_64 GNU/Linux
    root@containerd-test:~# cat /sys/kernel/security/apparmor/features/domain/stack
    yes
    root@containerd-test:~# k3s kubectl exec -n argocd argocd-server-6f85b59c87-w6cns -- cat /proc/1/attr/apparmor/current
    cri-containerd.apparmor.d (enforce)
    root@containerd-test:~# k3s kubectl exec -n argocd argocd-server-6f85b59c87-w6cns -- cat /proc/self/attr/apparmor/current
    cri-containerd.apparmor.d (enforce)
    root@containerd-test:~# dpkg -l apparmor
    Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
    |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
    ||/ Name           Version      Architecture Description
    +++-==============-============-============-======================================
    ii  apparmor       4.1.1-pmx1   amd64        user-space parser utility for AppArmor
    

    I also had dmesg -H -W running in another tab while doing this testing and got no dmesg spam.

  4. lexfrei commented on Feb 15, 2026

    @lexfrei
    Author

    @achernya I think the key difference is the AppArmor userspace version, not the kernel itself.

    Your setup:

    • apparmor 4.1.1-pmx1 (Proxmox)

    My setup:

    • apparmor_parser 5.0.0~alpha1 (Ubuntu 25.10 questing)

    Both have domain/stack = yes and kernel 6.17, yet kubectl exec produces different profiles:

    • On your system: cri-containerd.apparmor.d (enforce) (no stacking)
    • On mine: cri-containerd.apparmor.d//&unconfined (enforce) (stacked)

    This suggests that apparmor_parser 5.0.0~alpha1 either compiles the profile differently or changes the default exec transition behavior when stacking is available. The kernel honors domain/stack in both cases, but the compiled policy from 5.0.0 results in unconfined being stacked on top during exec.

    Could you check with apparmor_parser 5.0.0~alpha1 (or any 5.x) to confirm this is the discriminating factor?

    Either way, I'd argue the fix is still worthwhile — the signal peer={{.Name}}//&* rule makes the profile robust against stacking regardless of which parser version produced it. As distros ship AppArmor 5.x (Ubuntu 25.10 already does), this will affect more users.

  5. marnixbouhuis commented on Jun 10, 2026

    @marnixbouhuis

    Similar issue gets triggered over here running Ubuntu 26.04 LTS.

  6. added a commit that references this issue on Jun 12, 2026
    a173e5a
  7. DvdChe commented on Jul 9, 2026

    @DvdChe

    Confirming this on containerd 2.3.1 — the abi/3.0 pin from #12864 does not fix the signal variant, and the impact goes beyond SIGURG audit noise.

    Environment:

    • containerd v2.3.1 (includes the abi <abi/3.0> pin from apparmor: explicitly set abi/3.0 #12864)
    • Kubernetes 1.35.6 (kubeadm/self-managed, AWS EC2)
    • Ubuntu 26.04 LTS, kernel 7.0.0-27-generic, x86_64
    • AppArmor stacking enabled (/sys/kernel/security/apparmor/features/domain/stack = yes)

    Observed: processes created via CRI exec (kubectl exec, ExecSync) run under the stacked label, while container-init descendants keep the plain profile:

    $ cat /proc/self/attr/current          # inside kubectl exec session
    cri-containerd.apparmor.d//&unconfined (enforce)
    $ cat /proc/1/attr/current             # container init descendant
    cri-containerd.apparmor.d (enforce)
    

    Any signal between two exec-spawned processes is denied — including a process signaling its own child:

    $ kubectl exec <pod> -- bash -c 'setsid sleep 5 & kill $! && echo OK || echo BROKEN'
    BROKEN    # kill: Operation not permitted
    

    Signals from exec-spawned processes to init-descendants are allowed, which keeps the bug invisible in day-to-day use.

    Real-world impact beyond SIGURG noise: this breaks PostgreSQL major version upgrades managed by zalando/postgres-operator on Spilo/Patroni clusters. The operator (and the documented manual procedure) runs pg_upgrade via the exec API; pg_upgrade starts a temporary postmaster and then fails to stop it:

    pg_ctl: could not send stop signal (PID: 3041): Permission denied
    

    so the upgrade aborts after all checks pass, and rolls back — on every attempt, including the operator's automated maintenance-window upgrades. It also silently breaks timeout(1) killing its children inside exec sessions (leaked processes), and presumably ptrace-based debugging (strace -p on exec-spawned processes) per the peer rules having the same shape.

    Workaround we used: run the upgrade script from a lineage rooted in container init instead of exec — a one-shot root crontab inside the pod (spilo ships a cron daemon under runit). Jobs spawned by cron get the plain cri-containerd.apparmor.d label and signaling works. Pre-loading a patched cri-containerd.apparmor.d profile on nodes (so containerd skips generating its own) also works as a fleet-wide mitigation.

    Since 2.3.1 already carries the abi pin, this confirms the pin only addresses the unix-socket mediation (#12726) — the peer= label matching for signals still fails against stacked labels. The stacked-peer rules in #12887 are the right direction; based on our testing, receive is affected as well as send, so covering both would be safer.

  8. added 3 commits that reference this issue on Jul 9, 2026
    56af135
    16f6908
    d9ba8c6
  9. added 3 commits that reference this issue on Aug 14, 2026
    96dbd3b
    20cc0d6
    24f370f
  10. adelton commented on Oct 31, 2026

    @adelton

    Any chance of getting either #12887 or #13905 reviewed and merged in some form?

    This bug seems to block various K8s deployments on recent kernels (namely Ubuntu 26.04), judging by the number of issues that refer back here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/crikind/question

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions