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 B5EF14534B4; Tue, 16 Jun 2026 16:00:55 +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=1781625656; cv=none; b=Fi9n62SftpQvQ1tFLuGbwtQyZTdMMhxBnXaPVVn1pHU3ctuxuJ02SPvc76aMTkTqQ5Z8gM/QJ9h3OXE8tXhAepDvfraruIE7Wg49dEllKJ+KkKqWdhF2lGkC6Vgq2d2CIcTvLLnlTMfMWQqFD6p8VL/eSYYAZtCMZiZwuDOAXHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781625656; c=relaxed/simple; bh=LYQPiueEOTdcq3rCwsu88gr3P+gLHLCvZ5H6JOwguhc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hAgFaDC4Rwtob8RTkQYy5jRZ8rtqbNoJUH62eMAQlMgN+/+DZ9/MoY9dCjpvL+V6AVsOgsMK1HoC8QOM5S7/xe2cLyCN9p73zvixZnqEhtDV+HG+3Gi/ZV13KESAIoHgzFBm5rXQhdRvujRiFBNGmHPhr6v4ujDxrYoVCoDA5us= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=K+BW8ygB; 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="K+BW8ygB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA38A1F000E9; Tue, 16 Jun 2026 16:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781625655; bh=eApYK67iYOuxziXzRRVJMLk/5hyiF11q8G6cs+rkjRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=K+BW8ygB2lhIOVmdIXfzHGsVU8d3Lu1HizoPeUwCgE8BPNRZulNlL4SMAi3VMIT6A DHlQCOn6W9A3VHQC+9qnm2rG5dkxSxV/keDAMy1yVb9+6N3aryxrpnKxKwJq/Bb8H1 gEVjy9UrVlVatbZmqkNhxnhtG6tzIlKp//P8LCJ8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Adrian Korwel , Johan Hovold Subject: [PATCH 6.18 175/325] USB: serial: io_ti: fix heap overflow in build_i2c_fw_hdr() Date: Tue, 16 Jun 2026 20:29:31 +0530 Message-ID: <20260616145106.579565825@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145057.827196531@linuxfoundation.org> References: <20260616145057.827196531@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.18-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));