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 05/18] scsi: target: uring: Queue commands until a server fetches them
Date: Mon, 16 Nov 2026 00:46:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-215970@kernel.org> (raw)
In-Reply-To: <20261115-feat-target-core-uring-v1-5-28cdc137eac6@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] scsi: target: uring: missing TCMUR_MAX_IO_SIZE check in
tcmur_execute_rw()
--
commit aaa41f59a5c1c48ba973ecbd7b4b910b4c814276
Author: Qiliang Yuan <qiliang.yuan@linux.dev>
scsi: target: uring: Queue commands until a server fetches them
This commit allocates a struct tcmur_cmd for each read and write command,
populates its I/O descriptor, and queues it on the pending list of the
submitting CPU's queue.
> diff --git a/drivers/target/target_core_uring.c b/drivers/target/target_core_uring.c
> index 904ce2a613618..90e443ecb944c 100644
> --- a/drivers/target/target_core_uring.c
> +++ b/drivers/target/target_core_uring.c
[ ... ]
> @@ -66,12 +88,56 @@ static struct tcmur_dev *TCMUR_DEV(struct se_device *dev)
> return container_of(dev, struct tcmur_dev, se_dev);
> }
>
> +static struct tcmur_queue *tcmur_cmd_queue(struct tcmur_dev *udev,
> + struct se_cmd *se_cmd)
> +{
> + return &udev->queues[(unsigned int)se_cmd->cpuid % udev->nr_queues];
> +}
> +
> +static void tcmur_queue_cmd(struct tcmur_dev *udev, struct tcmur_cmd *tcmd)
> +{
> + struct tcmur_queue *q = tcmur_cmd_queue(udev, tcmd->se_cmd);
> +
> + spin_lock(&q->lock);
> + list_add_tail(&tcmd->node, &q->pending);
> + spin_unlock(&q->lock);
> +}
> +
> +static sense_reason_t tcmur_submit(struct se_cmd *se_cmd, u32 op, u64 offset,
> + u64 len, struct scatterlist *sgl,
> + u32 sgl_nents)
> +{
> + struct tcmur_dev *udev = TCMUR_DEV(se_cmd->se_dev);
> + struct tcmur_cmd *tcmd;
> +
> + tcmd = kmem_cache_zalloc(tcmur_cmd_cache, GFP_NOIO);
> + if (!tcmd)
> + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
> +
> + tcmd->se_cmd = se_cmd;
> + tcmd->sgl = sgl;
> + tcmd->sgl_nents = sgl_nents;
> + tcmd->desc.op = op;
> + tcmd->desc.offset = offset;
> + tcmd->desc.len = len;
> + tcmd->desc.data_len = se_cmd->data_length;
> + if (op == TCMUR_OP_WRITE && (se_cmd->se_cmd_flags & SCF_FUA))
> + tcmd->desc.flags |= TCMUR_IO_F_FUA;
> +
> + tcmur_queue_cmd(udev, tcmd);
> + return 0;
> +}
> +
> static sense_reason_t tcmur_execute_rw(struct se_cmd *se_cmd,
> struct scatterlist *sgl, u32 sgl_nents,
> enum dma_data_direction dir)
> {
> - /* Fail the commands until a server can pick them up */
> - return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
> + u32 block_size = se_cmd->se_dev->dev_attrib.block_size;
> +
> + return tcmur_submit(se_cmd, dir == DMA_FROM_DEVICE ? TCMUR_OP_READ :
> + TCMUR_OP_WRITE,
> + se_cmd->t_task_lba * block_size,
> + se_cmd->data_length, sgl, sgl_nents);
> }
[Severity: High]
Can tcmur_execute_rw() queue a command with tcmd->desc.data_len larger than
the TCMUR_MAX_IO_SIZE limit advertised by TCMUR_GET_DEV_INFO in
info.max_io_size?
Although tcmur_configure_device() sets dev->dev_attrib.hw_max_sectors to
TCMUR_MAX_IO_SIZE / udev->block_size, the target core only uses
hw_max_sectors to report the advisory maximum transfer length in Block
Limits VPD page 0xb0 and does not reject READ or WRITE commands that exceed
it (unlike fd_execute_rw(), which checks cmd->data_length > FD_MAX_BYTES).
An initiator can send a READ or WRITE command larger than 4 MiB and cause a
userspace server that sizes its I/O buffer to info.max_io_size (such as
tcmur_server.c in this series) to overflow its buffer.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261115-feat-target-core-uring-v1-0-28cdc137eac6@linux.dev?part=5
next prev parent reply other threads:[~2026-11-16 0:46 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
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 [this message]
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-215970@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