From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796412005; b=t8pTFnzJKlYAkBra3w/IUUWhoA38T729Htp7QQ9wTCPjhIlKSGdQ66zrhx1T+7AiK4cO v+TK6hl6KgCDGcphYhF2UyVo74XcIp79Ji3wzb5PtFI/dxy264tA8uXS6nTrWX5xw0Sq2 /P93dYstSTGy0iJz5ArGD97jgjGI5V/P7kR8ugdG1i0XB9bpIu8RD75WGS6V+X2uzFyb6 alRpNeDgy56h47JVtz/4wxxSHD5IYGWTCJ4I6yNkODfosMlFCUB4TkgLIaqLC+Zjv2oOA HBNJZg2MnbDbmm0aRBb+UDwCf6Hk7VmcbZn6/fp5D/lRazzbOQ7OgDOPYro9dxzwEYQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796412005; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=wBFTC6NXyafhCHEV1NQVMT1peeCWhiTK2aEN7cJYZGI=; b=zg8SDDtaJJGYvIZ+J7fJOemBzGdElLayCOVTC/eaMwex1IxcJFtbcl3eEOwQFscEX53k VmP8D94FK0bYevfUWUEma7gTmS87uAnPZuNjQ11llxylBJ36sUQbdIi+qCwFQpajSWnqF 6XNefkOuBR07Cra2Nk6xczKtTfSmn3K2zLzHpX+J9zWdHqt8p4HtSaHk3CCx+p5I+koaN BPj4ZTkiWxpO32ihUQACIzh33Fx4oHDpSVkN9Ad69vI/CZu+rENeJpfLaDf3JGYTxYFUR H83ET/ebWieVjiph76S4uhKoQVQnKU2PVusWjdq+DqUmG5JXFcQJ1gEHV5HqEFy0npg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=R2OgEiWR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 614D7606A322; Fri, 4 Dec 2026 19:20:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=R2OgEiWR Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3C311F00936; Fri, 4 Dec 2026 19:20:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796412005; bh=wBFTC6NXyafhCHEV1NQVMT1peeCWhiTK2aEN7cJYZGI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=R2OgEiWRU4zwKz8z9KAHh7hbLy/SadfGaf8ksejwOBlhzBN/3onJF8JN55Ye9COm2 y2yy8Tf6vh+QAIbKc0608lylzMFHY1JXZn9MhOjOwM5mp0Lzw3UM2ft98xnzr8T4uG ZaYdVnQAjcKk0iGhKGaBH3HpCFbyr4kjrDgcJM14DaMn7xpSbODFkgiPR07dh2HZmN HYAFOqOJbjgeQ0dJ+hHT/Rn/4bOGIXsZriQjmeLOiytfn4NX0gf8BV7D7GpxwU+DQu Qxaae4Vza9RJ0p8XnuiPYeuoX8O03vaFGqjDBrIs9s1pxFa+KgB2xoeOtSGfR5Qo9y 97GwsAiuaQ1+w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 2/2] scsi: target: iscsi: Reject SendTargets=All on Normal sessions Reply-To: sashiko-reviews@lists.linux.dev To: "Andrew Stellman" Cc: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org In-Reply-To: <20261204184309.70952-3-bugs@stellman-greene.com> References: <20261204184309.70952-1-bugs@stellman-greene.com> <20261204184309.70952-3-bugs@stellman-greene.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 19:20:04 +0000 X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Critical] scsi: target: iscsi: UAF when rejecting Text PDU reusing SCSI or TMR ITT - [Critical] scsi: target: iscsi: buf_ptr leak and TX OOB read on reused NOP-Out ITT -- commit b14aaa98ccafd0087fcc5c1540989f44bd35234f Author: Andrew Stellman scsi: target: iscsi: Reject SendTargets=3DAll on Normal sessions This commit rejects SendTargets=3DAll and empty Text requests without ICF_SENDTARGETS_SINGLE in iscsit_process_text_cmd() when running on a Normal session. > diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/i= scsi_target.c > index 7bf4a3b0998fb..133fc4f0d9bbb 100644 > --- a/drivers/target/iscsi/iscsi_target.c > +++ b/drivers/target/iscsi/iscsi_target.c > @@ -2186,6 +2186,9 @@ iscsit_process_text_cmd(struct iscsit_conn *conn, s= truct iscsit_cmd *cmd, > " discovery\n"); > goto reject; > } > + if (!conn->sess->sess_ops->SessionType && > + !(cmd->cmd_flags & ICF_SENDTARGETS_SINGLE)) > + goto reject; > goto empty_sendtargets; > } > if (strncmp("SendTargets=3D", text_in, 12) !=3D 0) { [Severity: Critical] Can this reject path cause a use-after-free on cmd and cmd->buf_ptr when an empty Text PDU reuses the ITT of a SCSI command? For hdr->ttt !=3D 0xffffffff, iscsi_target_rx_opcode() (and the iSER and cxgbit RX paths) looks up cmd with iscsit_find_cmd_from_itt() without checking cmd->iscsi_opcode or cmd->targ_xfer_tag. Routing that command to reject calls iscsit_reject_cmd() -> iscsit_add_reject_from_cmd(). Because cmd->se_cmd.se_tfo is non-NULL, iscsit_add_reject_from_cmd() queues cmd on conn->response_queue_list and calls target_put_sess_cmd(&cmd->se_cmd). For a completed SCSI command awaiting ExpStatSN (cmd_kref =3D=3D 1 after lio_check_stop_free()), that drops cmd_kref to 0 and runs iscsit_release_cmd() while cmd is still queued for TX and linked on conn->conn_cmd_list. Freeing cmd->buf_ptr and returning cmd to the session tag pool causes a use-after-free in iscsit_send_reject(), followed by a refcount underflow and double free in iscsit_release_commands_from_conn(). Earlier, iscsit_setup_text_cmd() also overwrites cmd->data_direction with DMA_NONE, causing SCSI WRITE teardown to skip stopping cmd->dataout_timer and freeing cmd_r2t_list. Rejecting non-0xffffffff TTT Text PDUs with iscsit_add_reject() before iscsit_setup_text_cmd() when the looked-up command is not an ISCSI_OP_TEXT with matching targ_xfer_tag would avoid mutating foreign commands. [Severity: Critical] Does rejecting an empty Text PDU that reuses a NOP-Out ITT leak cmd->buf_ptr and allow an out-of-bounds read in iscsit_send_nopin()? When a NOP-Out carries ping data, iscsit_handle_nop_out() stores it in cmd->buf_ptr and cmd->buf_ptr_size and queues ISTATE_SEND_NOPIN. If a pipelined empty Text PDU reuses that ITT on a Normal session, iscsit_add_reject_from_cmd() overwrites cmd->buf_ptr with a 48-byte kmemdup() without freeing the ping_data buffer or updating cmd->buf_ptr_size: RX thread TX thread iscsit_handle_nop_out() cmd->buf_ptr =3D ping_data cmd->buf_ptr_size =3D 4096 queue ISTATE_SEND_NOPIN iscsit_process_text_cmd() iscsit_add_reject_from_cmd() cmd->buf_ptr =3D kmemdup(..., 48) iscsit_send_nopin() iscsit_xmit_pdu(..., cmd->buf_ptr, cmd->buf_ptr_size) <-- slab out-of-bounds read The old ping_data buffer is leaked, and when cmd->buf_ptr_size exceeds 48 bytes, iscsit_send_nopin() reads past the reject header and sends adjacent kernel heap memory over the network. In addition, iscsit_add_reject_from_cmd() updates cmd->i_state without cmd->istate_lock, racing with iscsit_response_queue(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204184309.7095= 2-1-bugs@stellman-greene.com?part=3D2