DMA Engine development
 help / color / mirror / Atom feed
* [PATCH] dmaengine: ioat: reject a non-memory BAR 0 in probe
@ 2026-11-30 16:24 Dave Jiang
  0 siblings, 0 replies; only message in thread
From: Dave Jiang @ 2026-11-30 16:24 UTC (permalink / raw)
  To: dmaengine; +Cc: Frank.Li, vkoul, syzbot+79a6b3f7a8df01f58774

ioat_pci_probe() reads the version register from BAR 0 with readb().
If the device's BAR 0 is an I/O port BAR, pci_iomap() returns a port
cookie rather than an MMIO address, and readb() faults on it.

Normal ID matching never binds such a device, but driver_override
can. Return -ENODEV if BAR 0 is not a memory BAR.

Reported-by: syzbot+79a6b3f7a8df01f58774@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=79a6b3f7a8df01f58774
Signed-off-by: Dave Jiang <dave.jiang@intel.com>

---

It's a defensive measure more than anything. Reproduced by forcing the
ioatdma driver onto a different PCI device. Will not add a Fixes tag.
---
 drivers/dma/ioat/init.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
index a57024c4b066..48b855d5deff 100644
--- a/drivers/dma/ioat/init.c
+++ b/drivers/dma/ioat/init.c
@@ -1355,6 +1355,9 @@ static int ioat_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (err)
 		return err;
 
+	if (!(pci_resource_flags(pdev, IOAT_MMIO_BAR) & IORESOURCE_MEM))
+		return -ENODEV;
+
 	err = pcim_iomap_regions(pdev, 1 << IOAT_MMIO_BAR, DRV_NAME);
 	if (err)
 		return err;

base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.54.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-30 16:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 16:24 [PATCH] dmaengine: ioat: reject a non-memory BAR 0 in probe Dave Jiang

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