Skip to contentSkip to conversation

sched_ext: Fix missing return after scx_error() in scx_dsq_move()

PATCH Applied Cheng-Yang Chou 2 participants 2 messages Mar 26

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched_ext: Fix missing return after scx_error() in scx_dsq_move()

When scx_bpf_dsq_move[_vtime]() is called on a task that belongs to a different scheduler, scx_error() is invoked to flag the violation. scx_error() schedules an asynchronous scheduler teardown via irq_work and returns immediately, so execution falls through and the DSQ move proceeds on a cross-scheduler task regardless, potentially corrupting DSQ state.

Add the missing return false so the function exits right after reporting the error, consistent with the other early-exit checks in the same function (e.g. scx_vet_enq_flags() failure at the top).

Fixes bb4d9fd55158 ("sched_ext: scx_dsq_move() should validate the task belongs to the right scheduler")
---
 kernel/sched/ext.c | 1 +
 1 file changed, 1 insertion(+)
kernel/sched/ext.c +1 -0
index 551bfb99157d..a5d8871ac865 100644
@@ -8094,6 +8094,7 @@ static bool scx_dsq_move(struct bpf_iter_scx_dsq_kern *kit,
 	if (unlikely(!scx_task_on_sched(sch, p))) {
 		scx_error(sch, "scx_bpf_dsq_move[_vtime]() on %s[%d] but the task belongs to a different scheduler",
 			  p->comm, p->pid);
+		return false;
 	}
 
 	/*
Signature · 1 line
2.48.1
reviewer Applied
#1 lore raw

Applied to sched_ext/for-7.1.

Thanks.

Signature · 1 line
tejun