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 D07D51A6822; Sun, 7 Jun 2026 10:47:34 +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=1780829255; cv=none; b=PI1dwcy8VUDiKdVkriEXQB8erPucMbU4jctV1T4ccXBoTx1eHUD92deKGnMe8AXM9CbqpAYx58Ifbq+g9H9V40p18ZLp5OovVjOPCVLHdb3w3e7kKoAuddfDiO9l+5weVaAO+DqhifqxDPAMQThAl/3G+riEMhSrGqjzrfT3KP8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780829255; c=relaxed/simple; bh=pQW9xjtJX/01j31HS9ImRGAsNn5r+cYtLLH5URNiixs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aCJ0iBjqAfxF5dPAM1GyVPRSngEF1cfrBlogwEjc89HCQr1FqCbnn3Qy9FLKUnWNfjDfqzlrF2CBETuEe0Gm7U08oyTSk3QUoA1C3usSmsz/LIQZYduMwvUdRS6cUZwXhvPl9EZ79+2HIClzATsO3DagyQG89Db7vB1ZB9J4/OU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=waLR+0wH; 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="waLR+0wH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20F931F00893; Sun, 7 Jun 2026 10:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780829254; bh=Hd6kAndhJDfKE/lnXU94IyOWpu3Ia6Dfzj/MQU1MnHM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=waLR+0wHQK0aBEUll6WMYqHNhOo4jJPbnxbN2UInb6KSng7chLymYeQTXJFfso5iT iCj3lO0hnOVCh7BRBgHaAbqrAE9YsJw4MH9MjgOWJ/uIKxP/3nB/muDPs3qh8ZpaHc xDAnCsUqMJla5H7ncCDI/7ZXJVtAifcbui1roIKA= 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 7.0 258/332] usb: usbtmc: check URB actual_length for interrupt-IN notifications Date: Sun, 7 Jun 2026 12:00:27 +0200 Message-ID: <20260607095737.516989348@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095728.031258202@linuxfoundation.org> References: <20260607095728.031258202@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.0-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 @@ -2306,6 +2306,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];