* [PATCH] scsi: target: iscsi: Free dropped Text commands on DataDigest errors
@ 2026-11-29 13:53 Andrew Stellman
2026-11-29 14:08 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Stellman @ 2026-11-29 13:53 UTC (permalink / raw)
To: Martin K. Petersen; +Cc: Mike Christie, target-devel, linux-scsi
From: Andrew Stellman <astellman@stellman-greene.com>
At ErrorRecoveryLevel 1 and above, iscsit_handle_text_cmd() and
cxgbit_handle_text_cmd() silently drop a Text Request whose DataDigest
doesn't match. When the request starts a new exchange (TTT 0xffffffff),
the receive path has already allocated a command and a session tag for
it, but the drop path returns without linking the command to the
connection or freeing it, so each such request leaks the command and
its tag.
Free the command on both drop paths when TTT is 0xffffffff, as the
NOP-Out DataDigest error path already does. A Text Request that
continues an existing exchange uses a command that is already on the
connection list, so it's left alone. The PDU is still dropped silently.
Tested over TCP on mainline in an arm64 QEMU guest with KASAN, ERL 1
and DataDigest=CRC32C. Before the fix, after 140 Text Requests with a
bad DataDigest the target logged 136 digest errors and a following
NOP-Out got no NOP-In within 3 seconds; with the fix it got a NOP-In.
The cxgbit change was compiled but not run.
The issue was found by Claude Opus 5.5 running Quality Playbook, an
LLM-driven code review tool:
https://github.com/andrewstellman/quality-playbook
The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with
Claude Opus 5.5, and both were reviewed by me.
Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")
Fixes: 9730ffcb8957 ("cxgbit: add files for cxgbit.ko")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
A reproducer is available on request.
drivers/target/iscsi/cxgbit/cxgbit_target.c | 2 ++
drivers/target/iscsi/iscsi_target.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c
index 3698f2eb097e3..b9abc735284ee 100644
--- a/drivers/target/iscsi/cxgbit/cxgbit_target.c
+++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c
@@ -1179,6 +1179,8 @@ cxgbit_handle_text_cmd(struct cxgbit_sock *csk, struct iscsit_cmd *cmd)
pr_info("Dropping Text"
" Command CmdSN: 0x%08x due to"
" DataCRC error.\n", hdr->cmdsn);
+ if (hdr->ttt == cpu_to_be32(0xFFFFFFFF))
+ iscsit_free_cmd(cmd, false);
return 0;
}
}
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 2b4956f46c132..9810e3dfcc1ce 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -2300,6 +2300,8 @@ iscsit_handle_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
" DataCRC error.\n", hdr->cmdsn);
kfree(text_in);
cmd->text_in_ptr = NULL;
+ if (hdr->ttt == cpu_to_be32(0xFFFFFFFF))
+ iscsit_free_cmd(cmd, false);
return 0;
}
} else {
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] scsi: target: iscsi: Free dropped Text commands on DataDigest errors
2026-11-29 13:53 [PATCH] scsi: target: iscsi: Free dropped Text commands on DataDigest errors Andrew Stellman
@ 2026-11-29 14:08 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-29 14:08 UTC (permalink / raw)
To: Andrew Stellman; +Cc: target-devel, linux-scsi
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] scsi: target: iscsi: inaccurate Fixes trailer for
iscsit_handle_text_cmd()
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] scsi: target: iscsi: TCP stream desynchronization in
non-SCSI handlers [1]
--
commit 3e3312bd41bf89c36eb174a1346bc67aacc6f605
Author: Andrew Stellman <astellman@stellman-greene.com>
> scsi: target: iscsi: Free dropped Text commands on DataDigest errors
>
> At ErrorRecoveryLevel 1 and above, iscsit_handle_text_cmd() and
> cxgbit_handle_text_cmd() silently drop a Text Request whose DataDigest
> doesn't match. When the request starts a new exchange (TTT 0xffffffff),
> the receive path has already allocated a command and a session tag for
> it, but the drop path returns without linking the command to the
> connection or freeing it, so each such request leaks the command and
> its tag.
>
> Free the command on both drop paths when TTT is 0xffffffff, as the
> NOP-Out DataDigest error path already does. A Text Request that
> continues an existing exchange uses a command that is already on the
> connection list, so it's left alone. The PDU is still dropped silently.
>
> Tested over TCP on mainline in an arm64 QEMU guest with KASAN, ERL 1
> and DataDigest=CRC32C. Before the fix, after 140 Text Requests with a
> bad DataDigest the target logged 136 digest errors and a following
> NOP-Out got no NOP-In within 3 seconds; with the fix it got a NOP-In.
> The cxgbit change was compiled but not run.
>
> The issue was found by Claude Opus 5.5 running Quality Playbook, an
> LLM-driven code review tool:
> https://github.com/andrewstellman/quality-playbook
> The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with
> Claude Opus 5.5, and both were reviewed by me.
>
> Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")
> Fixes: 9730ffcb8957 ("cxgbit: add files for cxgbit.ko")
> Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
[Severity: Low]
In commit e48354ce078c ("iscsi-target: Add iSCSI fabric support for target
v4.1"), iscsit_handle_text_cmd() validated the DataDigest before calling
iscsit_allocate_cmd(), so the ERL >= 1 DataCRC drop path did not leak a
command. The leak in iscsit_handle_text_cmd() was introduced when commit
64534aa79496 ("iscsi-target: Refactor ISCSI_OP_TEXT RX handling") hoisted
iscsit_allocate_cmd() into iscsi_target_rx_opcode(). Should the first
Fixes: tag be:
Fixes: 64534aa79496 ("iscsi-target: Refactor ISCSI_OP_TEXT RX handling")
[ ... ]
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 2b4956f46c132..9810e3dfcc1ce 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
> @@ -2300,6 +2300,8 @@ iscsit_handle_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
> " DataCRC error.\n", hdr->cmdsn);
> kfree(text_in);
> cmd->text_in_ptr = NULL;
> + if (hdr->ttt == cpu_to_be32(0xFFFFFFFF))
> + iscsit_free_cmd(cmd, false);
> return 0;
> }
> } else {
[Severity: Critical]
This problem wasn't introduced by this patch, but can an early failure in
iscsit_setup_text_cmd() desynchronize the TCP stream [1]?
drivers/target/iscsi/iscsi_target.c:iscsit_handle_text_cmd() {
...
rc = iscsit_setup_text_cmd(conn, cmd, hdr);
if (rc < 0)
return 0;
rx_size = payload_length;
if (payload_length) {
...
}
When iscsit_setup_text_cmd() fails on a Text Request carrying a non-zero
payload_length (and similarly in iscsit_handle_nop_out() when
iscsit_setup_nop_out() fails), the handler returns 0 without reading
payload_length bytes from the socket. The RX thread then parses the
unread payload as the next iSCSI Basic Header Segment, allowing crafted
payload bytes to inject arbitrary PDUs or crash the target.
[1] https://sashiko.dev/#/bug/linux-bc9d46c7-9320-42b5-85cc-7b0a1cddfeb4
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261129135303.80812-1-bugs@stellman-greene.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-29 14:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-29 13:53 [PATCH] scsi: target: iscsi: Free dropped Text commands on DataDigest errors Andrew Stellman
2026-11-29 14:08 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox