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 4DC18468C11; Mon, 31 Aug 2026 13:46:08 +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=1788183970; cv=none; b=sjwVYi7eMieB/W8bYgQRnL9mJErcp9JzqCyAnZ31/XMjQm1TgL6+RvBuQFKREqpzdybue5gWGYA/0gx5CPTkUKx3RzS+oou7ysay9AsQR0UToopC/1ZxHU0MnyY75jg+tN4QSP9f5MGwunKoo2XenjRwNUHQLHG+Fir0F5Nkqgc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788183970; c=relaxed/simple; bh=comziWr/5K8WfwuQBHOd9VGZvguus2TJqfX8K/UsX04=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K/p22S1qqZay6isjQriinYoRwOne3csdrrY65llkVjFPVDela0zARvu8hXON0wFdyv+EUDbnttoiqB1V/d569jSDy8O+bvrc7sodDWb410bWaEB8sR20IrQUVaDqj90tx/Tmh7YxOVXBqJs9NAZPfxxo6sDhbN+gsEwWiRpGgu4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GV0Tvlxh; 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="GV0Tvlxh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5FBF1F00A3D; Mon, 31 Aug 2026 13:46:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788183968; bh=fghGkx5liQcalvx9nV5r1eXv7OKf6DbupCf/K9SrlGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=GV0TvlxhLRmVa9UWMoBkrkIjT8jMWq/lqclYQuO/AO4H6VbQg3xW4I6QRwFk70jym g2oisrraP5waSASmgeDwUvQqhwMt3kBNOVUYtHLbxlOJ7d/iiNKPnYihxB25NJ6lca DcsRe2P//9rSCDAzDm4uR59JneoNEH7DIeAc0AOo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Sebasti=C3=A1n=20Josu=C3=A9=20Alba=20Vives?= , Michael Zaidman , Jiri Kosina , Sasha Levin Subject: [PATCH 6.18 27/83] HID: ft260: validate i2c input report length Date: Mon, 31 Aug 2026 15:34:03 +0200 Message-ID: <20260831133400.728572617@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831133359.207714926@linuxfoundation.org> References: <20260831133359.207714926@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Zaidman [ Upstream commit 80c4bbb2b38513e9c3d84805fa61a0ee16d79c45 ] Add two checks to ft260_raw_event() to prevent out-of-bounds reads from malicious or malfunctioning devices: First, reject reports shorter than the 2-byte header (report ID + length fields). Without this, even accessing xfer->length on a 1-byte report is an OOB read. Second, validate xfer->length against the actual data capacity of the received HID report. Each I2C data report ID (0xD0 through 0xDE) defines a different report size in the HID descriptor, so the available payload varies per report. A corrupted length field could cause memcpy to read beyond the report buffer. Reported-by: SebastiƔn JosuƩ Alba Vives Signed-off-by: Michael Zaidman Signed-off-by: Jiri Kosina Stable-dep-of: bf3e39df3a39 ("HID: ft260: fix stack-use-after-return write in I2C read race") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-ft260.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1068,10 +1068,22 @@ static int ft260_raw_event(struct hid_de struct ft260_device *dev = hid_get_drvdata(hdev); struct ft260_i2c_input_report *xfer = (void *)data; + if (size < offsetof(struct ft260_i2c_input_report, data)) { + hid_err(hdev, "short report %d\n", size); + return -1; + } + if (xfer->report >= FT260_I2C_REPORT_MIN && xfer->report <= FT260_I2C_REPORT_MAX) { - ft260_dbg("i2c resp: rep %#02x len %d\n", xfer->report, - xfer->length); + ft260_dbg("i2c resp: rep %#02x len %d size %d\n", + xfer->report, xfer->length, size); + + if (xfer->length > size - + offsetof(struct ft260_i2c_input_report, data)) { + hid_err(hdev, "report %#02x: length %d exceeds HID report size\n", + xfer->report, xfer->length); + return -1; + } if ((dev->read_buf == NULL) || (xfer->length > dev->read_len - dev->read_idx)) {