From: sashiko-bot@kernel.org
To: "Andrew Stellman" <bugs@stellman-greene.com>
Cc: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 2/2] scsi: target: iscsi: Reject SendTargets=All on Normal sessions
Date: Fri, 04 Dec 2026 19:20:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-250522@kernel.org> (raw)
In-Reply-To: <20261204184309.70952-3-bugs@stellman-greene.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Critical] scsi: target: iscsi: UAF when rejecting Text PDU reusing
SCSI or TMR ITT
- [Critical] scsi: target: iscsi: buf_ptr leak and TX OOB read on reused
NOP-Out ITT
--
commit b14aaa98ccafd0087fcc5c1540989f44bd35234f
Author: Andrew Stellman <astellman@stellman-greene.com>
scsi: target: iscsi: Reject SendTargets=All on Normal sessions
This commit rejects SendTargets=All and empty Text requests without
ICF_SENDTARGETS_SINGLE in iscsit_process_text_cmd() when running on a
Normal session.
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 7bf4a3b0998fb..133fc4f0d9bbb 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
> @@ -2186,6 +2186,9 @@ iscsit_process_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
> " discovery\n");
> goto reject;
> }
> + if (!conn->sess->sess_ops->SessionType &&
> + !(cmd->cmd_flags & ICF_SENDTARGETS_SINGLE))
> + goto reject;
> goto empty_sendtargets;
> }
> if (strncmp("SendTargets=", text_in, 12) != 0) {
[Severity: Critical]
Can this reject path cause a use-after-free on cmd and cmd->buf_ptr when
an empty Text PDU reuses the ITT of a SCSI command?
For hdr->ttt != 0xffffffff, iscsi_target_rx_opcode() (and the iSER and
cxgbit RX paths) looks up cmd with iscsit_find_cmd_from_itt() without
checking cmd->iscsi_opcode or cmd->targ_xfer_tag. Routing that command
to reject calls iscsit_reject_cmd() -> iscsit_add_reject_from_cmd().
Because cmd->se_cmd.se_tfo is non-NULL, iscsit_add_reject_from_cmd()
queues cmd on conn->response_queue_list and calls
target_put_sess_cmd(&cmd->se_cmd).
For a completed SCSI command awaiting ExpStatSN (cmd_kref == 1 after
lio_check_stop_free()), that drops cmd_kref to 0 and runs
iscsit_release_cmd() while cmd is still queued for TX and linked on
conn->conn_cmd_list.
Freeing cmd->buf_ptr and returning cmd to the session tag pool causes a
use-after-free in iscsit_send_reject(), followed by a refcount underflow
and double free in iscsit_release_commands_from_conn().
Earlier, iscsit_setup_text_cmd() also overwrites cmd->data_direction
with DMA_NONE, causing SCSI WRITE teardown to skip stopping
cmd->dataout_timer and freeing cmd_r2t_list.
Rejecting non-0xffffffff TTT Text PDUs with iscsit_add_reject() before
iscsit_setup_text_cmd() when the looked-up command is not an
ISCSI_OP_TEXT with matching targ_xfer_tag would avoid mutating foreign
commands.
[Severity: Critical]
Does rejecting an empty Text PDU that reuses a NOP-Out ITT leak
cmd->buf_ptr and allow an out-of-bounds read in iscsit_send_nopin()?
When a NOP-Out carries ping data, iscsit_handle_nop_out() stores it in
cmd->buf_ptr and cmd->buf_ptr_size and queues ISTATE_SEND_NOPIN.
If a pipelined empty Text PDU reuses that ITT on a Normal session,
iscsit_add_reject_from_cmd() overwrites cmd->buf_ptr with a 48-byte
kmemdup() without freeing the ping_data buffer or updating
cmd->buf_ptr_size:
RX thread TX thread
iscsit_handle_nop_out()
cmd->buf_ptr = ping_data
cmd->buf_ptr_size = 4096
queue ISTATE_SEND_NOPIN
iscsit_process_text_cmd()
iscsit_add_reject_from_cmd()
cmd->buf_ptr = kmemdup(..., 48)
iscsit_send_nopin()
iscsit_xmit_pdu(..., cmd->buf_ptr,
cmd->buf_ptr_size)
<-- slab out-of-bounds read
The old ping_data buffer is leaked, and when cmd->buf_ptr_size exceeds
48 bytes, iscsit_send_nopin() reads past the reject header and sends
adjacent kernel heap memory over the network.
In addition, iscsit_add_reject_from_cmd() updates cmd->i_state without
cmd->istate_lock, racing with iscsit_response_queue().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204184309.70952-1-bugs@stellman-greene.com?part=2
prev parent reply other threads:[~2026-12-04 19:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 18:43 [PATCH v3 0/2] scsi: target: iscsi: SendTargets reject fixes Andrew Stellman
2026-12-04 18:43 ` [PATCH v3 1/2] scsi: target: iscsi: Fix leak of a Text command rejected for invalid SendTargets Andrew Stellman
2026-12-04 18:43 ` [PATCH v3 2/2] scsi: target: iscsi: Reject SendTargets=All on Normal sessions Andrew Stellman
2026-12-04 19:20 ` 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-250522@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bugs@stellman-greene.com \
--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 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.