All of lore.kernel.org
 help / color / mirror / Atom feed
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 v4 scsi-fixes 1/2] scsi: target: iscsi: Reserve tags on standalone Rejects
Date: Wed, 02 Dec 2026 17:03:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-246280@kernel.org> (raw)
In-Reply-To: <20261202164950.49838-1-bugs@stellman-greene.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Critical] scsi: target: iscsi: iscsit_find_cmd_from_itt() matches
  Reject RESERVED_ITT
--

commit 0c7a31e09b4e80ec4c1b3312cdddc1bc8f4f0667
Author: Andrew Stellman <astellman@stellman-greene.com>

scsi: target: iscsi: Reserve tags on standalone Rejects

This commit sets init_task_tag to RESERVED_ITT and targ_xfer_tag to
0xFFFFFFFF on standalone Reject commands in iscsit_add_reject() so they do
not stay zeroed on conn_cmd_list.

> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 2b4956f46c132..359c66d1051ab 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
> @@ -797,6 +797,8 @@ int iscsit_add_reject(
>  
>  	cmd->iscsi_opcode = ISCSI_OP_REJECT;
>  	cmd->reject_reason = reason;
> +	cmd->init_task_tag = RESERVED_ITT;
> +	cmd->targ_xfer_tag = 0xFFFFFFFF;
>  
>  	cmd->buf_ptr = kmemdup(buf, ISCSI_HDR_LEN, GFP_KERNEL);
>  	if (!cmd->buf_ptr) {

[Severity: Critical]
Can an ISCSI_OP_TEXT PDU with hdr->ttt != 0xFFFFFFFF and hdr->itt ==
RESERVED_ITT match this Reject command via iscsit_find_cmd_from_itt() and
cause the same use-after-free on cmd->buf_ptr?

When hdr->ttt != 0xFFFFFFFF, the ISCSI_OP_TEXT handler looks up hdr->itt
without rejecting RESERVED_ITT or checking cmd->iscsi_opcode:

drivers/target/iscsi/iscsi_target.c:iscsi_target_rx_opcode() {
    ...
	case ISCSI_OP_TEXT:
		if (hdr->ttt != cpu_to_be32(0xFFFFFFFF)) {
			cmd = iscsit_find_cmd_from_itt(conn, hdr->itt);
			if (!cmd)
				goto reject;
    ...
}

If the initiator follows a non-fatal Reject (such as an oversized
Data-Out) with an empty non-immediate ISCSI_OP_TEXT PDU carrying hdr->ttt
== 0, hdr->itt == RESERVED_ITT, and hdr->cmdsn < ExpCmdSN,
iscsit_process_text_cmd() overwrites cmd->targ_xfer_tag on the matched
Reject command and passes it to iscsit_sequence_cmd().  Because CmdSN is
lower than ExpCmdSN, iscsit_sequence_cmd() queues the Reject command onto
conn->immed_queue_list with ISTATE_REMOVE, freeing cmd->buf_ptr on the TX
thread before iscsit_response_queue() sends the Reject PDU.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202164950.49838-1-bugs@stellman-greene.com?part=1

      parent reply	other threads:[~2026-12-02 17:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 16:49 [PATCH v4 scsi-fixes 1/2] scsi: target: iscsi: Reserve tags on standalone Rejects Andrew Stellman
2026-12-02 16:49 ` [PATCH v4 scsi-fixes 2/2] scsi: target: iscsi: Fix UAF on an immediate data digest error Andrew Stellman
2026-12-02 17:03 ` 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-246280@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.