From: sashiko-bot@kernel.org
To: "Qiliang Yuan" <qiliang.yuan@linux.dev>
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Subject: Re: [PATCH RFC 03/18] scsi: target: uring: Create a character device per backstore device
Date: Mon, 16 Nov 2026 00:33:51 +0000 [thread overview]
Message-ID: <sashiko-outbox-215953@kernel.org> (raw)
In-Reply-To: <20261115-feat-target-core-uring-v1-3-28cdc137eac6@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] scsi: target: uring: incomplete rollback in
tcmur_destroy_device()
- [Medium] scsi: target: uring: unsafe error unwind in
tcmur_configure_device()
--
commit d9ed44c0dc0f5b30e64edec0424a89f4739a2cf8
Author: Qiliang Yuan <qiliang.yuan@linux.dev>
scsi: target: uring: Create a character device per backstore device
This commit creates a /dev/tcmurN character device when a target_core_uring
device is configured, ties the device and queue lifetimes to the embedded
struct device, and adds the TCMUR_GET_DEV_INFO ioctl.
> diff --git a/drivers/target/target_core_uring.c b/drivers/target/target_core_uring.c
> index 135435748d367..d1ca4f16e7d0b 100644
> --- a/drivers/target/target_core_uring.c
> +++ b/drivers/target/target_core_uring.c
[ ... ]
> @@ -143,24 +226,47 @@ static int tcmur_configure_device(struct se_device *dev)
> if (ret)
> return ret;
>
> + ret = ida_alloc_max(&tcmur_ida, TCMUR_MINORS - 1, GFP_KERNEL);
> + if (ret < 0)
> + goto free_queues;
> + udev->dev_id = ret;
> +
> dev->dev_attrib.hw_block_size = udev->block_size;
> dev->dev_attrib.hw_max_sectors = TCMUR_MAX_IO_SIZE / udev->block_size;
> dev->dev_attrib.hw_queue_depth = udev->nr_queues * udev->queue_depth;
> dev->dev_attrib.is_nonrot = 1;
>
> + udev->cdev_dev.devt = MKDEV(MAJOR(tcmur_devt), udev->dev_id);
> + ret = dev_set_name(&udev->cdev_dev, "tcmur%d", udev->dev_id);
> + if (ret)
> + goto free_id;
> +
> + cdev_init(&udev->cdev, &tcmur_ch_fops);
> + udev->cdev.owner = THIS_MODULE;
> + ret = cdev_device_add(&udev->cdev, &udev->cdev_dev);
> + if (ret)
> + goto free_id;
> +
> return 0;
> +
> +free_id:
> + ida_free(&tcmur_ida, udev->dev_id);
> + udev->dev_id = -1;
> +free_queues:
> + tcmur_free_queues(udev);
> + return ret;
> }
[Severity: Medium]
Can the free_id error path free udev->queues and udev->dev_id while a file
is still open, or re-register udev->cdev_dev if enabling the device is
retried?
cdev_device_add() publishes udev->cdev via cdev_add() before calling
device_add(). If device_add() fails, a process may already have opened the
character device before cdev_del() runs, so freeing udev->dev_id and
udev->queues here releases resources while that opener still holds a file
referencing udev. In addition, because DF_CONFIGURED is not set on failure,
a later write to the configfs enable attribute calls
tcmur_configure_device() again on the same udev, running cdev_init() and
device_add() a second time on the embedded udev->cdev and udev->cdev_dev.
>
> static void tcmur_destroy_device(struct se_device *dev)
> {
> struct tcmur_dev *udev = TCMUR_DEV(dev);
>
> - tcmur_free_queues(udev);
> + cdev_device_del(&udev->cdev, &udev->cdev_dev);
> }
[Severity: Medium]
What cleans up udev->queues and udev->dev_id if target_configure_device()
fails after tcmur_configure_device() succeeds?
drivers/target/target_core_device.c:target_configure_device() {
...
ret = core_setup_alua(dev);
if (ret)
goto out_destroy_device;
...
out_destroy_device:
dev->transport->destroy_device(dev);
...
}
When core_setup_alua() fails, target_configure_device() calls
tcmur_destroy_device() without setting DF_CONFIGURED or calling
tcmur_free_device(), so udev->cdev_dev keeps its initial reference and
tcmur_cdev_release() does not run. The unconfigured se_device stays alive
in configfs with udev->queues still allocated, udev->dev_id still set, and
udev->cdev_dev already passed through device_add() and device_del().
If the user then increases nr_queues via tcmur_set_configfs_dev_params()
before removing the device, tcmur_free_queues() reads past the end of the
old udev->queues array and passes out-of-bounds pointers to vfree(). If the
user instead retries enabling the device, tcmur_configure_device() leaks the
previous udev->queues and udev->dev_id and calls cdev_init() and
device_add() a second time on the embedded udev->cdev and udev->cdev_dev.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261115-feat-target-core-uring-v1-0-28cdc137eac6@linux.dev?part=3
next prev parent reply other threads:[~2026-11-16 0:33 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 0:17 [PATCH RFC 00/18] scsi: target: Add target_core_uring, an io_uring based user backstore Qiliang Yuan
2026-11-16 0:17 ` [PATCH RFC 01/18] scsi: target: uring: Introduce " Qiliang Yuan
2026-11-16 0:38 ` sashiko-bot
2026-11-16 0:17 ` [PATCH RFC 02/18] scsi: target: uring: Allocate per-queue command descriptors Qiliang Yuan
2026-11-16 0:17 ` [PATCH RFC 03/18] scsi: target: uring: Create a character device per backstore device Qiliang Yuan
2026-11-16 0:33 ` sashiko-bot [this message]
2026-11-16 0:17 ` [PATCH RFC 04/18] scsi: target: uring: Map the command descriptors into the server Qiliang Yuan
2026-11-16 0:17 ` [PATCH RFC 05/18] scsi: target: uring: Queue commands until a server fetches them Qiliang Yuan
2026-11-16 0:46 ` sashiko-bot
2026-11-16 0:17 ` [PATCH RFC 06/18] scsi: target: uring: Hand commands out through TCMUR_IO_FETCH Qiliang Yuan
2026-11-16 0:18 ` [PATCH RFC 07/18] scsi: target: uring: Complete commands with TCMUR_IO_COMMIT_AND_FETCH Qiliang Yuan
2026-11-16 0:18 ` [PATCH RFC 08/18] scsi: target: uring: Copy command data with pread() and pwrite() Qiliang Yuan
2026-11-16 0:18 ` [PATCH RFC 09/18] scsi: target: uring: Fail in-flight commands when the server exits Qiliang Yuan
2026-11-16 0:18 ` [PATCH RFC 10/18] scsi: target: uring: Time out commands the server does not complete Qiliang Yuan
2026-11-16 0:41 ` sashiko-bot
2026-11-16 0:18 ` [PATCH RFC 11/18] scsi: target: uring: Drop aborted commands that are still queued Qiliang Yuan
2026-11-16 0:37 ` sashiko-bot
2026-11-16 0:18 ` [PATCH RFC 12/18] scsi: target: uring: Support SYNCHRONIZE CACHE Qiliang Yuan
2026-11-16 0:40 ` sashiko-bot
2026-11-16 0:18 ` [PATCH RFC 13/18] scsi: target: uring: Implement UNMAP Qiliang Yuan
2026-11-16 0:45 ` sashiko-bot
2026-11-16 0:18 ` [PATCH RFC 14/18] scsi: target: uring: Handle WRITE SAME Qiliang Yuan
2026-11-16 0:44 ` sashiko-bot
2026-11-16 0:18 ` [PATCH RFC 15/18] scsi: target: uring: Register command data as io_uring fixed buffers Qiliang Yuan
2026-11-16 0:18 ` [PATCH RFC 16/18] selftests: target_core_uring: Add a minimal server Qiliang Yuan
2026-11-16 1:03 ` sashiko-bot
2026-11-16 0:18 ` [PATCH RFC 17/18] selftests: target_core_uring: Test a device exported through tcm_loop Qiliang Yuan
2026-11-16 0:49 ` sashiko-bot
2026-11-16 0:18 ` [PATCH RFC 18/18] Documentation: target: Describe the uring backstore Qiliang Yuan
2026-11-16 2:32 ` [PATCH RFC 00/18] scsi: target: Add target_core_uring, an io_uring based user backstore Ming Lei
2026-11-17 2:46 ` Qiliang Yuan
2026-11-18 1:40 ` Ming Lei
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-215953@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=qiliang.yuan@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=target-devel@vger.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.