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

Re: [PATCH] xen: detect uninitialized xenbus in xenbus_init


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 17 Nov 2021 08:41:56 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7O4IAlBuV7Ht5e46unwQP9LahssvTkosfPU1fu1k7K4=; b=QkHveLmQDEJaDHvwM413wEVfS7ZKeNAQdoqnyGheoOEKSsvcM3AICa/9wBByCqaHe/Nl3ZG2Ih9hDiRFVibmQ+2I/1qhcT7AFu5402KhLJlnWDZzMybjMMJWwfM747mD1FNgzHvENHnlwNdO8A0Jb56agbeWz0U8i4cS5RlBYI2M3rfxhcPm8t1JFyy85M8W1cH3E6IXJDe8+trFIuhasEtT6KKfzoL5eTz4s2sA7imrUvo/7l555RAeT1nVqRiutLpLH+6axGN6YFYUZPY1V382pFoWw4x+NxH79JvrH9gxHe2/m0vht2F2NVAmw/D+HcHnOGX2KA73kq8+dlORxg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SDhUGzxoqQKXNSnGrEn0zr67IRFXWhtNuFADnWufTi9XS9FMwkHE3fRmUiFPXRDmwjEh50qFQkGBJ5gcg0kZxCltNNi3K2pV2gpjXGoi77cN75Gsni497YO305jwLYAjWsuYL8utx4zxScCJ03ID6ohq2J2d7qqzCcf0dKPMvgKzGdSNl/qqZR8l+k9OIzVltKoi/myEljMSckZrKL7EzIalrbPFh/4n9Luw22ZEoIC8kLVic0n5ZeKgTnXheIZVi9NmKgp+X9cMYlprAZIuVElHcZZsoRcUfy7bHIFLdPW3/6VY9Lfv7nf2FShdKfR0s0jdKEdjUf6ZyniJLyyYlg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: boris.ostrovsky@xxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>, stable@xxxxxxxxxxxxxxx, jgross@xxxxxxxx
  • Delivery-date: Wed, 17 Nov 2021 07:42:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 17.11.2021 03:11, Stefano Stabellini wrote:
> --- a/drivers/xen/xenbus/xenbus_probe.c
> +++ b/drivers/xen/xenbus/xenbus_probe.c
> @@ -951,6 +951,18 @@ static int __init xenbus_init(void)
>               err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
>               if (err)
>                       goto out_error;
> +             /*
> +              * Uninitialized hvm_params are zero and return no error.
> +              * Although it is theoretically possible to have
> +              * HVM_PARAM_STORE_PFN set to zero on purpose, in reality it is
> +              * not zero when valid. If zero, it means that Xenstore hasn't
> +              * been properly initialized. Instead of attempting to map a
> +              * wrong guest physical address return error.
> +              */
> +             if (v == 0) {
> +                     err = -ENOENT;
> +                     goto out_error;
> +             }

If such a check gets added, then I think known-invalid frame numbers
should be covered at even higher a priority than zero. This would,
for example, also mean to ...

>               xen_store_gfn = (unsigned long)v;

... stop silently truncating a value here.

By covering them we would then have the option to pre-fill PFN params
with, say, ~0 in the hypervisor (to clearly identify them as invalid,
rather than having to guess at the validity of 0). I haven't really
checked yet whether such a change would be compatible with existing
software ...

Jan




 


Rackspace

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