mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Yang Zi <2959243019@qq.com>, vkoul@kernel.org, dmaengine@vger.kernel.org
Cc: Frank.Li@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dmaengine: ioatdma: Fix NULL pointer dereference in ioat_alloc_chan_resources()
Date: Tue, 25 Aug 2026 07:49:20 -0700	[thread overview]
Message-ID: <90003b42-543c-483e-a490-e9832bf7a14d@intel.com> (raw)
In-Reply-To: <tencent_629A33A5198254C3EC75AF7CB18050796F07@qq.com>



On 8/25/26 2:14 AM, Yang Zi wrote:
> 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>

NAK. This not reachable code. By the time ioat_alloc_chan_resources() gets called, reg_base would never be NULL. If iomap has failed, it would've failed long before this. The pci probe would've failed and the driver would not have loaded.

DJ


> ---
>  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 14:49 UTC|newest]

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

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=90003b42-543c-483e-a490-e9832bf7a14d@intel.com \
    --to=dave.jiang@intel.com \
    --cc=2959243019@qq.com \
    --cc=Frank.Li@kernel.org \
    --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®