[PATCH 2/2] sched_ext: Take rcu_read_lock() explicitly in sub-cap kfuncs
From: Kuba Piecuch
Date: Mon Nov 23 2026 - 10:01:46 EST
scx_bpf_sub_grant(), scx_bpf_sub_revoke() and scx_bpf_sub_caps() look up
scheds via scx_prog_sched() and scx_find_sub_sched(), read the cid
tables and, in revoke, walk ->children while holding only
guard(irqsave)(). They can be called without rcu_read_lock(), e.g. from
sleepable ops or bpf_timer callbacks.
This works only because IRQs are disabled and none of the RCU checks on
these paths require rcu_read_lock_held(). A plain rcu_dereference()
added to these paths would trigger a lockdep splat when called without
rcu_read_lock().
Take guard(rcu)() as scx_bpf_sub_dispatch() and scx_bpf_sub_kill_bstr()
already do. No functional change.
Signed-off-by: Kuba Piecuch <jpiecuch@xxxxxxxxxx>
---
kernel/sched/ext/sub.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/sched/ext/sub.c b/kernel/sched/ext/sub.c
index d2a20114eaa2..45aaa333f9c2 100644
--- a/kernel/sched/ext/sub.c
+++ b/kernel/sched/ext/sub.c
@@ -2870,6 +2870,7 @@ __bpf_kfunc s32 scx_bpf_sub_grant(u64 cgroup_id, u64 caps,
LIST_HEAD(to_deliver);
s32 si, ret;
+ guard(rcu)();
guard(irqsave)();
ret = sub_cap_preamble(cgroup_id, caps, aux, &parent, &child);
@@ -2999,6 +3000,7 @@ __bpf_kfunc void scx_bpf_sub_revoke(u64 cgroup_id, u64 caps,
LIST_HEAD(to_deliver);
s32 si, ret;
+ guard(rcu)();
guard(irqsave)();
if (sub_cap_preamble(cgroup_id, caps, aux, &parent, &child))
@@ -3092,6 +3094,7 @@ __bpf_kfunc s32 scx_bpf_sub_caps(u64 cgroup_id, u64 caps, struct scx_cmask *out_
struct scx_pshard **pshard;
s32 si, ret;
+ guard(rcu)();
guard(irqsave)();
sch = scx_prog_sched(aux);
--
2.56.1.750.gf70dc682cf-goog