summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorKarl Mehltretter <kmehltretter@gmail.com>2026-11-24 04:16:42 +0100
committerTejun Heo <tj@kernel.org>2026-11-23 20:07:41 -1000
commitc99f50e4acf86bfbbe313d79f281d83be1763260 (patch)
tree0d53881e0b1d9c90a4325896aa01ff4656c57395 /kernel
parent884e88175b95a03ea9f4dc8c89acca5d5b33cbd2 (diff)
cgroup/rstat: disable preemption in css_rstat_updated()
BPF programs can call css_rstat_updated() with preemption enabled. The kfunc calls __css_rstat_updated(), which requires preemption to be disabled while it queues an rstat update. A cgroup iterator can hit the lockdep assertion on both RT and non-RT kernels. The cgroup_hierarchical_stats selftest can also hit it on PREEMPT_RT: spin_lock_irqsave() on trace_cgroup_path_lock leaves preemption and interrupts enabled there. Disable preemption in the BPF wrapper after validating the CPU and before calling __css_rstat_updated(). Fixes: 36df6e3dbd7e ("cgroup: make css_rstat_updated nmi safe") Reported-by: Jiayuan Chen <jiayuan.chen@linux.dev> Closes: https://lore.kernel.org/r/20251119111402.153727-1-jiayuan.chen@linux.dev/ Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com> Acked-by: Shakeel Butt <shakeel.butt@linux.dev> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup/rstat.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index de816a43db9f..d72fe721cea0 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -131,6 +131,7 @@ __bpf_kfunc void css_rstat_updated(struct cgroup_subsys_state *css, int cpu)
if (unlikely(cpu < 0 || cpu >= nr_cpu_ids || !cpu_possible(cpu)))
return;
+ guard(preempt)();
__css_rstat_updated(css, cpu);
}