From: Kuba Piecuch <jpiecuch@google.com>
To: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>
Cc: Kuba Piecuch <jpiecuch@google.com>, Ryan Newton <newton@meta.com>,
sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] sched_ext: Take rcu_read_lock() explicitly in sub-cap kfuncs
Date: Mon, 23 Nov 2026 15:00:38 +0000 [thread overview]
Message-ID: <20261123145927.577162-3-jpiecuch@google.com> (raw)
In-Reply-To: <20261123145927.577162-1-jpiecuch@google.com>
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@google.com>
---
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
prev parent reply other threads:[~2026-11-23 15:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 15:00 [PATCHSET sched_ext/for-7.4-fixes] sched_ext: Fix and tighten RCU usage in kfuncs Kuba Piecuch
2026-11-23 15:00 ` [PATCH 1/2] sched_ext: Fix suspicious RCU usage in KF_RCU_PROTECTED kfuncs Kuba Piecuch
2026-11-23 15:00 ` Kuba Piecuch [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123145927.577162-3-jpiecuch@google.com \
--to=jpiecuch@google.com \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=newton@meta.com \
--cc=sched-ext@lists.linux.dev \
--cc=tj@kernel.org \
--cc=void@manifault.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®