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/3] scsi: target: iscsi: Don't drop live command refs on SNACK Reject
Date: Fri, 04 Dec 2026 19:12:32 +0000	[thread overview]
Message-ID: <sashiko-outbox-250507@kernel.org> (raw)
In-Reply-To: <20261204184320.71059-2-bugs@stellman-greene.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] iscsi-target: iscsit_add_reject() on SNACK errors can deadlock
  iscsi_trx
--

commit 54bafde1d196e0744177a40988397d61290fe45a
Author: Andrew Stellman <astellman@stellman-greene.com>

scsi: target: iscsi: Don't drop live command refs on SNACK Reject

This commit switches the error paths in iscsit_handle_r2t_snack() and
iscsit_handle_recovery_datain() from iscsit_reject_cmd() to
iscsit_add_reject(), so Reject PDUs are queued on a newly allocated command
instead of reusing the live SCSI command.

> diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c
> index 44b851e4a602d..20eef05400e69 100644
> --- a/drivers/target/iscsi/iscsi_target_erl1.c
> +++ b/drivers/target/iscsi/iscsi_target_erl1.c
> @@ -129,7 +129,8 @@ static int iscsit_handle_r2t_snack(
>  			" protocol error.\n", cmd->init_task_tag, begrun,
>  			(begrun + runlength), cmd->acked_data_sn);
>  
> -		return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf);
> +		return iscsit_add_reject(cmd->conn,
> +				ISCSI_REASON_PROTOCOL_ERROR, buf);
>  	}
>  
>  	if (runlength) {
> @@ -138,7 +139,7 @@ static int iscsit_handle_r2t_snack(
>  			" with BegRun: 0x%08x, RunLength: 0x%08x, exceeds"
>  			" current R2TSN: 0x%08x, protocol error.\n",
>  			cmd->init_task_tag, begrun, runlength, cmd->r2t_sn);
> -			return iscsit_reject_cmd(cmd,
> +			return iscsit_add_reject(cmd->conn,
>  					ISCSI_REASON_BOOKMARK_INVALID, buf);
>  		}
>  		last_r2tsn = (begrun + runlength);
> @@ -398,7 +399,8 @@ static int iscsit_handle_recovery_datain(
>  			" protocol error.\n", cmd->init_task_tag, begrun,
>  			(begrun + runlength), cmd->acked_data_sn);
>  
> -		return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR, buf);
> +		return iscsit_add_reject(conn,
> +				ISCSI_REASON_PROTOCOL_ERROR, buf);
>  	}
>  
>  	/*
> @@ -409,14 +411,14 @@ static int iscsit_handle_recovery_datain(
>  		pr_err("Initiator requesting BegRun: 0x%08x, RunLength"
>  			": 0x%08x greater than maximum DataSN: 0x%08x.\n",
>  				begrun, runlength, (cmd->data_sn - 1));
> -		return iscsit_reject_cmd(cmd, ISCSI_REASON_BOOKMARK_INVALID,
> -					 buf);
> +		return iscsit_add_reject(conn,
> +				ISCSI_REASON_BOOKMARK_INVALID, buf);
>  	}
>  
>  	dr = iscsit_allocate_datain_req();
>  	if (!dr)
> -		return iscsit_reject_cmd(cmd, ISCSI_REASON_BOOKMARK_NO_RESOURCES,
> -					 buf);
> +		return iscsit_add_reject(conn,
> +				ISCSI_REASON_BOOKMARK_NO_RESOURCES, buf);
>  
>  	dr->data_sn = dr->begrun = begrun;
>  	dr->runlength = runlength;

[Severity: High]
Can calling iscsit_add_reject() on these SNACK error paths deadlock the
iscsi_trx thread?

Previously, iscsit_reject_cmd() reused cmd without allocating a session tag.
iscsit_add_reject() calls iscsit_allocate_cmd(conn, TASK_INTERRUPTIBLE),
which sleeps in iscsit_wait_for_tag() when se_sess->sess_tag_pool is empty.

With ErrorRecoveryLevel >= 1, a remote initiator can keep ExpStatSN fixed
and fill se_sess->sess_tag_pool with ISTATE_SENT_STATUS commands (one
completed SCSI read plus immediate NOP-OUTs with non-reserved ITTs, which
bypass CmdSN checks).

If the initiator then sends an out-of-range Data or R2T SNACK for that
read's ITT, iscsi_target_rx_opcode() dispatches ISCSI_OP_SNACK without
calling iscsit_ack_from_expstatsn().  iscsi_trx then blocks in
iscsit_wait_for_tag() waiting for a tag that only iscsi_trx can free.

When conn->nopin_timer fires, iscsit_add_nopin() fails on the empty tag pool
without starting nopin_response_timer or re-arming nopin_timer.  The
connection and session stay wedged indefinitely, holding the socket and all
session tags until an administrator forces teardown.

Using TASK_RUNNING in iscsit_add_reject() (which already returns -1 to tear
down the connection when allocation fails) would avoid blocking iscsi_trx.

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

  reply	other threads:[~2026-12-04 19:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 18:43 [PATCH v4 scsi-fixes 0/3] scsi: target: iscsi: SNACK Reject and range fixes Andrew Stellman
2026-12-04 18:43 ` [PATCH v4 scsi-fixes 1/3] scsi: target: iscsi: Don't drop live command refs on SNACK Reject Andrew Stellman
2026-12-04 19:12   ` sashiko-bot [this message]
2026-12-04 18:43 ` [PATCH v4 scsi-fixes 2/3] scsi: target: iscsi: Check Data and R2T SNACK ranges without wrap Andrew Stellman
2026-12-04 18:43 ` [PATCH v4 scsi-fixes 3/3] scsi: target: iscsi: Bound Status SNACKs to unacknowledged StatSNs Andrew Stellman
2026-12-04 19:56   ` 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-250507@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.