mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guixin Liu <kanie@linux.alibaba.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] PCI: Check rom header and data structure addr before accessing
Date: Thu, 27 Nov 2025 09:58:31 +0800	[thread overview]
Message-ID: <89568cc6-4251-4d59-9794-0a76adf3b7a8@linux.alibaba.com> (raw)
In-Reply-To: <aSc78vbl70YCWR56@smile.fi.intel.com>



在 2025/11/27 01:42, Andy Shevchenko 写道:
> 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.
>
Sure, changed in v5.

Best Regards

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


  reply	other threads:[~2025-11-27  1:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26 12:57 Guixin Liu
2025-11-26 17:39 ` Andy Shevchenko
2025-11-26 17:42   ` Andy Shevchenko
2025-11-27  1:58     ` Guixin Liu [this message]
2025-11-27  1:57   ` Guixin Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=89568cc6-4251-4d59-9794-0a76adf3b7a8@linux.alibaba.com \
    --to=kanie@linux.alibaba.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®