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 scsi-fixes 2/3] scsi: target: iscsi: Check Data and R2T SNACK ranges without wrap
Date: Fri, 04 Dec 2026 06:06:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-249183@kernel.org> (raw)
In-Reply-To: <20261204054748.45560-3-bugs@stellman-greene.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Critical] scsi: target: iscsi: uninitialized ITT 0 collision in
iscsit_add_reject_common()
- [Medium] scsi: target: iscsi: ignored -ENOMEM leaks Reject cmd in
iscsit_add_reject_common()
--
commit f16fa2dff107b9597ae68bb5108303bdbef252b0
Author: Andrew Stellman <astellman@stellman-greene.com>
scsi: target: iscsi: Check Data and R2T SNACK ranges without wrap
This commit widens the BegRun + RunLength range checks in
iscsit_handle_r2t_snack() and iscsit_handle_recovery_datain() to u64 so that
wrapping sums are rejected as Bookmark Invalid instead of bypassing the check.
> diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c
> index 312e0502b9f0e..3562e9ad5e4c8 100644
> --- a/drivers/target/iscsi/iscsi_target_erl1.c
> +++ b/drivers/target/iscsi/iscsi_target_erl1.c
> @@ -134,7 +134,7 @@ static int iscsit_handle_r2t_snack(
> }
>
> if (runlength) {
> - if ((begrun + runlength) > cmd->r2t_sn) {
> + if ((u64)begrun + runlength > cmd->r2t_sn) {
> pr_err("Command ITT: 0x%08x received R2T SNACK"
> " with BegRun: 0x%08x, RunLength: 0x%08x, exceeds"
> " current R2TSN: 0x%08x, protocol error.\n",
[Severity: Critical]
Can this Reject path (and the matching check in
iscsit_handle_recovery_datain()) leave an uninitialized init_task_tag of 0 on
conn->conn_cmd_list and corrupt the list when a later PDU uses ITT 0?
Both range checks call iscsit_add_reject_keep_conn() ->
iscsit_add_reject_common(..., true) from commit "scsi: target: iscsi: Don't
drop live command refs on SNACK Reject". iscsit_allocate_cmd() zeroes cmd,
and iscsit_add_reject_common() never sets cmd->init_task_tag = RESERVED_ITT.
Until the initiator advances ExpStatSN past the Reject's StatSN,
iscsit_find_cmd_from_itt() matches the Reject cmd for any PDU with ITT 0. An
ISCSI_OP_TEXT PDU with ITT 0 and TTT != 0xffffffff then double-adds
cmd->i_conn_node in iscsit_process_text_cmd(), corrupting conn->conn_cmd_list.
The same path also overwrites cmd->buf_ptr in
iscsit_build_sendtargets_response() without freeing the Reject header, racing
with iscsit_send_reject(). Setting cmd->init_task_tag = RESERVED_ITT in
iscsit_add_reject_common() avoids ITT 0 collisions.
[Severity: Medium]
Does iscsit_add_reject_common() leak the Reject iscsit_cmd, its sess_tag_pool
tag, and cmd->buf_ptr when iscsit_add_cmd_to_response_queue() returns -ENOMEM?
iscsit_add_reject_common() ignores the return value of
iscsit_add_cmd_to_response_queue(), which allocates a struct iscsi_queue_req
with GFP_ATOMIC and can fail with -ENOMEM. When keep_conn is true, it still
returns 0 and leaves cmd linked on conn->conn_cmd_list in ISTATE_SEND_REJECT.
Because cmd is never queued to the TX thread, it never reaches
ISTATE_SENT_STATUS, so iscsit_ack_from_expstatsn() cannot reclaim it until
the connection closes. Unlinking cmd, calling iscsit_free_cmd(cmd, false),
and returning -1 on error avoids stranding it.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204054748.45560-1-bugs@stellman-greene.com?part=2
next prev parent reply other threads:[~2026-12-04 6:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 5:47 [PATCH v3 scsi-fixes 0/3] scsi: target: iscsi: SNACK Reject and range fixes Andrew Stellman
2026-12-04 5:47 ` [PATCH v3 scsi-fixes 1/3] scsi: target: iscsi: Don't drop live command refs on SNACK Reject Andrew Stellman
2026-12-04 6:10 ` sashiko-bot
2026-12-04 5:47 ` [PATCH v3 scsi-fixes 2/3] scsi: target: iscsi: Check Data and R2T SNACK ranges without wrap Andrew Stellman
2026-12-04 6:06 ` sashiko-bot [this message]
2026-12-04 5:47 ` [PATCH v3 scsi-fixes 3/3] scsi: target: iscsi: Bound Status SNACKs to unacknowledged StatSNs Andrew Stellman
2026-12-04 6:06 ` 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-249183@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