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

Re: [PATCH] tests/pdx: fix overflow from conversion from page index to address on 32bit


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Thu, 12 Mar 2026 09:36:10 +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=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=0EAaLruJ0j1AiI5md8lI1uSD7PkKz4SyXqT8+Jd3YB8=; b=AxPHg7kT6LlvnUdjZko90ywKF7hIYPo0A8Ms+Sqk7sOXIYLG5KKyPleyGU6p56H/xLQJOxPs4Y7/9EZX03PKRpyMjUJYLUVkciM1lK9xrn4DAMej0T4HhK/pTdv8jQ/ytNxUGdIPzF+z7Gd6im1/Qyd0/e74A6NNbrb0XT6Fl5uCnurxeYBfrr5v+mfcBjjDt3QrbXOafNPJzF5Se4DUOdV5+RvzrfZnHB2cCr/02W8YIM+SQbNj+4e/pOnJPx5LaqztMH369SBid9RcRNFyKC2OPju4FAFHX+p8X0KogBAhd//ehYLHR4e2E6kIdE8C32ll8awjq4I5f3MzBtz3EQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u87acAxyUs7S3MxLsjGLjocEjlUE1JZtoiMQQKMr+csZ0oU9o3oj/jP6m6C8ZiM26lbF03tDJMzHyJHnpVayi1xyO5a3YWo7fEeaubEnOwrGNNlYK/snZZd1o8T50r+d+14w0BzTHqZDuYfQErnSf+EXNqklJsVh1Sc7evjHLiCJyCPqAPUqz1+fZmd3SyGH9QwLpkQ4PdLV3K2w8X36pjS530RYVt9f8fra+X7ycUs4zCF/2bTrPjowWAN1mKtoUqTlX7yszibOUQ4FNHB+rIm+uaX8jFSBijmdhqdfDQqUNT7u3pmHNEg2yZBDPINe70ugmSgk5IjVZsyu7om6Dw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Edwin Török <edwin.torok@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 12 Mar 2026 08:36:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Mar 12, 2026 at 09:25:12AM +0100, Jan Beulich wrote:
> On 12.03.2026 09:02, Roger Pau Monne wrote:
> > When building the PDX test harness as a 32bit executable the page shifts
> > done on unsigned long types can overflow.  Instead use pfn_to_paddr(),
> > which casts the values to paddr_t previous to doing the shift.
> > 
> > Fixes: cb50e4033717 ("test/pdx: add PDX compression unit tests")
> > Reported-by: Edwin Török <edwin.torok@xxxxxxxxxx>
> > Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> 
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> 
> > --- a/tools/tests/pdx/test-pdx.c
> > +++ b/tools/tests/pdx/test-pdx.c
> > @@ -208,8 +208,8 @@ int main(int argc, char **argv)
> >              if ( !tests[i].ranges[j].start && !tests[i].ranges[j].end )
> >                  break;
> >  
> > -            pfn_pdx_add_region(tests[i].ranges[j].start << PAGE_SHIFT,
> > -                               size << PAGE_SHIFT);
> > +            pfn_pdx_add_region(pfn_to_paddr(tests[i].ranges[j].start),
> > +                               pfn_to_paddr(size));
> >          }
> >  
> >          if ( pfn_pdx_compression_setup(0) != tests[i].compress )
> > @@ -233,8 +233,8 @@ int main(int argc, char **argv)
> >              if ( !start && !end )
> >                  break;
> >  
> > -            if ( !pdx_is_region_compressible(start << PAGE_SHIFT, 1) ||
> > -                 !pdx_is_region_compressible((end - 1) << PAGE_SHIFT, 1) )
> > +            if ( !pdx_is_region_compressible(pfn_to_paddr(start), 1) ||
> > +                 !pdx_is_region_compressible(pfn_to_paddr(end - 1), 1) )
> >              {
> >                  printf(
> >      "PFN compression invalid, pages %#lx and %#lx should be 
> > compressible\n",
> 
> Largely unrelated remark, from going through all of the PAGE_SHIFT uses: Isn't
> the __LP64__ conditional excluding quite a few too many array elements in
> main()'s tests[]?

Hm, I think so.  Will send a separate fix for that however.

Thanks, Roger.



 


Rackspace

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