From: Bjorn Helgaas <helgaas@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Philipp Stanner <phasta@kernel.org>, linux-pci@vger.kernel.org
Subject: Re: [bug report] PCI: Check BAR index for validity
Date: Sat, 8 Mar 2025 15:07:20 -0600 [thread overview]
Message-ID: <20250308210720.GA469242@bhelgaas> (raw)
In-Reply-To: <9b116a86-d235-4a77-8002-7de0be61e24f@stanley.mountain>
On Sat, Mar 08, 2025 at 01:23:28PM +0300, Dan Carpenter wrote:
> Hello Philipp Stanner,
>
> Commit ba10e5011d05 ("PCI: Check BAR index for validity") from Mar 4,
> 2025 (linux-next), leads to the following Smatch static checker
> warning:
>
> drivers/pci/devres.c:632 pcim_remove_bar_from_legacy_table()
> error: buffer overflow 'legacy_iomap_table' 6 <= 15
Thanks, I dropped this patch for now.
> drivers/pci/devres.c
> 621 static void pcim_remove_bar_from_legacy_table(struct pci_dev *pdev, int bar)
> 622 {
> 623 void __iomem **legacy_iomap_table;
> 624
> 625 if (!pci_bar_index_is_valid(bar))
>
> This line used to check PCI_STD_NUM_BARS (6) but now it's checking
> PCI_NUM_RESOURCES (15).
>
> 626 return;
> 627
> 628 legacy_iomap_table = (void __iomem **)pcim_iomap_table(pdev);
> 629 if (!legacy_iomap_table)
> 630 return;
> 631
> --> 632 legacy_iomap_table[bar] = NULL;
> ^^^^^^^^^^^^^^^^^^^^^^^
> Leading to a buffer overflow.
>
> 633 }
>
> regards,
> dan carpenter
next prev parent reply other threads:[~2025-03-08 21:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-08 10:23 [bug report] PCI: Check BAR index for validity Dan Carpenter
2025-03-08 21:07 ` Bjorn Helgaas [this message]
2025-03-10 7:54 ` Philipp Stanner
2025-03-10 8:57 ` Philipp Stanner
2025-03-10 9:18 ` Dan Carpenter
2025-03-10 19:53 ` Bjorn Helgaas
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=20250308210720.GA469242@bhelgaas \
--to=helgaas@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=linux-pci@vger.kernel.org \
--cc=phasta@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