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 81BE6314B6D; Fri, 7 Aug 2026 15:32:31 +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=1786116752; cv=none; b=DhAaMmOD8tNlokL0uv0dPuMz8e2CFlH0Ay78ktkhoR1K8/EFTBpGA6doXyYuS2y9J+4T4EjCaySm3bBi9sUyWlUybcfI6Uhmp8c+4KeSfB6s7soccHiZAktFLkUcFWcGUcJhV6S1Yz+3X859fKCc75NHALXQ3RbvFbaHpoQPJZk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786116752; c=relaxed/simple; bh=FaJY7fsN/l9C9MFZ4gVHrtL6qGYVSk8cb6OEZdRTdvo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NhMAGEfB+uqx8YoyA5NoAt6AvzQMJ3zelnELVWBX8XciMSy23PHyHo5OpkMCp4RJfLJDw5Msls7nJOOcShTtedIDQ4/t6KyAIZ2CuFg+99KA9eCdGEfu3dcYbBDTZslSOwngkSeJ2arByH+MZsMFbgXmDeLs/FdqbD0EjOkUN9M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=aPqaquo8; 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="aPqaquo8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7AF51F000E9; Fri, 7 Aug 2026 15:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786116751; bh=XeJJwtGFIebbPZoN1WmwuIeOqL4vLl0yZExd3fSzIe0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aPqaquo8LqHadUwpL4TpcczfrKMGwYlw8u7aIGp0HchLJegUtjs6J/RZjxA/hOFqp bAk4/kZlJmcweS4J6yWKSApA9osbaFG9VkmV5LnC9gurvs6zTVvJOvZki4yV3VJGnp IpV5t5rpwhmYX9uzK7c87BC0FTxusxRMODU2xJuE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko AI , HyeongJun An , Chris Leech , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 7.1 079/438] scsi: libiscsi: Fix stale-data leak into the SCSI sense buffer Date: Fri, 7 Aug 2026 16:34:35 +0200 Message-ID: <20260807143429.667435403@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260807143428.008222056@linuxfoundation.org> References: <20260807143428.008222056@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 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: HyeongJun An [ Upstream commit 98b87885de4b7f605533a2860685f5689fce8e82 ] iscsi_scsi_cmd_rsp() copies the sense data of a SCSI Response from the target-supplied data segment. The segment carries a 2-byte sense length followed by the sense bytes, so it must hold 2 + senselen bytes, but the bounds check only requires datalen >= senselen: senselen = get_unaligned_be16(data); if (datalen < senselen) goto invalid_datalen; memcpy(sc->sense_buffer, data + 2, min_t(uint16_t, senselen, SCSI_SENSE_BUFFERSIZE)); A target that returns a SCSI Response whose datalen equals senselen (with senselen <= SCSI_SENSE_BUFFERSIZE) makes the memcpy() from data + 2 read up to two bytes past the received data. Those bytes are stale conn->data contents and end up in the command's sense buffer, which is returned to userspace. Account for the 2-byte sense length prefix in the check. Fixes: 7996a778ff8c ("[SCSI] iscsi: add libiscsi") Suggested-by: Sashiko AI Assisted-by: Claude:claude-opus-4-8 Signed-off-by: HyeongJun An Acked-by: Chris Leech Link: https://patch.msgid.link/20260714104934.1404423-1-sammiee5311@gmail.com Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/libiscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 25857d6ed6e84..1b4e6af37c927 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -918,7 +918,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, } senselen = get_unaligned_be16(data); - if (datalen < senselen) + if (datalen < senselen + 2) goto invalid_datalen; memcpy(sc->sense_buffer, data + 2, -- 2.53.0