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

Re: [PATCH v3 1/7] xen/evtchn: Make sure all buckets below d->valid_evtchns are allocated


  • To: Rahul Singh <rahul.singh@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Thu, 1 Sep 2022 14:47:40 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=arm.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tCqMWkbONnNBW7xCZnzA02s5mxJuxs8qoF+Sr83l4IM=; b=c+J3mb5U/NRWUpVZe+26wbJ/Yg1jdoHmGgayZEzH/AugbqCIc3EEgY0TEcrES1mOMDT+CLw7aDpqgTO2l4a9csEsj9pdYQYelXX6GgQ+s23B51FmqSpgfhjqWnRxOUX6U8qcvtXLQiLPSR4UL30czWVMZRHMLgh3mmEzofGhhMRburCBz2QWPiymeawfmc0xkKMxPi/TuCKMWPDI5AxrB4y4dpRxtyz78loC38BK+of+HpzV9TYEJtEiJ1+JUG+dJQP0xIwoiRDdkdp1V+Cla5Y41iPMsTpJOshLkFDEZE/Vcjv99DA+sa1dGRbQRO+zofwEokNTycZwit/zrQesKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gdOWKpooVjW4dtMwc/PJxJjyn86WijqVHYCDSK8YDCW06CLrUJIQKpB+Oppuf2G+S2gipVWdbwZRW3iKZE/wnhxkk6LPF+03j8KCa2ua58LtLsWCdOELmGYiphTzCzj2yo9Lcxz6FZsIZsdwEdL+iZGqJ7kyjDvJW6cJGDjpYMEeY63rthPO+w5hFw8rH9vzfPdGbA6QTIFEGtKGcJKFO2O/30FPS3+KRFCS3r5w3kcAnH2ImxONW7kGEywXQB4RVK9YPu6G3ZFuNrFylCYWVeVtc0VEOVC61LcbyQ+v1SW3LDy7srK4Hw7bC6Fz7GpxR1w7fhlHz2q2FMJDwjcMAg==
  • Cc: <bertrand.marquis@xxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 01 Sep 2022 12:47:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Rahul,

On 01/09/2022 11:13, Rahul Singh wrote:
> 
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> Since commit 01280dc19cf3 "evtchn: simplify port_is_valid()", the event
> channels code assumes that all the buckets below d->valid_evtchns are
> always allocated.
> 
> This assumption hold in most of the situation because a guest is not
> allowed to chose the port. Instead, it will be the first free from port
> 0.
> 
> When static event channel support will be added for dom0less domains
> user can request to allocate the evtchn port numbers that are scattered
> in nature.
> 
> The existing implementation of evtchn_allocate_port() is not able to
> deal with such situation and will end up to override bucket or/and leave
> some bucket unallocated. The latter will result to a droplet crash if
> the event channel belongs to an unallocated bucket.
> 
> This can be solved by making sure that all the buckets below
> d->valid_evtchns are allocated. There should be no impact for most of
> the situation but LM/LU as only one bucket would be allocated. For
> LM/LU, we may end up to allocate multiple buckets if ports in use are
> sparse.
> 
> A potential alternative is to check that the bucket is valid in
> is_port_valid(). This should still possible to do it without taking
> per-domain lock but will result a couple more of memory access.
> 
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
> Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
> ---
> Changes in v3:
>  - fix comments in commit msg.
>  - modify code related to d->valid_evtchns and {read,write}_atomic()
> Changes in v2:
>  - new patch in this version to avoid the security issue
> ---
>  xen/common/event_channel.c | 55 ++++++++++++++++++++++++--------------
>  1 file changed, 35 insertions(+), 20 deletions(-)
> 
> diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
> index c2c6f8c151..80b06d9743 100644
> --- a/xen/common/event_channel.c
> +++ b/xen/common/event_channel.c
> @@ -193,6 +193,15 @@ static struct evtchn *alloc_evtchn_bucket(struct domain 
> *d, unsigned int port)
>      return NULL;
>  }
> 
> +/*
> + * Allocate a given port and ensure all the buckets up to that ports
> + * have been allocated.
> + *
> + * The last part is important because the rest of the event channel code
> + * relies on all the buckets up to d->valid_evtchns to be valid. However,
> + * event channels may be sparsed when restoring a domain during Guest
> + * Transparent Migration and Live Update.
You got rid of mentioning these non-existing features from the commit msg,
but you still mention them here.

Apart from that, all the Jan comments were addressed, so:
Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>

~Michal



 


Rackspace

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