Skip to contentSkip to conversation

xen/sched: fix scheduler callback verification on init

PATCH In review Ruslan Ruslichenko 3 participants 3 messages Sep 25 – Oct 1

lore
Share & tools
lore
#0 lore raw

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

From: Ruslan Ruslichenko <[email protected]>

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")
---
 xen/common/sched/core.c | 1 +
 1 file changed, 1 insertion(+)
xen/common/sched/core.c +1 -0
index 17e7f52169..77cbfd5226 100644
@@ -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);
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 17 lines · Ruslan Ruslichenko

From: Ruslan Ruslichenko <[email protected]>

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.

Quoted 5 lines

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")
Reviewed-by on v2 1/1
#2 lore raw
In reply to Ruslan Ruslichenko
Quoted 17 lines · Ruslan Ruslichenko

From: Ruslan Ruslichenko <[email protected]>

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.

Quoted 5 lines

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")

Juergen