From: sashiko-bot@kernel.org
To: "Yao Kai" <yaokai34@huawei.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH] dmaengine: idxd: Avoid destroying the device workqueue twice
Date: Wed, 11 Nov 2026 02:43:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-208111@kernel.org> (raw)
In-Reply-To: <20261111021026.3354620-1-yaokai34@huawei.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] dmaengine: idxd: use-after-free and double free in
idxd_alloc() [1]
--
commit 8d423d27ba8372d572adfd4d4096b791e0e07bdf
Author: Yao Kai <yaokai34@huawei.com>
dmaengine: idxd: Avoid destroying the device workqueue twice
This commit clears idxd->wq after destroying the workqueue on error paths
and guards destroy_workqueue() in idxd_conf_device_release() with a NULL
check so that the workqueue is not destroyed twice.
> diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
> index 6d251095c350f..d5ffc641c8567 100644
> --- a/drivers/dma/idxd/sysfs.c
> +++ b/drivers/dma/idxd/sysfs.c
> @@ -1836,7 +1836,8 @@ static void idxd_conf_device_release(struct device *dev)
> {
> struct idxd_device *idxd = confdev_to_idxd(dev);
>
> - destroy_workqueue(idxd->wq);
> + if (idxd->wq)
> + destroy_workqueue(idxd->wq);
> kfree(idxd->groups);
> bitmap_free(idxd->wq_enable_map);
> kfree(idxd->wqs);
[Severity: Critical]
This problem wasn't introduced by this patch, but can the err_name path in
idxd_alloc() cause a use-after-free and double free [1] of idxd,
idxd->opcap_bmap, and idxd->id?
drivers/dma/idxd/init.c:idxd_alloc() {
...
device_initialize(conf_dev);
conf_dev->parent = dev;
conf_dev->bus = &dsa_bus_type;
conf_dev->type = idxd->data->dev_type;
rc = dev_set_name(conf_dev, "%s%d", idxd->data->name_prefix, idxd->id);
if (rc < 0)
goto err_name;
...
err_name:
put_device(conf_dev);
bitmap_free(idxd->opcap_bmap);
err_opcap:
ida_free(&idxd_ida, idxd->id);
err_ida:
kfree(idxd);
...
}
When dev_set_name() fails, conf_dev->type is already set, so
put_device(conf_dev) invokes idxd_conf_device_release(), which frees
idxd->id, idxd->opcap_bmap, and idxd. The fallthrough to err_opcap and
err_ida then reads from the freed idxd struct and frees all three a second
time.
[1] https://sashiko.dev/#/bug/linux-4811d59b-3028-4d67-8ce7-e0e9de64774f
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111021026.3354620-1-yaokai34@huawei.com?part=1
prev parent reply other threads:[~2026-11-11 2:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 2:10 [PATCH] dmaengine: idxd: Avoid destroying the device workqueue twice Yao Kai
2026-11-11 2:43 ` sashiko-bot [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=sashiko-outbox-208111@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
--cc=yaokai34@huawei.com \
/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