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

Re: [PATCH 10/10] xencontrol: guard against NumberPages overflow in gnttab size calculation


  • To: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>, David ambu <david.preetham@xxxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Tue, 13 Oct 2026 08:01:51 +0000
  • Accept-language: en-GB, en-US
  • 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=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=JZ0DkIUP8KRJruQlwTvnur5cpmDeaSE8KwsCJ2ZspJE=; b=Wb8Tzfy4jtahF/jtDoN8LqJIV+pJftelv+T2F65NK9lfSSDIZqVsdA1/jDy4lfXIUHTTokb2bmWf73lBlH83KTtDZhOI8maAKAOn8CdNu0I1+e1RBv+gSyN5i0eBbpfxhEsBhmXDb2oyvUzBt4tm+v3mvPmABvmZc3KThGpZmULlpszp5LcqNNCe5mGBfHEnxH3hZlJQ3Md0vsb06f0qZBJ2DGYZYvCJyA8wpnUyIwxgLZ9zRGBLKCj+NMshWnwSNrGYMvbSxIibLbTh9OdctsefT/Erez/wZYADKGY1LL8MNvRmy/+MXicO0Ysr7CZSJ7Bg9ZwM6LsEi0Wl11YaYg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Rc7+Kgzpl7m4rCh05jzE22eXGTW0fpsSkbti4OHqaXBvjdVW1vT2sBI29dnMbHvakZPPl7z11lzrhpLjQObkaH7ypIkG37NHN9XLqmab+1A76xnx5VfRd5/ZeUOYkPnnCPGq16T8bHOUyle4Tn78nSjtK/+0lpKF8foCmOlmVsE/3NpfqUj/XX0SKiunxhNF9+VS38i2QMYLM67VDruSr9Ju4x9b7uTBRI1XexehnMjachm/gPBokGyduhXbQq+zDnCkchv+f/jDL53OAvuAEFzw7sEOU/R214lnlyyKwZde/46yRnhiOI3AFlNIHoVIYmBR4odviTWpNwzTcYIL6Q==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Tue, 13 Oct 2026 08:01:59 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Msip_labels:
  • Thread-index: AQHdVx1buiM7764nOEueG4e52n1g9rb0/rcAgAVsf4CAALQqDQ==
  • Thread-topic: [PATCH 10/10] xencontrol: guard against NumberPages overflow in gnttab size calculation

>>> diff --git a/src/xencontrol/xencontrol.c b/src/xencontrol/xencontrol.c
>>> index a68dcf6..8f21867 100644
>>> --- a/src/xencontrol/xencontrol.c
>>> +++ b/src/xencontrol/xencontrol.c
>>> @@ -407,6 +407,11 @@ XcGnttabPermitForeignAccess2(
>>>        BOOL                                            Success;
>>>        DWORD                                           Status;
>>>
>>> +    if (NumberPages == 0 || NumberPages > XENCONTROL_GNTTAB_MAX_PAGES) {
>>
>> I believe the boundary condition of NumberPages ==
>> XENCONTROL_GNTTAB_MAX_PAGES still causes an overflow? So
>> XENCONTROL_GNTTAB_MAX_PAGES should be (1024 * 1024 - 1) instead.
>
>MAXULONG / PAGE_SIZE would be a better formulation still, only problem
>being PAGE_SIZE is not defined for usermode targets.

Maximum number of pages allowed is also checked in IoctlGnttabMapForeignPages
against a hard coded 1024*1024.
It would be good to have the same constant/#define referred to in both places.

Eventually, this ends up in FdoPciHoleAllocate or FdoMemoryHoleAllocate, 
depending
on the "UseMemoryHole" setting.
FdoPciHoleAllocate is limited to 4GiB - PAGE_SIZE bytes (i.e. 1024*1024 - 1 
pages)
FdoMemoryHoleAllocate's allocations doesnt specify a maximum size, but the 
chances
of allocating a contiguous 4GB set of pages would be problematic.

Its likely this check is excessively large, but I'm unsure as to what the safe 
correct
maximum would be.

>
>>
>>> +        Log(XLL_ERROR, L"Invalid NumberPages %lu", NumberPages);
>>> +        return ERROR_INVALID_PARAMETER;
>>> +    }
>>> +
>>>        In.RemoteDomain = RemoteDomain;
>>>        In.Address = Address;
>>>        In.NumberPages = NumberPages;
>>> @@ -508,6 +513,11 @@ XcGnttabMapForeignPages(

Owen



 


Rackspace

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