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 39B592D8378; Sun, 7 Jun 2026 10:49:53 +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=1780829394; cv=none; b=pln3xRPYPwNtMJY7tsNb0MhqV9VHrp6enw6LfqoTjVt29zgmxvEqzz5TLP1LyBEUeWvYkb4AIh+XRxOOe7tDTL0MvLFwioD4sbR3JyzcWVUcovEPUMiQZGYF4ArQ9JOkzgyuNoxaNkTIA/40wJQsiWtOeYxuJ4CIHgK2eI3/5j0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780829394; c=relaxed/simple; bh=4aK1T500EioE1+ICCEA11y45ScGtdpYu7BHtDh65hO4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zlu4GTmYVeeYcbmYUKtnuh3Q2vwMRlYSy9yeX2UtVt0Bm/pGu6Jjknqw3WV5WIAiFW7+qZfpwtYpLaheilllq9E8UnlO77zbs7g9/wKAizmYza6RvoCe1rKr0lgoNmDhLJ9tCi8VGte5N06dxjYefXgcMnSNIXMbgzvyzSVPPBw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hPmjvBgp; 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="hPmjvBgp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80E8B1F00893; Sun, 7 Jun 2026 10:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780829393; bh=lHdF/v842TXvy1zzImnc1eBtufOnYfzsLxZzMSqqxAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hPmjvBgpkIZPmqrhwoXpdKTCkzC9A06znYVOmb0ew31rTCRGYZ52q2Rh4m9wif01J oDzMuRNotoGeS/h/TLHb4aFuM4I/a5wun1+cUigj7Sct3/ZRcCYbnRI8kqntx3cXs/ NikFSw75wTKNjBbWC5JcuNzyNWF0VhxixDS5ZAqM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+abbfd103085885cf16a2@syzkaller.appspotmail.com, stable , Michal Pecio , Heitor Alves de Siqueira Subject: [PATCH 6.12 220/307] usb: usbtmc: check URB actual_length for interrupt-IN notifications Date: Sun, 7 Jun 2026 12:00:17 +0200 Message-ID: <20260607095735.794643142@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.647295505@linuxfoundation.org> References: <20260607095727.647295505@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Heitor Alves de Siqueira commit 52f2ad3f7e5eb3b5908e1d685d4342519dc9cfcd upstream. USBTMC devices can use an optional interrupt endpoint for notification messages. These typically contain two-byte headers indicating the payload format, but the driver does not check if these headers are present before accessing the data buffers. In cases where the URB actual_length is not enough to fit these headers, the driver will either cause an out-of-bounds read, or consume stale leftover data from a previous notification. Fix by checking if actual_data contains enough bytes for the headers, otherwise resubmit URB to the interrupt endpoint. Fixes: dbf3e7f654c0 ("Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.") Reported-by: syzbot+abbfd103085885cf16a2@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=abbfd103085885cf16a2 Cc: stable Suggested-by: Michal Pecio Signed-off-by: Heitor Alves de Siqueira Link: https://patch.msgid.link/20260505-usbtmc-iin-size-v3-1-a36113f62db7@igalia.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/usbtmc.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/usbtmc.c @@ -2310,6 +2310,14 @@ static void usbtmc_interrupt(struct urb switch (status) { case 0: /* SUCCESS */ + /* ensure at least two bytes of headers were transferred */ + if (urb->actual_length < 2) { + dev_warn(dev, + "actual length %d not sufficient for interrupt headers\n", + urb->actual_length); + goto exit; + } + /* check for valid STB notification */ if (data->iin_buffer[0] > 0x81) { data->bNotify1 = data->iin_buffer[0];