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 A0C123BFE40; Tue, 16 Jun 2026 16:27:02 +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=1781627223; cv=none; b=s9un8OgNgNrQOuOKtN4S0NqumB3KUU3xul3VNnxEkkbFRJEA9bmjSscpy8v9RiuXiCwb3sZzcpEnZID5wXipsvyae3LAN8q+4IfS7hmPvPp0Qu1T1uPM+LimvQ2Hs+2Jt3lDWSAsAxkYDlfR03unAE/BAUjwvghwNQyGVXoyX1Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781627223; c=relaxed/simple; bh=QRh1esEtSdAIZJVS8MyuvX/Su40Jcoir8tZIpDy7feY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ATzTmCmgQDytJzKP9gbyYkTlA9E9GTBIVjumGtww7SR+143y2f9CZAP4MCDDQIzMSSdRpMZPUSlIGq18gxDdDBg1CwInEBCFjjeMR3zMiuZmmemB6WldX/JxAfKwUk/3RkTJ0WH7raH6epJg3RuZqH6Hr/kHMNqh07O18E+DLl4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=10ZUqtqJ; 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="10ZUqtqJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A29CB1F000E9; Tue, 16 Jun 2026 16:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781627222; bh=AUWESKnSTar6qskMN/Mx/3Ow+QOWF6c60eaz5tgEl4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=10ZUqtqJjE7l24ubIFGu5I2cQgRfUK85w6rm9pgJHJ0JiMaybFybGwZ9kgVusTKZz KKYTCUaD7PcDw49eyPDZQcR80fLDmQmNaLZUvUhECBGO4Bn+p0enBL+MtAQTefI8rt rpeir+DbsUBT8edEGHtel2aR+Qgp6PGuemtPXNOg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Adrian Korwel , Johan Hovold Subject: [PATCH 6.12 140/261] USB: serial: io_ti: fix heap overflow in build_i2c_fw_hdr() Date: Tue, 16 Jun 2026 20:29:38 +0530 Message-ID: <20260616145051.569629578@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145044.869532709@linuxfoundation.org> References: <20260616145044.869532709@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: Adrian Korwel commit 0fd2b00b2d3d05e3eaa13342b3dfb0fa85c226ae upstream. build_i2c_fw_hdr() allocates a fixed-size buffer of (16*1024 - 512) + sizeof(struct ti_i2c_firmware_rec) bytes, then copies le16_to_cpu(img_header->Length) bytes into it without validating that Length fits within the available space after the firmware record header. img_header->Length is a __le16 from the firmware file and can be up to 65535. check_fw_sanity() validates the total firmware size but not img_header->Length specifically. Fix by rejecting images where img_header->Length exceeds the available destination space. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Adrian Korwel Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/io_ti.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -844,6 +844,11 @@ static int build_i2c_fw_hdr(u8 *header, /* Pointer to fw_down memory image */ img_header = (struct ti_i2c_image_header *)&fw->data[4]; + if (le16_to_cpu(img_header->Length) > + buffer_size - sizeof(struct ti_i2c_firmware_rec)) { + kfree(buffer); + return -EINVAL; + } memcpy(buffer + sizeof(struct ti_i2c_firmware_rec), &fw->data[4 + sizeof(struct ti_i2c_image_header)], le16_to_cpu(img_header->Length));