|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] xen/sched: fix scheduler callback verification on init
On Tue, Apr 14, 2026 at 1:10 PM Mykyta Poturai <Mykyta_Poturai@xxxxxxxx> wrote:
>
> On 4/10/26 19:40, Ruslan Ruslichenko wrote:
> > From: Ruslan Ruslichenko <Ruslan_Ruslichenko@xxxxxxxx>
> >
> > 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 adding check inside sched_test_func
> > macro and skipping the call to a global_init if first step did not pass.
> >
> > Signed-off-by: Ruslan Ruslichenko <Ruslan_Ruslichenko@xxxxxxxx>
> > ---
> > xen/common/sched/core.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
> > index a57d5dd929..4270c89491 100644
> > --- a/xen/common/sched/core.c
> > +++ b/xen/common/sched/core.c
> > @@ -3017,7 +3017,7 @@ void __init scheduler_init(void)
> > for ( i = 0; i < NUM_SCHEDULERS; i++)
> > {
> > #define sched_test_func(f) \
> > - if ( !schedulers[i]->f ) \
> > + if ( schedulers[i] && !schedulers[i]->f ) \
> > { \
> > printk("scheduler %s misses .%s, dropped\n", \
> > schedulers[i]->opt_name, #f); \
> > schedulers[i] = NULL; \
>
> Maybe it would be cleaner to just add "continue" here?
>
Probably, yes. This will also skip unneeded checks after the first
missing callback.
I will update the patch then.
--
BR,
Ruslan
> > @@ -3034,6 +3034,9 @@ void __init scheduler_init(void)
> >
> > #undef sched_test_func
> >
> > + if ( !schedulers[i] )
> > + continue;
> > +
> > if ( schedulers[i]->global_init && schedulers[i]->global_init() <
> > 0 )
> > {
> > printk("scheduler %s failed initialization, dropped\n",
>
> --
> Mykyta
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |