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

Re: [PATCH] xen/sched: rt: fix NULL cpupool dereference in move_repl_timer()


  • To: Juergen Gross <jgross@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Oleksii Moisieiev <oleksii_moisieiev@xxxxxxxx>
  • Date: Thu, 16 Jul 2026 18:22:17 +0300
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wyYrBfb3SHk20RsDa8d083u4H7+tvMOO6ZkZe1goqwg=; b=MuNmgx7Lut/bnFJdQQseyQYHZ8yxBg4tBVGAgOkoNvWReaYqOpU/m8wMnaLgCjFhSfUyeLO2awOh+whh3jCJGNytiVIqniBhZPLxh7IuwAReJTHfJNW5P+QgTFx2c6iAWT+SZAs1odEOWb33zAdrRTnMpVmIflq7u2DaB9C3aFF4djAKb6Nx2DgU6Ns9n9kDOmGws6KI60kaXIPSomKpv51x7Ph1seE8FscExR2Rb5hUrku7Pp/CilyJB6F3Rc7iwAbuPvhVZU9PEgB4ywd+tC/2DAgy+7KRoZCkQ/YMoVA+pMythWG5rukP19HDiH6A7LuObvKtES44WO/U/dC+BQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PoH5mkNoKwbIxzczOqeVJgQQA+/CaRqjL07sD5SwBRopMwLq2W38A8sOJJ3om9rir7aWSsVvlUUaFX4xcdZGSjbkZGhw+mXml5asMj7t4U3SvsVKUvvxcmPcKGrSL0e0X54p3y3pMsQtWM/rE9YkU6rXG935HnkuIGPWV73aANrlM606XfnuQy/tbG4f1beMyWL7fuGunA3YZ4/Mky8S1ul16cstR10dg8VNbkRPUoBEsrKird9iVcfZCA0/j0eXaUQ/WfgLXKsBotM6pBSBAUHwKD5+M9zdUnhGVTyF2OFvIUuG1Zd3gXeStf+sMyFPqACdLurNvB2/ZXskao45bw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Dario Faggioli <dfaggioli@xxxxxxxx>, George Dunlap <gwd@xxxxxxxxxxxxxx>, Meng Xu <mengxu@xxxxxxxxxxxxx>
  • Delivery-date: Thu, 16 Jul 2026 15:22:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Juergen,

Thanks for quick response.

On 16/07/2026 17:44, Juergen Gross wrote:
On 16.07.26 16:20, Oleksii Moisieiev wrote:
schedule_cpu_rm() clears the cpupool pointer of the scheduling
resource before calling sched_deinit_pdata():

     sr->cpupool = NULL;
     ...
     sched_deinit_pdata(data->old_ops, data->ppriv_old, cpu);

For RTDS, rt_deinit_pdata() calls move_repl_timer() when the
replenishment timer lives on the cpu being removed, and
move_repl_timer() dereferences get_sched_res(old_cpu)->cpupool
without checking it for NULL. Removing the last pCPU from an RTDS
cpupool therefore dereferences NULL + 0x10 (the res_valid member)
and panics:

     (XEN) Data Abort Trap. Syndrome=0x1c28005
     (XEN) Walking Hypervisor VA 0x10 on CPU0 via TTBR ...
     (XEN) Xen call trace:
     (XEN)    [<...>] find_next_bit+0x74/0xa8 (PC)
     (XEN)    [<...>] rt.c#move_repl_timer+0xb8/0xec (LR)
     (XEN)
     (XEN) Panic on CPU 0:
     (XEN) CPU0: Unexpected Trap: Data Abort

Reproducer, on any host with at least 2 pCPUs and RTDS compiled in
(observed on arm64, but the path is common code):

     xl cpupool-create name="test" sched="rtds"
     xl cpupool-cpu-remove Pool-0 1
     xl cpupool-cpu-add test 1
     xl cpupool-cpu-remove test 1

The last command moves the RTDS replenishment timer to cpu1 (first
and only cpu of the pool) and then removes cpu1, hitting the NULL
dereference in the sched_deinit_pdata() callback.

Treat a NULL cpupool like a cpupool with no remaining scheduling
resources and kill the timer, which is the intent of the existing
comment in move_repl_timer().

Hmm, is this correct?

What if there are 2 cpus in the cpupool and you are just removing the
one owning the timer? This would kill the timer instead of moving it
to the other cpu of the cpupool.

I guess the correct fix would be to add a cpupool pointer to struct
rt_private and use that in move_repl_timer().

Makes sense... I'll rethink. Thanks

Juergen



 


Rackspace

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