mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yang Zi <2959243019@qq.com>
To: dave.jiang@intel.com, vkoul@kernel.org, dmaengine@vger.kernel.org
Cc: Frank.Li@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] dmaengine: ioatdma: Fix NULL pointer dereference in ioat_alloc_chan_resources()
Date: Tue, 25 Aug 2026 17:14:16 +0800	[thread overview]
Message-ID: <tencent_629A33A5198254C3EC75AF7CB18050796F07@qq.com> (raw)

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);
 


             reply	other threads:[~2026-08-25  9:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  9:14 Yang Zi [this message]
2026-08-25 14:49 ` Dave Jiang

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=tencent_629A33A5198254C3EC75AF7CB18050796F07@qq.com \
    --to=2959243019@qq.com \
    --cc=Frank.Li@kernel.org \
    --cc=dave.jiang@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vkoul@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

all inboxes | Powered by JetHome®