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=1796384575; b=G75TZKrnO5AhIgiBFd25VcKd0WP2IOqTwJVT3U/cfxg7UZ1gDDltIOhsaPH9v56wb7T1 thCj/D+/0kg8S96zURgH68fn+knKaCg4cAVmHKir1e3Jn9lsZhpY2zyzpblOXrOXaCzOs WnpM1J4A5nSr4lSxTWiSEpwfm72vNJDpFz4y752EYqtz172sBt4oGDUr3rA70ad9/yV03 rh+l6EjaUlMR1Kx3qXARuK1+XysMJOGjDjzC6iYCL104Xg9zUw66acbK8ieNtNzXOq519 jFtktsE2Zwu87vBKqUEdbLcMzdkI+wHo6fS6iTTPb+f/NFNfePJVYYyFBS4dswWpw2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384575; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=LV3GNQJi6yrlHCa9oDjbicICVYOa9HO577JLzSWlKAo=; b=XGZLXhsJxo7ee/G0jy+lhpsfjSPwIhZiq3sNY1pQ50im2n3vbUijEQuIBmDm5aUn4sxK nSagKP3ajY0TWZFJRoMCdwzwRlv12d3D/jm53/OvHNaiqFXYYLw+ykUXPmFLGULeThHLd b1HNUAzK/DkPSJBeBfDICACeh0WOGPm5zKTpMPn/GDNqEwI+hvd0QsNoLFqg2ZpNVK6QA /7m6Kfv5ZGzUdXJNU7VrR/Fh3e4VBT+cb93cgLHIKUziAZ33C+eb3RbaekXfi6/Vnl1Xm MRN7YaRTntxPLgUxMP78gHaDbA6evBSXnTQza/XiNGUXX0Nq0HkiqAn/dkWizM4ndxg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=NX1Ky6JN; 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 7854A606A336; Fri, 4 Dec 2026 11:42:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=NX1Ky6JN Received: by smtp.kernel.org (Postfix) with ESMTPSA id E690B1F000C2; Fri, 4 Dec 2026 11:42:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384575; bh=LV3GNQJi6yrlHCa9oDjbicICVYOa9HO577JLzSWlKAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NX1Ky6JNXcwJc9FK5Cs5ArRDK4deOydtoJzweo1RppZbi/d+uo5kn06HQ2JRnUYjR PfcsZtj24aPboF84TCjh2Xo+k6rmhBW2m32+3vqkDrUgJcNa/wnDjMxTCD2x5FwKJ1 6ZZbNm8+xGPmq0evqm/Q0KSr9empWMfJbBkSUqQ0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Damien Le Moal , Niklas Cassel , Sasha Levin Subject: [PATCH 6.6 0209/1167] ata: libata-scsi: fix MODE SELECT field pointer for unsupported subpages Date: Fri, 4 Dec 2026 18:53:56 +0900 Message-ID: <20261204100707.512054549@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Niklas Cassel [ Upstream commit 2a4c61cf94d48ec8560473d4fd5383583ce8809c ] When the mode page of a MODE SELECT parameter list has an unsupported SUBPAGE CODE, ata_scsi_mode_select_xlat() sets the FIELD POINTER of the INVALID FIELD IN PARAMETER LIST sense data to the SUBPAGE CODE byte of the mode page header (byte 1 of the page) if the SPF bit is set, and to the PAGE CODE byte (byte 0 of the page) otherwise. However, the SPF bit is tested on p[0] after p has already been advanced past the mode page header, so the test reads bit 6 of the first byte of the mode page data instead. If the parameter list ends with the mode page header, it even reads the byte that follows the parameter list in buffer, which is not initialized when no data beyond the parameter list was transferred. The test is not needed anyway: spg can only be non-zero for a mode page in sub_page format, i.e. with the SPF bit set, and the field in error is the SUBPAGE CODE. Always set the FIELD POINTER to the SUBPAGE CODE byte, which follows the mode parameter header, the block descriptors and the PAGE CODE byte. Fixes: 7780081c1f04 ("libata-scsi: Set information sense field for invalid parameter") Reviewed-by: Damien Le Moal Link: https://lore.kernel.org/r/20261103205448.931471-14-cassel@kernel.org Signed-off-by: Niklas Cassel Signed-off-by: Sasha Levin --- drivers/ata/libata-scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index ddfeaf6b7bcd4..b43fb3de1213d 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -4030,8 +4030,7 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc) break; fallthrough; default: - fp = (p[0] & 0x40) ? 1 : 0; - fp += hdr_len + bd_len; + fp = hdr_len + bd_len + 1; goto invalid_param; } } -- 2.53.0