All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Frank.Li@oss.nxp.com
Cc: Frank.Li@kernel.org, imx@lists.linux.dev, vkoul@kernel.org,
	dmaengine@vger.kernel.org, linux-sunxi@lists.linux.dev,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] dmaengine: vchan: add vchan_chan_name() to get channel device name
Date: Thu, 03 Sep 2026 21:03:23 +0000	[thread overview]
Message-ID: <20260903210323.EC1891F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903-dma-chan_dev-rename-v2-1-0db305b6c716@nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but there is a preexisting Use-After-Free of the channel name string in the IRQ handler registration on the probe error path.
--

commit 33984ca85ddf2f8f41c22000aad40c8fceb5f946
Author: Frank Li <Frank.Li@nxp.com>

dmaengine: vchan: add vchan_chan_name() to get channel device name

Introduce vchan_chan_name() to obtain the DMA channel device name.
Use a dedicated helper instead of directly accessing dma_chan::dev
so callers remain unaffected by an upcoming rename of the struct member.

[ ... ]

> diff --git a/drivers/dma/stm32/stm32-dma.c b/drivers/dma/stm32/stm32-dma.c
> index d3ad78562a140..3e8151e2ad75a 100644
> --- a/drivers/dma/stm32/stm32-dma.c
> +++ b/drivers/dma/stm32/stm32-dma.c
> @@ -1668,7 +1668,7 @@ static int stm32_dma_probe(struct platform_device *pdev)
>  
>  		ret = devm_request_irq(&pdev->dev, chan->irq,
>  				       stm32_dma_chan_irq, 0,
> -				       dev_name(chan2dev(chan)), chan);
> +				       vchan_chan_name(&chan->vchan), chan);

[Severity: High]
This isn't a bug introduced by this patch, but is there a preexisting
Use-After-Free of the channel name string in the IRQ handler registration on
the probe error path?

In stm32_dma_probe(), the driver successfully registers the DMA device using
dma_async_device_register(), then iteratively allocates devres-managed IRQs
using devm_request_irq() with the channel name pointer from vchan_chan_name().

If a subsequent operation fails (e.g. of_dma_controller_register()), the error
handling path manually calls dma_async_device_unregister(dd). This frees the
DMA device and its dynamically allocated channel name string immediately.

However, the devres-managed IRQs remain active until the probe function returns
and devres cleanup runs. During this window, the IRQ subsystem holds a dangling
pointer to the freed channel name.

Could this race window be triggered by unprivileged users concurrently reading
/proc/interrupts, or if an interrupt fires during this time?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903-dma-chan_dev-rename-v2-0-0db305b6c716@nxp.com?part=1

  reply	other threads:[~2026-09-03 21:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 20:53 [PATCH v2 0/3] dmaengine: rename dma_chan::dev to dma_chan::chan_dev for clarity Frank.Li
2026-09-03 20:53 ` [PATCH v2 1/3] dmaengine: vchan: add vchan_chan_name() to get channel device name Frank.Li
2026-09-03 21:03   ` sashiko-bot [this message]
2026-09-03 22:30   ` Logan Gunthorpe
2026-09-04  8:35   ` Amelie Delaunay
2026-09-04  9:10     ` [Linux-stm32] " Amelie Delaunay
2026-09-04 14:21       ` Frank Li
2026-09-04  9:08   ` Andy Shevchenko
2026-09-04  9:26     ` Amelie Delaunay
2026-09-04 11:38       ` Andy Shevchenko
2026-09-03 20:53 ` [PATCH v2 2/3] dmaengine: use dma_chan_name() helper to get per-channel " Frank.Li
2026-09-03 21:05   ` sashiko-bot
2026-09-03 20:53 ` [PATCH v2 3/3] dmaengine: add union chan_dev for dma_chan::dev for clarity Frank.Li
2026-09-03 21:03   ` sashiko-bot
2026-09-04  9:19   ` Andy Shevchenko

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=20260903210323.EC1891F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=Frank.Li@oss.nxp.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 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.