Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andrew Stellman" <bugs@stellman-greene.com>
Cc: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: target: iscsi: Reject SendTargets=All on Normal sessions
Date: Mon, 30 Nov 2026 06:48:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-240527@kernel.org> (raw)
In-Reply-To: <20261130063456.58615-1-bugs@stellman-greene.com>

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

      reply	other threads:[~2026-11-30  6:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-240527@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bugs@stellman-greene.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox