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=1796179800; b=RgruG0yim28nyH/WT3Drgp3tVUb4F/F6SV04M0pYRcQLpklu7lwpdYG0R6GpUQNbY+1x S+ePzv2CMNWd9i6dVmoQgW3Qq642Rk++9Dwi7qrpZ+s5VRyCK7MyZrUYUY157ZQhMnJ5n 71RLF4ag0Czdo7tnqa5C+Vs+g8LwDMFE/3hmqOrDaWmGZa0y85PrK8WszlJuEFgLm33Z5 rc8D1HKOu2KkKOiSxBxIQGfobLJVPl/CYlhsr2xyzit0CBhwBujJhhrGRjhxPZe8NHxKQ w1f6BA6b83f0s93y5K6twu3buJ+OIWefFw4/TMn8xax0t6u5+NbtlNHFmv/dMVtkhpA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796179800; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Sokg31T7/4sMx2rDzSBKLRJiRGG9fmOaYJLQBVeObdo=; b=OONKkyckW2wWtIaJow8+qLL6+DnFIAllaa+WH5upQv4OUj5M0GN2MigvvJIPukkgRS96 UEQmJl35jnpHAeOStAU1rxdOGehmqnOSYq/Sy3QJdcaDMNtjP5RRuMcayOHfZTb+tWZPJ wHnxmLYcyCU4vav6miyro8UdKF8lo4dYSxBEthdBavIBQf4NvTfTJ/aWv4clIRI+HIS6R z0IghGg74fHcKL84IXQarbcHVf1SsQsBudZ8IwViPNrjXUL3HOTBpiMgYs4I3H4pL4TAi XHyIzvfSpvVb7ptpwMRysBwXAjIwklzFWd54N4saOkbcb26nq+0kopaLK3bH/MDR17g== 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=KLgIQtws; 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 23757606A339 for ; Wed, 2 Dec 2026 02:49:59 +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=KLgIQtws Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E81F1F00893; Wed, 2 Dec 2026 02:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796179799; bh=Sokg31T7/4sMx2rDzSBKLRJiRGG9fmOaYJLQBVeObdo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=KLgIQtwslV815FXYGUwydabYaBCk0aU8Ozu99KvXjp8yxg8YvWTfm6L9aZzCOlOR/ H/GMqC04YIVSfwXjER2FRQ1tyX7QAvbUrh1pJUuugOK/2NaKjx5WFFYz4h8PBNS6wr WZFVws4g1XqRiznePE+c6PVIiyfX4jz8IH1QkU/oKtjV/pLle0Wf59ZTpcfN1oYqUf YQgaSXYWqMiVxuCzXHp8exWbt/yOQJSCsmqWqemMWcnRL2J+ezNaeJ6+xw/Gg1iDL7 T8x0adEu23dTehCs4QJTdjrOBvlcW7c1b4IMB/l0aKaHdDEBvPuTICQwJBIvL9lLQU dt0YmUFUJs+bg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] usb: storage: shuttle_usbat: reject oversized device-reported read length Reply-To: sashiko-reviews@lists.linux.dev To: "Artem Dinaburg" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261202024441.52639-1-artem@trailofbits.com> References: <20261202024441.52639-1-artem@trailofbits.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 02:49:59 +0000 X-Mailing-List: linux-usb@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 no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [High] usb: storage: wrong READ CD length unpacking in usbat_hp8200e_handle_read10() [1] -- commit 93bfef65f8b31cbe01134b79df0424fc0e66a02f Author: Artem Dinaburg usb: storage: shuttle_usbat: reject oversized device-reported read length This commit rejects device-to-host read transfers in usbat_hp8200e_transport() when the response length reported by the device's ATA LBA_ME and LBA_HI registers exceeds scsi_bufflen(srb). > diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/sh= uttle_usbat.c > index 563a2beeeb44a..35129e82612c9 100644 > --- a/drivers/usb/storage/shuttle_usbat.c > +++ b/drivers/usb/storage/shuttle_usbat.c > @@ -1673,6 +1673,9 @@ static int usbat_hp8200e_transport(struct scsi_cmnd= *srb, struct us_data *us) > else > len =3D *status; > =20 > + /* The device reports the length; don't overrun the buffer */ > + if (len > scsi_bufflen(srb)) > + return USB_STOR_TRANSPORT_ERROR; > =20 > result =3D usbat_read_block(us, scsi_sglist(srb), len, > scsi_sg_count(srb)); [Severity: High] This problem wasn't introduced by this patch, but does usbat_hp8200e_handle_read10() unpack the wrong CDB bytes when computing the transfer length in blocks for GPCMD_READ_CD [1]? When usbat_hp8200e_transport() handles GPCMD_READ_CD with a transfer buffer= of at least 64 KiB, usbat_hp8200e_handle_read10() computes len from data[7..18] (which holds the 12-byte CDB): drivers/usb/storage/shuttle_usbat.c:usbat_hp8200e_handle_read10() { ... if (data[7+0] =3D=3D GPCMD_READ_CD) { len =3D short_pack(data[7+9], data[7+8]); len <<=3D 16; len |=3D data[7+7]; usb_stor_dbg(us, "GPCMD_READ_CD: len %d\n", len); srb->transfersize =3D len ? scsi_bufflen(srb) / len : 0; } ... } For GPCMD_READ_CD, the 24-bit big-endian transfer length in blocks is in CDB bytes 6..8 (data[7+6..7+8]), while CDB byte 9 (data[7+9]) holds the sector = and header selection flags (such as 0xf8 for 2352-byte raw CDDA frames). Becau= se short_pack(LSB, MSB) puts its first argument in the low byte, this expressi= on evaluates to (srb->cmnd[8] << 24) | (srb->cmnd[9] << 16) | srb->cmnd[7], ignoring srb->cmnd[6] and shifting in the flags byte. When srb->cmnd[9] is non-zero, len is inflated so scsi_bufflen(srb) / len becomes 0, forcing srb->transfersize to the 2048-byte fallback and miscomputing both the per-chunk byte count and the rewritten CDB sector cou= nt. [1] https://sashiko.dev/#/bug/linux-9aacd68e-51b6-463a-88fe-003733a49838 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202024441.5263= 9-1-artem@trailofbits.com?part=3D1