Linux SCSI subsystem development
 help / color / mirror / Atom feed
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 01/18] scsi: target: uring: Introduce an io_uring based user backstore
Date: Mon, 16 Nov 2026 00:38:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-215959@kernel.org> (raw)
In-Reply-To: <20261115-feat-target-core-uring-v1-1-28cdc137eac6@linux.dev>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] scsi: target: missing target_core_uring autoload in
  transport_subsystem_check_init()
- [Medium] scsi: target: uring: block_size desync and underflow in
  tcmur_get_blocks()
--

commit 61188ead36f715e3a08be0d083f957ddb97dafd3
Author: Qiliang Yuan <qiliang.yuan@linux.dev>

scsi: target: uring: Introduce an io_uring based user backstore

This commit adds the initial target_core_uring LIO backstore plugin with
configfs support for configuring device size and block size, and emulates
SCSI commands via sbc_parse_cdb().

> diff --git a/drivers/target/Kconfig b/drivers/target/Kconfig
> index 92641d39126a3..545a1d4cf37e5 100644
> --- a/drivers/target/Kconfig
> +++ b/drivers/target/Kconfig
> @@ -43,6 +43,16 @@ config TCM_USER2
>  	process to handle requests. This is version 2 of the ABI; version 1
>  	is obsolete.
>  
> +config TCM_URING
> +	tristate "TCM/URING Subsystem Plugin for Linux"
> +	depends on IO_URING
> +	help
> +	  Say Y here to enable the TCM/URING subsystem plugin, which lets a
> +	  userspace server handle the block commands of a device through
> +	  io_uring commands. Unlike TCM/USER, the kernel emulates the SCSI
> +	  commands and the server only reads, writes, flushes and unmaps
> +	  blocks, on several queues and without copying data twice.
> +

[Severity: Medium]
Should transport_subsystem_check_init() also autoload target_core_uring
when CONFIG_TCM_URING=m?

When creating an HBA directory in configfs, target_core_call_addhbatotarget()
calls transport_subsystem_check_init(), which autoloads the other modular
backstores (target_core_iblock, target_core_file, target_core_pscsi, and
target_core_user) via request_module() before core_alloc_hba() searches
backend_list.  Without an entry for target_core_uring, creating a uring_<id>
HBA in configfs fails with -EINVAL unless the module was loaded manually
beforehand.

> diff --git a/drivers/target/target_core_uring.c b/drivers/target/target_core_uring.c
> new file mode 100644
> index 0000000000000..13981e608a85c
> --- /dev/null
> +++ b/drivers/target/target_core_uring.c
[ ... ]
> +		switch (token) {
> +		case Opt_block_size:
> +			if (val < 512 || val > PAGE_SIZE || !is_power_of_2(val))
> +				ret = -EINVAL;
> +			else
> +				udev->block_size = val;
> +			break;
> +		}
> +	}
> +
> +	kfree(orig);
> +	return ret ? ret : count;
> +}
> +
> +static ssize_t tcmur_show_configfs_dev_params(struct se_device *dev, char *b)
> +{
> +	struct tcmur_dev *udev = TCMUR_DEV(dev);
> +	ssize_t bl = 0;
> +
> +	bl += sprintf(b + bl, "Size: %llu Block size: %u", udev->dev_size,
> +		      udev->block_size);
> +	bl += sprintf(b + bl, "\n");
> +	return bl;
> +}
> +
> +static sector_t tcmur_get_blocks(struct se_device *dev)
> +{
> +	struct tcmur_dev *udev = TCMUR_DEV(dev);
> +
> +	return div_u64(udev->dev_size, dev->dev_attrib.block_size) - 1;
> +}

[Severity: Medium]
Can tcmur_get_blocks() underflow to ULLONG_MAX and leave udev->block_size
out of sync when attrib/block_size is modified after device configuration?

Because tcmur_ops sets tb_dev_attrib_attrs = sbc_attrib_attrs, userspace
can write to attrib/block_size after target_configure_device() has run.
block_size_store() updates dev->dev_attrib.block_size without updating
udev->block_size or revalidating udev->dev_size.  If a device is configured
with dev_size=512 and block_size=512 and attrib/block_size is then set to
4096, div_u64(udev->dev_size, dev->dev_attrib.block_size) returns 0 and
tcmur_get_blocks() wraps to ULLONG_MAX, wrapping end_lba to 0 in
sbc_parse_cdb() and reporting 0xffffffffffffffff blocks in
READ CAPACITY (16).

Also, Opt_block_size accepts powers of two up to PAGE_SIZE, which on 16K or
64K page kernels permits block sizes above 4096 that LIO core does not
support in block_size_store() or target_to_linux_sector().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261115-feat-target-core-uring-v1-0-28cdc137eac6@linux.dev?part=1

  reply	other threads:[~2026-11-16  0:38 UTC|newest]

Thread overview: 29+ 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 [this message]
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
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

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-215959@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox