* [PATCH v2 1/2] scsi: target: iscsi: Fix leak of a Text command rejected for invalid SendTargets
2026-12-04 5:47 [PATCH v2 0/2] scsi: target: iscsi: SendTargets reject fixes Andrew Stellman
@ 2026-12-04 5:47 ` Andrew Stellman
2026-12-04 5:47 ` [PATCH v2 2/2] scsi: target: iscsi: Reject SendTargets=All on Normal sessions Andrew Stellman
1 sibling, 0 replies; 4+ messages in thread
From: Andrew Stellman @ 2026-12-04 5:47 UTC (permalink / raw)
To: Martin K. Petersen
Cc: Mike Christie, Dmitry Bogdanov, target-devel, linux-scsi
From: Andrew Stellman <astellman@stellman-greene.com>
iscsit_process_text_cmd() rejects an invalid SendTargets value with
iscsit_reject_cmd(), which doesn't add the new Text command to the
connection's command list, so the command and its Reject header leak:
ten immediate SendTargets=Bogus requests left 20 unreferenced objects
in kmemleak.
Use iscsit_add_reject_cmd() for a new command (TTT 0xffffffff), so it's
listed and freed.
The leak was found by the Sashiko review of v1:
https://sashiko.dev/#/patchset/20261130063456.58615-1-bugs@stellman-greene.com?part=1
The fix and this changelog were drafted with OpenAI GPT-6 (Codex),
Claude Opus 5.5 and Claude Sonnet 5.5 and reviewed by me.
Fixes: 9864ca9d27f7 ("iscsi-target: Move sendtargets parsing into iscsit_process_text_cmd")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
v1: https://lore.kernel.org/r/20261130063456.58615-1-bugs@stellman-greene.com/
Tested on v7.4-rc5 (fe6ff8d5d675) in arm64 QEMU with KASAN and
kmemleak: after ten immediate SendTargets=Bogus requests, the second
scan found 20 objects without this patch and none with it.
A reproducer is available on request.
drivers/target/iscsi/iscsi_target.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 2b4956f46c13..7bf4a3b0998f 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -2226,6 +2226,9 @@ iscsit_process_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
return iscsit_execute_cmd(cmd, 0);
reject:
+ if (hdr->ttt == cpu_to_be32(0xffffffff))
+ return iscsit_add_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR,
+ (unsigned char *)hdr);
return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR,
(unsigned char *)hdr);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/2] scsi: target: iscsi: Reject SendTargets=All on Normal sessions
2026-12-04 5:47 [PATCH v2 0/2] scsi: target: iscsi: SendTargets reject fixes Andrew Stellman
2026-12-04 5:47 ` [PATCH v2 1/2] scsi: target: iscsi: Fix leak of a Text command rejected for invalid SendTargets Andrew Stellman
@ 2026-12-04 5:47 ` Andrew Stellman
2026-12-04 6:07 ` sashiko-bot
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Stellman @ 2026-12-04 5:47 UTC (permalink / raw)
To: Martin K. Petersen
Cc: Mike Christie, Dmitry Bogdanov, target-devel, linux-scsi
From: Andrew Stellman <astellman@stellman-greene.com>
RFC 7143 Appendix C disallows SendTargets=All on an operational
session, but iscsit_process_text_cmd() accepts it on a Normal session
and can return the target names that session's ACL can see.
Reject SendTargets=All on Normal sessions. In testing, the connection
now closed and no Reject or target names arrived.
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), this changelog with
OpenAI GPT-6 (Codex), Claude Opus 5.5 and Claude Sonnet 5.5, and both
were reviewed by me.
Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
v1: https://lore.kernel.org/r/20261130063456.58615-1-bugs@stellman-greene.com/
Tested on v7.4-rc5 (fe6ff8d5d675) in arm64 QEMU with KASAN and
generate_node_acls=1: ten Normal-session SendTargets=All requests
returned both target names before this series and ended at EOF with no
names after it.
A reproducer is available on request.
drivers/target/iscsi/iscsi_target.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 7bf4a3b0998f..eaaf0a4177b0 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -2197,6 +2197,8 @@ iscsit_process_text_cmd(struct iscsit_conn *conn, struct iscsit_cmd *cmd,
text_ptr = strchr(text_in, '=');
BUG_ON(!text_ptr);
if (!strncmp("=All", text_ptr, 5)) {
+ if (!conn->sess->sess_ops->SessionType)
+ goto reject;
cmd->cmd_flags |= ICF_SENDTARGETS_ALL;
} else if (!strncmp("=iqn.", text_ptr, 5) ||
!strncmp("=eui.", text_ptr, 5)) {
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread