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 v2 scsi-fixes] scsi: target: iscsi: Fix UAF on an immediate data digest error
Date: Sun, 29 Nov 2026 00:36:43 +0000 [thread overview]
Message-ID: <sashiko-outbox-239199@kernel.org> (raw)
In-Reply-To: <20261129001755.78909-1-bugs@stellman-greene.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] scsi: target: iscsi: UAF via zeroed tags in iscsit_add_reject()
--
commit 6dd082a26a7d6aa60cc88c1fd9d419ea3195000a
Author: Andrew Stellman <astellman@stellman-greene.com>
scsi: target: iscsi: Fix UAF on an immediate data digest error
This commit sends the DataDigest error Reject at ErrorRecoveryLevel >= 1
via iscsit_add_reject() using a separate command and frees the failed
WRITE command directly instead of queueing it as ISTATE_REMOVE.
> diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c
> index 3698f2eb097e3..0b0a3cc3361f3 100644
> --- a/drivers/target/iscsi/cxgbit/cxgbit_target.c
> +++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c
> @@ -871,7 +871,7 @@ cxgbit_handle_immediate_data(struct iscsit_cmd *cmd, struct iscsi_scsi_req *hdr,
> return IMMEDIATE_DATA_CANNOT_RECOVER;
> }
>
> - iscsit_reject_cmd(cmd, ISCSI_REASON_DATA_DIGEST_ERROR,
> + iscsit_add_reject(conn, ISCSI_REASON_DATA_DIGEST_ERROR,
> (unsigned char *)hdr);
> return IMMEDIATE_DATA_ERL1_CRC_FAILURE;
> }
[ ... ]
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 2b4956f46c132..c4d114ffa5c41 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
[ ... ]
> @@ -2654,9 +2657,9 @@ static int iscsit_handle_immediate_data(
> (unsigned char *)hdr);
> return IMMEDIATE_DATA_CANNOT_RECOVER;
> } else {
> - iscsit_reject_cmd(cmd,
> - ISCSI_REASON_DATA_DIGEST_ERROR,
> - (unsigned char *)hdr);
> + iscsit_add_reject(conn,
> + ISCSI_REASON_DATA_DIGEST_ERROR,
> + (unsigned char *)hdr);
> return IMMEDIATE_DATA_ERL1_CRC_FAILURE;
> }
> } else {
[Severity: High]
Can calling iscsit_add_reject() when the connection stays up allow a
subsequent PDU to match the Reject command on conn->conn_cmd_list by its
zeroed tags and cause a use-after-free or double free?
Existing callers of iscsit_add_reject() sit on fatal paths that close the
connection right away. Unlike iscsit_add_nopin(), iscsit_add_reject()
leaves cmd->init_task_tag and cmd->targ_xfer_tag at 0 when adding the new
command to conn->conn_cmd_list:
drivers/target/iscsi/iscsi_target.c:iscsit_add_reject() {
cmd = iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE);
if (!cmd)
return -1;
cmd->iscsi_opcode = ISCSI_OP_REJECT;
cmd->reject_reason = reason;
...
spin_lock_bh(&conn->cmd_lock);
list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list);
spin_unlock_bh(&conn->cmd_lock);
Because the connection remains active at ErrorRecoveryLevel >= 1 and the
Reject command stays on conn->conn_cmd_list until its StatSN is
acknowledged via ExpStatSN, a NOP-Out with ITT 0xffffffff and TTT 0 in
iscsit_process_nop_out() matches the Reject command via
iscsit_find_cmd_from_ttt(conn, 0) and queues it on the immediate queue as
ISTATE_REMOVE. The TX thread then frees the Reject command from the
immediate queue before iscsit_response_queue() transmits cmd->buf_ptr, or
both iscsit_immediate_queue() and iscsit_ack_from_expstatsn() free it.
Any PDU looking up ITT 0 (such as a Text, Data-Out, SNACK, or ABORT_TASK
PDU) will also match the Reject command via iscsit_find_cmd_from_itt().
Initializing cmd->init_task_tag = RESERVED_ITT and
cmd->targ_xfer_tag = 0xFFFFFFFF in iscsit_add_reject(), as
iscsit_add_nopin() does, would prevent ITT and TTT lookups from matching
Reject commands.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129001755.78909-1-bugs@stellman-greene.com?part=1
next prev parent reply other threads:[~2026-11-29 0:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 19:17 [PATCH scsi-fixes] scsi: target: iscsi: Fix UAF on an immediate data digest error Andrew Stellman
2026-11-28 19:38 ` sashiko-bot
2026-11-29 0:17 ` [PATCH v2 " Andrew Stellman
2026-11-29 0:36 ` sashiko-bot [this message]
2026-11-29 15:52 ` [PATCH v3 scsi-fixes 1/2] scsi: target: iscsi: Reserve tags on standalone Rejects Andrew Stellman
2026-11-29 15:52 ` [PATCH v3 scsi-fixes 2/2] scsi: target: iscsi: Fix UAF on an immediate data digest error Andrew Stellman
2026-11-29 16:12 ` sashiko-bot
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-239199@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox