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

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


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 18 Nov 2021 09:47:41 +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=iya6b1bQoAJ848Se32DLvKbaTbi3hYCcvLKUjFP3Yr8=; b=UEw2ypKus0m9XrDt7qs1jhWcN95WRL34tkoypveQx1wZeGSFPrxt1hAWVHoy0fazBExkvJAbWUF6YRkMjiqJOsuBLCJeiaVVQfFhAvNOctMsjD0jGsSLevwG92S5wfBdp0okkGFZElFiosEDPfCTfZKpsGAFKZwow5P1D2EpwAn6tLIgcMVMgJRp3MB22jC3i7PPwGmry3HNYE6loakkOE+UzyFxF3s6JVw7Ud+YbCj4BSqlu+RtmCaFe8NkaJiJa6nEdQEvVcxDdS8umfphhauCLFfzJYB8Nog1m6JSkZFccNMD/b/H8XFvzv3AAVFcimDtHwPbj2Mv8j3TG2u8Jw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ci9UAXQnQuRyURYz83cDPaecd6Tc1ztE4EhAW3iHIglrEctqOZhvAt+x4x7rtz0oQN2KI5nLb0YRmjAT563Ow7FhODnoF2hgPGNscM5vlLdCeY2lmDxLiUqXCNqtvWNGj+zycSBbfOaQEPZcV/RBoEV3HgCQatjhbBNxvsqAi414X9o6UIXIEtg9kpfD0FWhheAALG9PlVQCzGu5N7OkAwL22h5mp5DyRN3ee+/iZhdfwd6CLjhOAFFxxrbnX6vgpqgbaDCuJxFUM6j4giCB3RFRFx4QxcBVhRXCyjYnx7CwGvZpe9Juy+ApaQaH1A3cmIkuMIKUdG5PQBXO2ByGrw==
  • 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, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Thu, 18 Nov 2021 08:47:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 18.11.2021 06:32, Juergen Gross wrote:
> On 18.11.21 03:37, Stefano Stabellini wrote:
>> --- a/drivers/xen/xenbus/xenbus_probe.c
>> +++ b/drivers/xen/xenbus/xenbus_probe.c
>> @@ -951,6 +951,28 @@ static int __init xenbus_init(void)
>>              err = hvm_get_parameter(HVM_PARAM_STORE_PFN, &v);
>>              if (err)
>>                      goto out_error;
>> +            /*
>> +             * Return error on an invalid value.
>> +             *
>> +             * 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) {
> 
> Make this "if (v == ULONG_MAX || v== 0)" instead?
> This would result in the same err on a new and an old hypervisor
> (assuming we switch the hypervisor to init params with ~0UL).
> 
>> +                    err = -ENOENT;
>> +                    goto out_error;
>> +            }
>> +            /*
>> +             * ULONG_MAX is invalid on 64-bit because is INVALID_PFN.
>> +             * On 32-bit return error to avoid truncation.
>> +             */
>> +            if (v >= ULONG_MAX) {
>> +                    err = -EINVAL;
>> +                    goto out_error;
>> +            }
> 
> Does it make sense to continue the system running in case of
> truncation? This would be a 32-bit guest with more than 16TB of RAM
> and the Xen tools decided to place the Xenstore ring page above the
> 16TB boundary. This is a completely insane scenario IMO.
> 
> A proper panic() in this case would make diagnosis of that much
> easier (me having doubts that this will ever be hit, though).

While I agree panic() may be an option here (albeit I'm not sure why
that would be better than trying to cope with 0 and hence without
xenbus), I'd like to point out that the amount of RAM assigned to a
guest is unrelated to the choice of GFNs for the various "magic"
items.

Jan




 


Rackspace

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