SCSI target development
 help / color / mirror / Atom feed
* [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

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