All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: ioat: reject a non-memory BAR 0 in probe
@ 2026-11-30 16:24 Dave Jiang
  2026-12-01 20:12 ` Frank Li
  0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread

* Re: [PATCH] dmaengine: ioat: reject a non-memory BAR 0 in probe
  2026-11-30 16:24 [PATCH] dmaengine: ioat: reject a non-memory BAR 0 in probe Dave Jiang
@ 2026-12-01 20:12 ` Frank Li
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Li @ 2026-12-01 20:12 UTC (permalink / raw)
  To: Dave Jiang; +Cc: dmaengine, Frank.Li, vkoul, syzbot+79a6b3f7a8df01f58774

On Mon, Nov 30, 2026 at 09:24:25AM -0700, Dave Jiang wrote:
> 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>
>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.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	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01 20:12 UTC | newest]

Thread overview: 2+ messages (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
2026-12-01 20:12 ` Frank Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.