* [PATCH] scsi: target: iscsi: Reject SendTargets=All on Normal sessions
@ 2026-11-30 6:34 Andrew Stellman
2026-11-30 6:48 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Stellman @ 2026-11-30 6:34 UTC (permalink / raw)
To: Martin K. Petersen; +Cc: Mike Christie, target-devel, linux-scsi
From: Andrew Stellman <astellman@stellman-greene.com>
RFC 7143 Appendix C says the SendTargets value All "MUST NOT be
supported on an operational session", but iscsit_process_text_cmd()
accepts it on Normal sessions. With two targets configured with
generate_node_acls=1 and authentication=0, a Normal session to one
target got both target names for SendTargets=All.
Send All on a Normal session to the existing Protocol Error Reject, as
for other invalid SendTargets values. This changes existing behaviour:
a Normal session that sends SendTargets=All no longer gets a target
list. From reading the code, the reject path also ends the connection.
Named-target requests on Normal sessions are unchanged and are not
covered by this patch. In the same setup, a Normal session asking for
the other target still got that target's name and address, in single
runs on head and with the patch.
Tested over TCP in an arm64 KASAN QEMU guest. In an earlier boot, one
Normal-session request on head got both target names for
SendTargets=All. With the patch, ten Normal-session SendTargets=All
requests returned no target name: five got the Reject (reason 0x04)
and five ended with EOF and no response. On head, ten Normal-session
SendTargets=Bogus requests, which go to the same reject label in the
code, got three Rejects and seven EOFs. In earlier boots, single runs
of Discovery All and of a request for the session's own target
returned the same responses on head and with the patch.
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 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>
---
Only the TCP path was run; cxgbit calls the same function and was not
tested.
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 03d618cd76721..2dd6aa6ed7ee4 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] 2+ messages in thread* Re: [PATCH] scsi: target: iscsi: Reject SendTargets=All on Normal sessions
2026-11-30 6:34 [PATCH] scsi: target: iscsi: Reject SendTargets=All on Normal sessions Andrew Stellman
@ 2026-11-30 6:48 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-30 6:48 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:
- [High] scsi: target: iscsi: memory and tag leak in
iscsit_process_text_cmd()
--
commit a6aa92f926647a8f3a5142bf12aecdd7f9d82ae7
Author: Andrew Stellman <astellman@stellman-greene.com>
scsi: target: iscsi: Reject SendTargets=All on Normal sessions
This commit rejects SendTargets=All text requests received on Normal
(operational) iSCSI sessions with a Protocol Error Reject.
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 2b4956f46c132..c177ccfe53c64 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: High]
Does jumping to reject here leak cmd, cmd->text_in_ptr, cmd->buf_ptr, and
the session command tag?
In iscsit_process_text_cmd(), cmd is only linked onto conn->conn_cmd_list
after the SendTargets checks succeed, and the reject label calls
iscsit_reject_cmd(), which passes add_to_conn = false to
iscsit_add_reject_from_cmd():
drivers/target/iscsi/iscsi_target.c:iscsit_process_text_cmd() {
...
spin_lock_bh(&conn->cmd_lock);
list_add_tail(&cmd->i_conn_node, &conn->conn_cmd_list);
spin_unlock_bh(&conn->cmd_lock);
...
reject:
return iscsit_reject_cmd(cmd, ISCSI_REASON_PROTOCOL_ERROR,
(unsigned char *)hdr);
}
Because cmd is never added to conn->conn_cmd_list, neither
iscsit_ack_from_expstatsn() nor iscsit_release_commands_from_conn() will
free it on iSCSI/TCP or cxgbit connections. Each rejected SendTargets=All
request on a Normal session leaks cmd->text_in_ptr, the cmd->buf_ptr
allocated in iscsit_add_reject_from_cmd(), and a tag from
sess->se_sess->sess_tag_pool until the session runs out of tags.
Calling iscsit_add_reject_cmd() (which passes add_to_conn = true) instead
of iscsit_reject_cmd() at the reject label would ensure cmd is tracked on
conn->conn_cmd_list and released during command acknowledgement or
connection teardown.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130063456.58615-1-bugs@stellman-greene.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-30 6:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 6:34 [PATCH] scsi: target: iscsi: Reject SendTargets=All on Normal sessions Andrew Stellman
2026-11-30 6:48 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox