From: sashiko-bot@kernel.org
To: "James Sawyer" <james@jamessawyer.co.uk>
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Subject: Re: [PATCH v2] scsi: target: iscsi: reject Text continuations that carry data
Date: Thu, 03 Dec 2026 12:56:53 +0000 [thread overview]
Message-ID: <sashiko-outbox-247806@kernel.org> (raw)
In-Reply-To: <20261203-iscsi-text-double-listadd-v2-1-36ebee74657d@jamessawyer.co.uk>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Critical] scsi: target: iscsi: late reject in
iscsit_process_text_cmd() races live cmd
--
commit 32cdbf151fa81a960d964a21d4f123dfe2121be1
Author: James Sawyer <james@jamessawyer.co.uk>
scsi: target: iscsi: reject Text continuations that carry data
This commit rejects iSCSI Text Request continuations (TTT != 0xFFFFFFFF)
that carry a text_in payload in iscsit_process_text_cmd() by branching to
iscsit_reject_cmd().
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 124ff269b8e75..f542098e5d877 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
> @@ -2207,6 +2207,17 @@ iscsit_process_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
> }
> goto empty_sendtargets;
> }
> + /*
> + * A Text Request with TTT != 0xFFFFFFFF continues an earlier
> + * response and reuses the command found by ITT, which is still on
> + * conn_cmd_list. Only an empty continuation is supported; a new
> + * request must not be processed on that command.
> + */
> + if (hdr->ttt != cpu_to_be32(0xFFFFFFFF)) {
> + pr_err("Text continuation with data is not supported, TTT: 0x%08x\n",
> + be32_to_cpu(hdr->ttt));
> + goto reject;
> + }
[Severity: Critical]
Can rejecting a reused command this late in iscsit_process_text_cmd() race
with the TX thread and corrupt or leak cmd->buf_ptr?
By the time this check runs, iscsit_setup_text_cmd() has already mutated the
live cmd in place and freed cmd->text_in_ptr. iscsit_add_reject_from_cmd()
then replaces cmd->buf_ptr with a 48-byte kmemdup() buffer, writes
cmd->i_state without cmd->istate_lock, and re-queues cmd on the response list.
An unauthenticated discovery initiator can pipeline a data-carrying Text
continuation while the TX thread is sending the prior Text response:
RX thread TX thread
iscsit_find_cmd_from_itt()
iscsit_setup_text_cmd()
kfree(cmd->text_in_ptr)
iscsit_send_text_rsp()
iscsit_build_sendtargets_response()
/* sets buf_ptr, up to 32 KiB */
iscsit_process_text_cmd()
goto reject
iscsit_add_reject_from_cmd()
cmd->buf_ptr = kmemdup(...)
iscsit_xmit_pdu(..., cmd->buf_ptr,
text_length)
<-- out-of-bounds read (up to 32 KiB)
This causes a use-after-free of cmd->text_in_ptr in
iscsit_build_sendtargets_response() under ICF_SENDTARGETS_SINGLE, or a slab
out-of-bounds read or DMA map past the 48-byte kmemdup() buffer.
Even without a race, iscsit_add_reject_from_cmd() overwrites cmd->buf_ptr
without freeing the prior SendTargets buffer (leaking up to 32 KiB per PDU),
and on kmemdup() failure it calls iscsit_free_cmd(cmd, false) while cmd is
still linked on conn->conn_cmd_list.
If hdr->itt matches an active SCSI or TMR command (cmd->se_cmd.se_tfo !=
NULL), iscsit_add_reject_from_cmd() also calls target_put_sess_cmd() and
drops a reference it does not own.
On iSER, re-queuing ISTATE_SEND_REJECT reuses isert_cmd->tx_desc and
comp_work while a prior send or completion may still be in flight, and
leaving ISCSI_FLAG_TEXT_CONTINUE set in tx_desc.iscsi_header causes
isert_put_cmd() to keep cmd stuck on conn->conn_cmd_list.
Should data-carrying Text continuations be rejected before mutating the
looked-up command and without repurposing it through iscsit_reject_cmd()
(using iscsit_add_reject() in iscsi_target and cxgbit, and a fresh
isert_allocate_cmd() reject or connection reinstatement in isert)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-iscsi-text-double-listadd-v2-1-36ebee74657d@jamessawyer.co.uk?part=1
prev parent reply other threads:[~2026-12-03 12:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 12:34 [PATCH v2] scsi: target: iscsi: reject Text continuations that carry data James Sawyer via B4 Relay
2026-12-03 12:56 ` 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-247806@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=james@jamessawyer.co.uk \
--cc=linux-scsi@vger.kernel.org \
--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