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

Re: [PATCH] xen/sched: fix sched_move_domain() for domain without vcpus


  • To: Juergen Gross <jgross@xxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 6 Sep 2021 12:14:48 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=8DIosnqOWGFq84M1MwFZbsweglLBrZR4689wCKGnoEo=; b=WTHfwF0DMLPA753PCnSHlnYAIx01fG8ynSdC2nMEC2hgmfYwhF1IdpJoyHR7sjX6BuoWpDpZyA6EIwwegF/U8dM1Nzg2wYgVoAUtK0vp2s9zMH5FqPIRWFZ/K9LAXUsuuht/bqiqGAsgVBl+ny1q16n6MYKewc3ZFNbrlgO5yD1Q4mycL3s3ex41h+8rH34E+Bvidopp7Fx7tup/P4dXkOZK19E6w3Kfs1mEbcy6Tsw7jdBtvh2O4tCHN5H17kTDxLAYfkbovMRbCNKfZEGj8yPNZMywwDM6lTOiVlL7sqJs5P8xl3d2f87dZdP/yZe3mhXpY77EggI85YcyWasPAw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jTFVkScVpNPVsclnXnFuj4JvvGK/1s0ApPARsh0d/iWpD8pSSiLkAwf6VIXPHOu3j2aWD0dE4F0hDKP/eRn9xZpaEvT5NUOwsMCMWqVg5CpGAxSbR2fwSTySX16N+KVikuxLzcFEr/u45282oV90Zyyw7Rz2F9O+2qKvB+luH0GeZDtnoeHxQhLRb0Go24e3/2/eQAAaxARPOuWb8hhNGBeL5ehxG76o2n3HibThUIkdMoofuP+kMqr+mFb+kPfvycL0nLECrpLxIRWA0hJgQSZah/EHyMq4ql99iqaxoeApHYSt8hdNKqQdBA1dMBer5ubGvFMHnP1emKCQNVo7TA==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: George Dunlap <george.dunlap@xxxxxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Mon, 06 Sep 2021 11:15:06 +0000
  • Ironport-hdrordr: A9a23:aLpIX60KMs9qunmdlIZzSgqjBSVyeYIsimQD101hICG9Lfb2qy n+ppgmPEHP5Qr5OEtApTiBUJPwJE80hqQFnrX5Wo3SIDUO2VHYUb2KiLGN/9SOIVyHygcw79 YGT0E6MqyLMbEYt7eL3ODbKadY/DDvysnB7o2/vhQdPj2CKZsQizuRYjzrY3GeLzM2Y6bReq DshPav6wDQAkj+Oa+Adwc4tqX41pH2vaOjRSRDKw8s6QGIgz/twLnmEyKA1hNbdz9U278t/U XMjgS8v8yYwr+G4y6Z81WWw4VdmdPnxNcGLMuQivINIjGprgqzfoxuV5CLoThwiuCy71QBls XKvn4bTotOwkKUWlvwjQrm2gHm3jprw3j+yWWAiX+mmsD9TCJSMbsLuatpNj/ir2YwttB116 xGm0iDsYBMMB/GlCPho/DVShBDjCOP0DkfuN9Wq0YafZoVabdXo4Ba1lhSCo08ECXz751iOP VyDfvb+O1dfTqhHjDkV1FUsZmRt0kIb1O7qhBogL3T79EWpgE586Ig/r1cop9an6hNDaWt5I z/Q+xVff91P5YrhQ8UPpZ3fSKNMB25ffv7ChPaHb3WLtB0B5vzke+C3FwU3pDhRHVa9up+pH z+OGkow1LaPXieUfGz4A==
  • Ironport-sdr: yyVzsrerJc31Vq4XhX3BSvdEhgA5sZEjHA742tSj20s9+xubdWoiSaMDCSH6hmbZI400VsWs1B u//yIyX9p9pGYrSjQ5UnJ3vAqAwN7oaS0f1xvAoW2gCzEQunYN0bvunW+9FfV+7Koi27tqAoMJ B4zp6BWdsj/RB8RctWGYdp44K/JkHHmFHrBD1wCv2G+DAzgskNQPbQRfKE1Oat1oc3BPyZXY3J tebEh9AXWiSgOWDriF/pvDEIqCiYXLBk5WB9uptuowsUGq8bKLkvfH8HjRbPDSBeZ7CPoFKF0J Vfy5+SESMhoBns0iUUAMAzNa
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 06/09/2021 12:00, Juergen Gross wrote:
> In case a domain is created with a cpupool other than Pool-0 specified
> it will be moved to that cpupool before any vcpus are allocated.
>
> This will lead to a NULL pointer dereference in sched_move_domain().
>
> Fix that by tolerating vcpus not being allocated yet.
>
> Fixes: 70fadc41635b9b6 ("xen/cpupool: support moving domain between cpupools 
> with different granularity")
> Reported-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
> Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
> ---
>  xen/common/sched/core.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
> index 8d178baf3d..79c9100680 100644
> --- a/xen/common/sched/core.c
> +++ b/xen/common/sched/core.c
> @@ -671,6 +671,10 @@ int sched_move_domain(struct domain *d, struct cpupool 
> *c)
>  
>      for ( unit_idx = 0; unit_idx < n_units; unit_idx++ )
>      {
> +        /* Special case for move at domain creation time. */
> +        if ( !d->vcpu[unit_idx * gran] )
> +            break;
> +
>          unit = sched_alloc_unit_mem();
>          if ( unit )
>          {

I think the logic would be clearer if you wrap the entire for loop in if
( d->max_vcpus ).  This loop is only allocating units in the new
scheduler for existing vcpus, so there's no point entering the loop at
all during domain creation.

Also, this removes a non-speculatively-guarded d->vcpu[] deference.

~Andrew




 


Rackspace

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