Repository navigation
contrib/apparmor: allow signals/ptrace for stacked-label exec processes - #13905
partiallymaxi wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the default AppArmor profile template to handle Linux kernels where AppArmor label stacking causes runtime exec sessions to run under a stacked label (<profile>//&unconfined). This prevents signal and ptrace denials between exec-spawned processes and the container’s init tree under the same base profile.
Changes:
- Add
signalpeer rules allowing stacked-label ({{.Name}}//&unconfined) tasks to signal each other and non-stacked tasks under the same profile. - Add matching
ptracepeer rules for the same stacked-label exec session case.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
16c942e to
fb89396
Compare
fb89396 to
b1753cd
Compare
|
We hit the same bug from different directions. I've written up the coverage comparison in #12887, including a live-kernel table, since the two are easier to judge side by side than separately. Short version: the literal |
On kernels with AppArmor label stacking enabled by default (>= 6.17), processes entered through the runtime exec API carry the stacked label "<profile>//&unconfined" while the container's init tree carries the plain "<profile>" label. The template's peer rules only match the plain label, so every signal sent by an exec-spawned process is denied with EPERM, including root killing its own child, a process signalling itself, and timeout(1) killing its timed-out command. Exec-based probes, debugging sessions, and clients that signal their own children break (observed live: Slurm's srun wedging forever at exit). The abi <abi/3.0> pin does not help: signal mediation is part of the 3.0 ABI, and the pin changes mediation semantics, not the task's label, so peer string matching against the stacked label still fails. Verified on Ubuntu 25.10 (kernel 6.17.0-40, stacking default-on) via aa-exec stacked-label repro: unpatched rules deny kill of own child and self-signal from the stacked label; patched rules restore both, plain-label behavior unchanged, and stacked tasks still cannot signal unconfined (host) processes. Signed-off-by: Maxi Saparov <[email protected]>
b1753cd to
2e3ace0
Compare
| # Exec sessions carry a stacked label on kernels with label stacking (>= 6.17). | ||
| signal (send,receive) peer="{{.Name}}//&unconfined", |
|
PR needs rebase. DetailsInstructions 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. |
|
closing in favor of #12887 |
On kernels with AppArmor label stacking enabled by default (>= 6.17), processes entered through the runtime exec API carry the stacked label
<profile>//&unconfined, while the container's init tree keeps the plain<profile>label. The profile's peer rules only match the plain label, so every signal sent by an exec-spawned process is denied, including root killing its own child and a process signalling itself.This breaks
timeout(1), exec-based debugging, and any exec'd client that signals its own children (observed: Slurm'ssrunwedging at exit).The
abi <abi/3.0>pin from #12864 doesn't help: signal mediation is part of the 3.0 ABI, and the pin changes mediation semantics, not the task's label. This PR adds symmetric signal and ptrace peer rules for the stacked label. Related: #12726, k3s-io/k3s#13625, moby/moby#47720.Repro (containerd 2.1.4 / kernel 7.0; passes on 1.7.2 / kernel 6.5):
Verified on Ubuntu 25.10 (kernel 6.17.0-40) by driving the labels directly with
aa-exec: unpatched rules deny kill-own-child and self-signal from the stacked label; patched rules restore both, plain-label behavior is unchanged, and stacked tasks still cannot signal unconfined (host) processes.Security considerations: the new peer string matches only tasks whose entire label is
<profile>//&unconfined, i.e. the runtime-exec sessions themselves. Host processes (plainunconfined) do not match and gain nothing new; the scope mirrors the existingpeer=<profile>rule, and ptrace remains gated by Yama and capability checks.Happy to switch to the glob form (
peer="<profile>//**") if preferred; the explicit stack is the minimal grant matching what the kernel emits today. A cherry-pick torelease/2.1would be appreciated (affected fleet runs 2.1.4).