* [PATCH v2 0/2] scsi: target: iscsi: SendTargets reject fixes
@ 2026-12-04 5:47 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 ` [PATCH v2 2/2] scsi: target: iscsi: Reject SendTargets=All on Normal sessions Andrew Stellman
0 siblings, 2 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>
Patch 1 fixes the leak that the Sashiko review of v1 found, without
changing when the connection closes. Patch 2 is v1's change, rejecting
SendTargets=All on Normal sessions, which now closes the connection.
Andrew Stellman (2):
scsi: target: iscsi: Fix leak of a Text command rejected for invalid
SendTargets
scsi: target: iscsi: Reject SendTargets=All on Normal sessions
---
v1: https://lore.kernel.org/r/20261130063456.58615-1-bugs@stellman-greene.com/
Applies to v7.4-rc5 and on top of the SNACK v2 series:
https://lore.kernel.org/r/20261202165734.51018-1-bugs@stellman-greene.com/
drivers/target/iscsi/iscsi_target.c | 5 +++++
1 file changed, 5 insertions(+)
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [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
* Re: [PATCH v2 2/2] scsi: target: iscsi: Reject SendTargets=All on Normal sessions
2026-12-04 5:47 ` [PATCH v2 2/2] scsi: target: iscsi: Reject SendTargets=All on Normal sessions Andrew Stellman
@ 2026-12-04 6:07 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-12-04 6:07 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:
- [Medium] scsi: target: iscsi: empty Text PDU bypasses Normal-session
SendTargets check
--
commit 716dd73bbcd2e3457f8206ab625d6269131c3acb
Author: Andrew Stellman <astellman@stellman-greene.com>
scsi: target: iscsi: Reject SendTargets=All on Normal sessions
This commit rejects SendTargets=All text requests in
iscsit_process_text_cmd() when the session is a Normal session
(SessionType == 0), rather than returning visible target names.
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 7bf4a3b0998fb..eaaf0a4177b04 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)) {
[Severity: Medium]
Can an empty Text PDU on a Normal session bypass this SessionType check and
still enumerate all visible targets?
On a Normal session, an initiator can send an immediate ISCSI_OP_NOOP_OUT
with ITT=X and TTT=0xffffffff (which stays on conn->conn_cmd_list with
cmd_flags == 0), followed by an empty ISCSI_OP_TEXT PDU (dlength=0,
ISCSI_FLAG_CMD_FINAL set) using the same ITT=X and any TTT != 0xffffffff.
iscsi_target_rx_opcode() looks up that command solely by ITT via
iscsit_find_cmd_from_itt() without checking that it is a Text command.
iscsit_setup_text_cmd() then sets cmd->text_in_ptr to NULL, so
iscsit_process_text_cmd() jumps to empty_sendtargets and skips this check.
Because iscsit_build_sendtargets_response() only filters g_tiqn_list when
ICF_SENDTARGETS_SINGLE is set and never checks ICF_SENDTARGETS_ALL or
SessionType, it returns every target visible to the Normal session's ACL.
Guarding the !text_in path on Normal sessions when ICF_SENDTARGETS_SINGLE
is not set would close this bypass.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204054735.45435-1-bugs@stellman-greene.com?part=2
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-04 6:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v2 2/2] scsi: target: iscsi: Reject SendTargets=All on Normal sessions Andrew Stellman
2026-12-04 6:07 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox