Linux SCSI subsystem development
 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 scsi-fixes] scsi: target: iscsi: Fix the Discovery session opcode check
Date: Sat, 28 Nov 2026 19:26:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-238994@kernel.org> (raw)
In-Reply-To: <20261128191735.30260-1-bugs@stellman-greene.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] scsi: target: iscsi: bogus Reject on HeaderDigest error in
  iscsit_get_rx_pdu()
--

commit 1fd1145d67663e7038dd80d77ad570d438916435
Author: Andrew Stellman <astellman@stellman-greene.com>

scsi: target: iscsi: Fix the Discovery session opcode check

This commit replaces the bitwise opcode checks for Discovery sessions in
iscsit_get_rx_pdu() and cxgbit_rx_opcode() with equality checks against
ISCSI_OP_TEXT and ISCSI_OP_LOGOUT.

> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 2b4956f46c132..3f56c5495821e 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
> @@ -4088,8 +4088,7 @@ static void iscsit_get_rx_pdu(struct iscsit_conn *conn)
>  		opcode = buffer[0] & ISCSI_OPCODE_MASK;
>  
>  		if (conn->sess->sess_ops->SessionType &&
> -		   ((!(opcode & ISCSI_OP_TEXT)) ||
> -		    (!(opcode & ISCSI_OP_LOGOUT)))) {
> +		    opcode != ISCSI_OP_TEXT && opcode != ISCSI_OP_LOGOUT) {
>  			pr_err("Received illegal iSCSI Opcode: 0x%02x"
>  			" while in Discovery Session, rejecting.\n", opcode);
>  			iscsit_add_reject(conn, ISCSI_REASON_PROTOCOL_ERROR,

[Severity: Medium]
On a HeaderDigest CRC32C failure in a Discovery session, does this cause
iscsit_get_rx_pdu() to queue a Reject PDU containing the synthetic 0xff
buffer instead of dropping the connection in iscsi_target_rx_opcode()?

Just above this check, the HeaderDigest error path overwrites buffer:

drivers/target/iscsi/iscsi_target.c:iscsit_get_rx_pdu() {
    ...
			if (digest != checksum) {
				pr_err("HeaderDigest CRC32C failed,"
					" received 0x%08x, computed 0x%08x\n",
					digest, checksum);
				/*
				 * Set the PDU to 0xff so it will intentionally
				 * hit default in the switch below.
				 */
				memset(buffer, 0xff, ISCSI_HDR_LEN);
				atomic_long_inc(&conn->sess->conn_digest_errors);
    ...
}

Previously, the resulting opcode 0x3f passed the bitwise check (since bit
0x04 was set) and reached the default case in iscsi_target_rx_opcode().
With the equality check, a digest failure in a Discovery session hits this
branch, logs a bogus illegal opcode 0x3f error, and passes the all-0xff
buffer to iscsit_add_reject().

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

      reply	other threads:[~2026-11-28 19:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 19:17 [PATCH scsi-fixes] scsi: target: iscsi: Fix the Discovery session opcode check Andrew Stellman
2026-11-28 19:26 ` 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-238994@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