[PATCH v2] xen/sched: fix scheduler callback verification on init

Ruslan Ruslichenko posted 1 patch 1 month, 4 weeks ago
xen/common/sched/core.c | 1 +
1 file changed, 1 insertion(+)
[PATCH v2] xen/sched: fix scheduler callback verification on init
Posted by Ruslan Ruslichenko 1 month, 4 weeks ago
From: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>

During core scheduler initialization, each registered scheduler
is sanity tested in two steps:

- it must provide required callbacks (e.g. init, do_schedule).
- if global_init callback is present, it must succeed.

If any of the steps fail, scheduler entry is cleared in global
'schedulers' array.

However, in the current implementation, if verification fails during
the first step, the scheduler entry is cleared but verification
sequence is not interrupted. This lead to NULL pointer dereference
when subsequent required callbacks verified, and possible during
the second step.

The patch fixes the crashes by skipping consequent checks if one of
the required callbacks are not present for the scheduler.

Fixes: ec25b3c0261c ("xen/sched: only allow schedulers with all mandatory functions available")
Signed-off-by: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>
---
 xen/common/sched/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 17e7f52169..77cbfd5226 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -3065,6 +3065,7 @@ void __init scheduler_init(void)
             printk("scheduler %s misses .%s, dropped\n", \
                    schedulers[i]->opt_name, #f);         \
             schedulers[i] = NULL;                        \
+            continue;                                    \
         }
 
         sched_test_func(init);
-- 
2.43.0
Re: [PATCH v2] xen/sched: fix scheduler callback verification on init
Posted by Juergen Gross 1 month, 3 weeks ago
On 25.09.26 23:30, Ruslan Ruslichenko wrote:
> From: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>
> 
> During core scheduler initialization, each registered scheduler
> is sanity tested in two steps:
> 
> - it must provide required callbacks (e.g. init, do_schedule).
> - if global_init callback is present, it must succeed.
> 
> If any of the steps fail, scheduler entry is cleared in global
> 'schedulers' array.
> 
> However, in the current implementation, if verification fails during
> the first step, the scheduler entry is cleared but verification
> sequence is not interrupted. This lead to NULL pointer dereference
> when subsequent required callbacks verified, and possible during
> the second step.
> 
> The patch fixes the crashes by skipping consequent checks if one of
> the required callbacks are not present for the scheduler.
> 
> Fixes: ec25b3c0261c ("xen/sched: only allow schedulers with all mandatory functions available")
> Signed-off-by: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen
Re: [PATCH v2] xen/sched: fix scheduler callback verification on init
Posted by Jan Beulich 1 month, 3 weeks ago
On 25.09.2026 23:30, Ruslan Ruslichenko wrote:
> From: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>
> 
> During core scheduler initialization, each registered scheduler
> is sanity tested in two steps:
> 
> - it must provide required callbacks (e.g. init, do_schedule).
> - if global_init callback is present, it must succeed.
> 
> If any of the steps fail, scheduler entry is cleared in global
> 'schedulers' array.
> 
> However, in the current implementation, if verification fails during
> the first step, the scheduler entry is cleared but verification
> sequence is not interrupted. This lead to NULL pointer dereference
> when subsequent required callbacks verified, and possible during
> the second step.
> 
> The patch fixes the crashes by skipping consequent checks if one of
> the required callbacks are not present for the scheduler.
> 
> Fixes: ec25b3c0261c ("xen/sched: only allow schedulers with all mandatory functions available")
> Signed-off-by: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>