From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E410744237F; Mon, 17 Aug 2026 14:12:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786975981; cv=none; b=YoqBVRybK/v1EdzD/xVI6WTlUNLnVlStdfDgYP5kxK+gp0OyJkEk8bOZhs+5C2UjwBsH4yNxrxRw5NnKuq0xbdQYinLvfTzao9w2iMUTjvpvjzXnMm0vRPKD/uKk43yLy2L9nU083CQtIuCORJQEMSZ1cC9Ts/Z5g17Ka7tyFn4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786975981; c=relaxed/simple; bh=zkbOjaQO3miz7MK0St4iuO9ikuRC5p9Im/fma+BwggM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bza1bgS9kJdG5SWJdmzqDis3UcO41kgtPPMyTQch9GSCvnSsnviWYURXfttOzIT1npoXYbOn55Tnuqv+AFWcqV/xxfvz4XC/BfJuO+aXt/V2bAYBRa2uI8O7gNmDPQcrerx+JPEqh27QKLFxB03dRx7rztDP2Ut5ab4WGhhVNHI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=V0P7fkKQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="V0P7fkKQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1824E1F00ADB; Mon, 17 Aug 2026 14:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786975979; bh=7I3d7LJKVdduBHVIfLZ6Ca8n4t7UiCqaTiwYx3yk9s0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V0P7fkKQ6lJPiaRlSvLeQvsxJg7YkKymDpKZ4XHmQE8twAwtSk8aaz2hU5wqrN8xT TSMsGd9yOomAGNzybaf8cxc2qlGnvb59elAkJX51tkoi0d3xMupfJzs027DLl4q0V7 jPP5+gu8XZqvBRUB118B1I60vANMgnsfJC/59kAo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Leech , HyeongJun An , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 215/389] scsi: libiscsi_tcp: Bound SCSI Response data segment to the connection buffer Date: Mon, 17 Aug 2026 15:30:54 +0200 Message-ID: <20260817132547.597168624@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260817132538.796021292@linuxfoundation.org> References: <20260817132538.796021292@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: HyeongJun An [ Upstream commit c1dea15f819cded9b3faf58f8bec72323568b6e6 ] iscsi_tcp_hdr_dissect() receives the data segment of several PDU types into the fixed-size conn->data buffer, which is allocated for ISCSI_DEF_MAX_RECV_SEG_LEN (8192) bytes. For the LOGIN_RSP, TEXT_RSP, REJECT and ASYNC_EVENT opcodes the dissect path already rejects a PDU whose DataSegmentLength exceeds that buffer. The SCSI Command Response (ISCSI_OP_SCSI_CMD_RSP) path also copies its data segment (sense/response data) into conn->data via iscsi_tcp_data_recv_prep(), but it does so without the same check. The only upstream bound on in.datalen is conn->max_recv_dlength, the initiator's advertised MaxRecvDataSegmentLength, which is commonly negotiated well above 8192 (open-iscsi defaults to 262144). A target that returns a SCSI Response with a DataSegmentLength between 8193 and max_recv_dlength therefore overflows the 8192-byte conn->data buffer. Once the same bound applies, ISCSI_OP_SCSI_CMD_RSP is handled exactly like those responses: bound the data segment, receive it into conn->data when present, and otherwise complete the PDU with no data. Fold the opcode into that case group rather than duplicating the check. Fixes: a081c13e39b5 ("[SCSI] iscsi_tcp: split module into lib and lld") Suggested-by: Chris Leech Assisted-by: Claude:claude-opus-4-8 Signed-off-by: HyeongJun An Acked-by: Chris Leech Link: https://patch.msgid.link/20260716065848.1653431-1-sammiee5311@gmail.com Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/libiscsi_tcp.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/scsi/libiscsi_tcp.c b/drivers/scsi/libiscsi_tcp.c index 83f14b2c8804b..0aa883ab6ff02 100644 --- a/drivers/scsi/libiscsi_tcp.c +++ b/drivers/scsi/libiscsi_tcp.c @@ -722,13 +722,6 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) rc = __iscsi_complete_pdu(conn, hdr, NULL, 0); spin_unlock(&conn->session->back_lock); break; - case ISCSI_OP_SCSI_CMD_RSP: - if (tcp_conn->in.datalen) { - iscsi_tcp_data_recv_prep(tcp_conn); - return 0; - } - rc = iscsi_complete_pdu(conn, hdr, NULL, 0); - break; case ISCSI_OP_R2T: spin_lock(&conn->session->back_lock); task = iscsi_itt_to_ctask(conn, hdr->itt); @@ -745,6 +738,7 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr) } else rc = ISCSI_ERR_PROTO; break; + case ISCSI_OP_SCSI_CMD_RSP: case ISCSI_OP_LOGIN_RSP: case ISCSI_OP_TEXT_RSP: case ISCSI_OP_REJECT: -- 2.53.0