All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: ioatdma: Fix NULL pointer dereference in ioat_alloc_chan_resources()
@ 2026-08-25  9:14 Yang Zi
  2026-08-25 14:49 ` Dave Jiang
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Zi @ 2026-08-25  9:14 UTC (permalink / raw)
  To: dave.jiang, vkoul, dmaengine; +Cc: Frank.Li, linux-kernel

ioat_alloc_chan_resources() performs MMIO accesses using
ioat_chan->reg_base without validating that the device's BAR mapping
(ioat_chan->ioat_dma->reg_base) is valid.  If the PCI BAR is not
properly mapped, reg_base is NULL and the channel's reg_base is computed
as NULL plus a small channel offset, so the first writew() touches an
address near NULL and faults.

KASAN/Oops report:

    BUG: kernel NULL pointer dereference, address: 0000000000000181
    #PF: supervisor write access in kernel mode
    #PF: error_code(0x0002) - not-present page
    RIP: 0010:ioat_alloc_chan_resources+0x40b/0x1ff0 [drivers/dma/ioat/init.c:679]

Validate the MMIO base before any register access and return -ENODEV if
it is not mapped.

Signed-off-by: Yang Zi <2959243019@qq.com>
---
 drivers/dma/ioat/init.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
index 737496391109..80dc8f36c346 100644
--- a/drivers/dma/ioat/init.c
+++ b/drivers/dma/ioat/init.c
@@ -677,6 +677,10 @@ static int ioat_alloc_chan_resources(struct dma_chan *c)
     if (ioat_chan->ring)
         return 1 << ioat_chan->alloc_order;
 
+    /* Validate the MMIO base before any register access. */
+    if (!ioat_chan->ioat_dma->reg_base)
+        return -ENODEV;
+
     /* Setup register to interrupt and write completion status on error */
     writew(IOAT_CHANCTRL_RUN, ioat_chan->reg_base + IOAT_CHANCTRL_OFFSET);
 


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

end of thread, other threads:[~2026-08-25 14:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25  9:14 [PATCH] dmaengine: ioatdma: Fix NULL pointer dereference in ioat_alloc_chan_resources() Yang Zi
2026-08-25 14:49 ` Dave Jiang

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.