DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ruoyu Wang" <ruoyuw560@gmail.com>
Cc: vkoul@kernel.org, Frank.Li@kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH] dmaengine: idxd: Remove channel from list on registration failure
Date: Thu, 09 Jul 2026 06:37:27 +0000	[thread overview]
Message-ID: <20260709063728.3BE0A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709062303.4167624-1-ruoyuw560@gmail.com>

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

Pre-existing issues:
- [High] Unsafe lockless modification of `dma->channels` and missing `dma_list_mutex` lock leading to global list corruption.
--

--- Patch [1]: [PATCH] dmaengine: idxd: Remove channel from list on registration failure ---
commit 4fb2c9798431d41ef3638a29b584b02b54cf00cf
Author: Ruoyu Wang <ruoyuw560@gmail.com>

dmaengine: idxd: Remove channel from list on registration failure

This commit fixes a stale list entry bug by removing the channel from the
dma channels list before freeing it on the registration failure path.

> diff --git a/drivers/dma/idxd/dma.c b/drivers/dma/idxd/dma.c
> --- a/drivers/dma/idxd/dma.c
> +++ b/drivers/dma/idxd/dma.c
> @@ -289,6 +289,7 @@ static int idxd_register_dma_channel(struct idxd_wq *wq)
>  
>  	rc = dma_async_device_channel_register(dma, chan, NULL);
>  	if (rc < 0) {
> +		list_del(&chan->device_node);

[Severity: High]
This is a pre-existing issue, but does this list_del() and the surrounding
code need additional locking to safely modify the channel list?

Currently, idxd_register_dma_channel() modifies the shared dma->channels
list while only holding a per-workqueue lock, rather than a lock that
serializes access to the parent dma device.

Furthermore, this path calls dma_async_device_channel_register() which
leads to a lockless global list traversal:

idxd_register_dma_channel()
  dma_async_device_channel_register()
    dma_channel_rebalance()

The dma_channel_rebalance() function requires the caller to hold the global
dma_list_mutex, but dma_async_device_channel_register() does not acquire it.

If a privileged user triggers concurrent sysfs bind operations on multiple
idxd workqueue devices, could they race here and corrupt both the global
dma_device_list and the shared dma->channels list?

>  		kfree(idxd_chan);
>  		return rc;
>  	}

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

  reply	other threads:[~2026-07-09  6:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09  6:23 [PATCH] dmaengine: idxd: Remove channel from list on registration failure Ruoyu Wang
2026-07-09  6:37 ` sashiko-bot [this message]
2026-07-09 15:30 ` 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=20260709063728.3BE0A1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=ruoyuw560@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