Linux PCI subsystem development
 help / color / mirror / Atom feed
* [bug report] PCI: Check BAR index for validity
@ 2025-03-08 10:23 Dan Carpenter
  2025-03-08 21:07 ` Bjorn Helgaas
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2025-03-08 10:23 UTC (permalink / raw)
  To: Philipp Stanner; +Cc: linux-pci

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

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-03-10 19:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-08 10:23 [bug report] PCI: Check BAR index for validity Dan Carpenter
2025-03-08 21:07 ` Bjorn Helgaas
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox