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 C8C56437479; Mon, 31 Aug 2026 13:55: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=1788184555; cv=none; b=c1N+5Buj9SGYD5w09UH8ShV5M0mEk6/QamlpCf0DY+nqoSA8NnsqyPy+Ru5xCo6hpyRJxkTjxy8U3BVy7n8ra91n0V5qwhy2RAGGdeB9TmyqdjHz07aMn4+60kgSysdJe5sbuVs9cfwL4rmOP/Bmg+0lzHtqcJU8clRtjSDpg64= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788184555; c=relaxed/simple; bh=6HJqF2rez0yj/C+5gMU34H0OsXF055FmPa2nkRkufmU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bYHbMjzm6rhsSebMnXgIv94DL6z460vlEAtWc4b1XWvIHV6y1vvZR1ENdl1SphEXA6Y93i1w95cFO0O/j/WaXILcINj3dEGty0BHizeD4HvpKg3vOHbig12ah+UZOS0xmrvpFdqSLEwHAcDSc/QNr3LWLpSVYmUdUNI4ARweZiw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oaJXl4zy; 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="oaJXl4zy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D47D1F00A3D; Mon, 31 Aug 2026 13:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788184553; bh=+uXFw6AHtCjAhnEnyF2t5zN3kJn/yC37kIZ7c+5+0fY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oaJXl4zyZxWWkgY/7lUoKoT4YWSz1W7P8gRVZ/3PCKhnvAdKVFkFLccodoYsS5dep rbnFlIFaCJXGwm8ICR+bo+5FnQR2ujuPfEfM2QQjXAYZSMWqn0G0CwEWwzXiloN6+K Ljxjd2DwPF8VJoylhhM8BhjH7YiRmP6E9qRKedKM= 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.6 48/91] HID: ft260: validate i2c input report length Date: Mon, 31 Aug 2026 15:34:36 +0200 Message-ID: <20260831133402.230688748@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831133359.468089036@linuxfoundation.org> References: <20260831133359.468089036@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.6-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)) {