Skip to content

Commit f467de3

Browse files
committed
sched/ext: Prevent update_locked_rq() calls with NULL rq
JIRA: https://issues.redhat.com/browse/RHEL-111810 CVE: CVE-2025-38522 commit e14fd98 Author: Breno Leitao <leitao@debian.org> Date: Wed Jul 16 10:38:48 2025 -0700 sched/ext: Prevent update_locked_rq() calls with NULL rq Avoid invoking update_locked_rq() when the runqueue (rq) pointer is NULL in the SCX_CALL_OP and SCX_CALL_OP_RET macros. Previously, calling update_locked_rq(NULL) with preemption enabled could trigger the following warning: BUG: using __this_cpu_write() in preemptible [00000000] This happens because __this_cpu_write() is unsafe to use in preemptible context. rq is NULL when an ops invoked from an unlocked context. In such cases, we don't need to store any rq, since the value should already be NULL (unlocked). Ensure that update_locked_rq() is only called when rq is non-NULL, preventing calling __this_cpu_write() on preemptible context. Suggested-by: Peter Zijlstra <peterz@infradead.org> Fixes: 18853ba ("sched_ext: Track currently locked rq") Signed-off-by: Breno Leitao <leitao@debian.org> Acked-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org> Cc: stable@vger.kernel.org # v6.15 Signed-off-by: Phil Auld <pauld@redhat.com>
1 parent 68adaa9 commit f467de3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

kernel/sched/ext.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,30 +1263,34 @@ static inline void update_locked_rq(struct rq *rq)
12631263

12641264
#define SCX_CALL_OP(sch, mask, op, rq, args...) \
12651265
do { \
1266-
update_locked_rq(rq); \
1266+
if (rq) \
1267+
update_locked_rq(rq); \
12671268
if (mask) { \
12681269
scx_kf_allow(mask); \
12691270
(sch)->ops.op(args); \
12701271
scx_kf_disallow(mask); \
12711272
} else { \
12721273
(sch)->ops.op(args); \
12731274
} \
1274-
update_locked_rq(NULL); \
1275+
if (rq) \
1276+
update_locked_rq(NULL); \
12751277
} while (0)
12761278

12771279
#define SCX_CALL_OP_RET(sch, mask, op, rq, args...) \
12781280
({ \
12791281
__typeof__((sch)->ops.op(args)) __ret; \
12801282
\
1281-
update_locked_rq(rq); \
1283+
if (rq) \
1284+
update_locked_rq(rq); \
12821285
if (mask) { \
12831286
scx_kf_allow(mask); \
12841287
__ret = (sch)->ops.op(args); \
12851288
scx_kf_disallow(mask); \
12861289
} else { \
12871290
__ret = (sch)->ops.op(args); \
12881291
} \
1289-
update_locked_rq(NULL); \
1292+
if (rq) \
1293+
update_locked_rq(NULL); \
12901294
__ret; \
12911295
})
12921296

0 commit comments

Comments
 (0)