[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • To: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • From: Ruslan Ruslichenko <ruslichenko.r@xxxxxxxxx>
  • Date: Tue, 14 Apr 2026 14:37:20 +0200
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Q9zdWPoWdvbWCQTO+55S7ZInEF0uDLun5ABiAEsj0AE=; fh=IS/tDDkuF9s3/ln8GtiQ3p6v+3aSD0NVmXMIz5Ujy88=; b=YZKv+7nNLhUb9CJIo6iHDIr0PKsB6YvXuVDDMGCpO6kO5XAiomS4yx80BzUBKsTXwb 4hqHxuH4oHfGZ5Es2yY8e8sRstk4FnfnZgS+a5oBIdVv1Num71xGbvK7r2hyXybR9SgL I95FngOs8xYBsVZSaQ5fYp+PppAv2J7aXJaq6PrpLOb+qos+SIQEBI4F4EE/2asS5Mgo BMJ7L69FrCHnebInnqfyRUSqaz4dwH6ITGwUt1lmctq8gpNZoBM8eAauG1MD8nnv7jVj mOxUaXAHktaW8wAvVNPW8zU6B+D5W1xdXXRcD3n8Lgaqel0O8fTUWnJAPQ5O5XjOtzWz e7Sg==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1776170252; cv=none; d=google.com; s=arc-20240605; b=M3UkeP5n+se6S7TPzMiw0wdpnI5mhsoKCsuNXfhqPb6Jf6pDLkfFXS4Be1ApIAFT+l WZOvmKFGfQ3HT64clf8Jk4orKn+hTlpAsUQtk3fRui0run1CA5px9le/YQsTrElEXNnX U9x82Q0nmK8iDXaEs1EXuFvGM+hAsaisS38HadH+ZDkwh6bsSySzxgchKsvN3S07MMPs BWfif9NLnruMV6BM04wVS0kR7Gh5sV4N8WSD6tRxX+nddZBU6Gi3d+5DPK+tR3Jdl/sP LImTvtAadYia4hqlJ9ZEYrJ3hb2lwGkZxvYS4w7vKRvl83QKD8Yjp1jxMYfuBXIVr+Ip 3xpw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Ruslan Ruslichenko <ruslan_ruslichenko@xxxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, George Dunlap <gwd@xxxxxxxxxxxxxx>
  • Delivery-date: Tue, 14 Apr 2026 12:37:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.