Public bug reported:

Environment:
- Ubuntu 26.04.1 LTS, kernel 7.0.0-44-generic
- k3s v1.37.2+k3s1 (embedded containerd 2.3.7), default container AppArmor 
profile
  "cri-containerd.apparmor.d" (Kubernetes RuntimeDefault)

Symptoms:
1. Images whose entrypoint uses gosu (postgres, mysql...) hang at startup with 
100% CPU.
   strace shows an endless sched_yield loop: gosu (Go) calls setuid/setgid, the 
Go
   runtime signals every thread and waits for all of them, and the signal is 
denied.
2. PostgreSQL crash recovery fails with "FATAL: could not signal for checkpoint:
   Permission denied", then the container restarts in a loop.
3. Every Go program in a container is silently affected (see below).

Kernel log:
[ 2889.292244] audit: type=1400 audit(1796347356.515:4824): apparmor="DENIED" 
operation="signal" class="signal" profile="cri-containerd.apparmor.d" pid=2675 
comm="node_exporter" requested_mask="send" denied_mask="send" signal=term 
peer="cri-containerd.apparmor.d//&unconfined"
[ 2889.292249] audit: type=1400 audit(1796347356.515:4825): apparmor="DENIED" 
operation="signal" class="signal" profile="cri-containerd.apparmor.d" pid=2675 
comm="node_exporter" requested_mask="send" denied_mask="send" signal=term 
peer="cri-containerd.apparmor.d//&unconfined"
[ 2891.528787] audit: type=1400 audit(1796347358.751:4828): apparmor="DENIED" 
operation="signal" class="signal" profile="cri-containerd.apparmor.d" pid=55176 
comm="node_exporter" requested_mask="send" denied_mask="send" signal=urg 
peer="cri-containerd.apparmor.d//&unconfined"

Analysis:
The containerd profile allows "signal (send,receive) 
peer=cri-containerd.apparmor.d",
but the target processes/threads are labelled 
"cri-containerd.apparmor.d//&unconfined".
The stacked label does not match the peer rule, so signals between processes of 
the
same container are denied.
The lines above come from node_exporter (Go): SIGURG is the Go runtime's async
preemption signal, sent by the process to its own threads. Even a process 
signalling
its own threads is denied. gosu is the case where it blocks completely.
Seen on two different machines running Ubuntu 26.04 (not hardware-specific). A 
user
on the Incus forum reports the same gosu hang on Ubuntu 24.04.

Expected: processes of the same container can signal each other, as the
profile intends.

Workaround: a Localhost profile identical to cri-containerd.apparmor.d but with
"signal (send,receive)," and "ptrace (trace,read,tracedby,readby)," without peer
conditions; or appArmorProfile: Unconfined (not allowed under Pod Security 
"restricted").

Related: LP #2065423 (runc peer signals),
https://discuss.linuxcontainers.org/t/mysql-oci-container-use-100-cpu-without-even-working/24052

** Affects: apparmor (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2190627

Title:
  Signals between processes of the same container denied when the peer
  label is stacked (cri-containerd.apparmor.d//&unconfined)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/2190627/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to