lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aSc78vbl70YCWR56@smile.fi.intel.com>
Date: Wed, 26 Nov 2025 19:42:10 +0200
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Guixin Liu <kanie@...ux.alibaba.com>
Cc: Bjorn Helgaas <bhelgaas@...gle.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4] PCI: Check rom header and data structure addr before
 accessing

On Wed, Nov 26, 2025 at 07:39:18PM +0200, Andy Shevchenko wrote:
> On Wed, Nov 26, 2025 at 08:57:27PM +0800, Guixin Liu wrote:

...

> >  	image = rom;
> >  	do {
> >  		void __iomem *pds;
> > +
> > +		if (!pci_rom_header_valid(pdev, image, rom, size, true))
> >  			break;
> > +
> >  		/* get the PCI data structure and check its "PCIR" signature */
> >  		pds = image + readw(image + 24);
> > +		if (!pci_rom_data_struct_valid(pdev, pds, rom, size))
> >  			break;
> > +
> > +		last_image = !!(readb(pds + 21) & 0x80);
> 
> !!() is not needed.
> 
> 		last_image = readb(pds + 21) & 0x80;

And while at it, isn't this a bit field and

		last_image = readb(pds + 21) & BIT(7);

is even more descriptive? Please, check with specification and if it's
a (single) bit, also change this.

> >  		length = readw(pds + 16);
> >  		image += length * 512;
> > +
> > +		if (!pci_rom_header_valid(pdev, image, rom, size, last_image))
> >  			break;
> >  	} while (length && !last_image);

-- 
With Best Regards,
Andy Shevchenko



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ