DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v2 2/5] dmaengine: ti: omap-dma: fix notifier leak in remove
Date: Mon, 01 Jun 2026 00:58:24 +0000	[thread overview]
Message-ID: <20260601005824.B7B101F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260601003553.72573-3-rosenp@gmail.com>

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

Pre-existing issues:
- [Critical] Potential Use-After-Free of notifier_block due to missing RCU synchronization.
--

commit 5e6f29c5f10bea4aff2b71ed41a418296a887ddf
Author: Rosen Penev <rosenp@gmail.com>

dmaengine: ti: omap-dma: fix notifier leak in remove

This commit fixes a notifier leak during driver removal. It ensures the CPU PM
notifier is unregistered if either the needs_busy_check or may_lose_context
flag is set, rather than only checking may_lose_context.

> diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
> --- a/drivers/dma/ti/omap-dma.c
> +++ b/drivers/dma/ti/omap-dma.c
> @@ -1853,7 +1853,7 @@ static void omap_dma_remove(struct platform_device *pdev)
>  	struct omap_dmadev *od = platform_get_drvdata(pdev);
>  	int irq;
>  
> -	if (od->cfg->may_lose_context)
> +	if (od->cfg->needs_busy_check || od->cfg->may_lose_context)
>  		cpu_pm_unregister_notifier(&od->nb);

[Severity: Critical]
This is a pre-existing issue, but does this unregister path leave the
notifier_block vulnerable to a use-after-free?

In omap_dma_remove(), cpu_pm_unregister_notifier() unlinks the notifier
block from the raw notifier chain but does not wait for an RCU grace period.
Because the od structure is managed by devres (allocated via devm_kzalloc),
it gets freed automatically shortly after omap_dma_remove() returns.

If a concurrent CPU PM transition (like another CPU entering or exiting idle
states) traverses the raw notifier chain using rcu_read_lock(), couldn't the
traversing CPU dereference the freshly freed notifier_block?

Would adding a synchronization mechanism for RCU before the driver is
released prevent this regression?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260601003553.72573-1-rosenp@gmail.com?part=2

  reply	other threads:[~2026-06-01  0:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01  0:35 [PATCH v2 0/5] dmaengine: ti: omap-dma: various bug fixes Rosen Penev
2026-06-01  0:35 ` [PATCH v2 1/5] dmaengine: ti: omap-dma: fix missing return in probe error path Rosen Penev
2026-06-01  0:35 ` [PATCH v2 2/5] dmaengine: ti: omap-dma: fix notifier leak in remove Rosen Penev
2026-06-01  0:58   ` sashiko-bot [this message]
2026-06-01  0:35 ` [PATCH v2 3/5] dmaengine: ti: omap-dma: fix dma_pool_destroy before omap_dma_free in error paths Rosen Penev
2026-06-01  1:12   ` sashiko-bot
2026-06-01  0:35 ` [PATCH v2 4/5] dmaengine: ti: omap-dma: fix interrupt handling in remove Rosen Penev
2026-06-01  1:27   ` sashiko-bot
2026-06-01  0:35 ` [PATCH v2 5/5] dmaengine: ti: omap-dma: use devm for dmaengine registration Rosen Penev
2026-06-01  1:36   ` sashiko-bot

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=20260601005824.B7B101F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=rosenp@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox