[PATCH 1/2] xen/credit: fix race with schedule_cpu_rm() in csched_timer()
Juergen Gross <[email protected]> Wed, 29 Jul 2026 14:06:42 +0200
| Newsgroups | gmane.comp.emulators.xen.devel |
|---|---|
| Message-ID | <[email protected]> |
When removing a CPU from a cpupool running the credit scheduler, a
race might happen between schedule_cpu_rm() and csched_timer(),
resulting in a NULL dereference.
The timer associated with csched_timer() is killed only in
csched_deinit_pdata(), which is called by schedule_cpu_rm() after
setting the scheduler's per-cpu data to NULL AND after enabling
interrupts again. This can result in the timer to fire before it is
being killed, so csched_timer() needs to test the per-cpu data to be
set before accessing it.
Fixes: 78be3dbbfefa ("cpupools [1/6]: hypervisor changes")
Reported-by: Dietmar Hahn <[email protected]>
Signed-off-by: Juergen Gross <[email protected]>
---
xen/common/sched/credit.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/xen/common/sched/credit.c b/xen/common/sched/credit.c
index 328c802d0c..4dde2ede12 100644
--- a/xen/common/sched/credit.c
+++ b/xen/common/sched/credit.c
@@ -1589,6 +1589,10 @@ static void cf_check csched_tick(void *_cpu)
struct csched_pcpu *spc = CSCHED_PCPU(cpu);
struct csched_private *prv = CSCHED_PRIV(sr->scheduler);
+ /* Handle race of timer disabling vs. firing when switching scheduler. */
+ if ( !spc )
+ return;
+
spc->tick++;
/*
--
2.55.0