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 E8F1E47043E; Mon, 31 Aug 2026 13:51:17 +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=1788184280; cv=none; b=pMYCXWjk/DzNkA5LVewkQXvZRMAJjW92v+jdagRvPWPWLaFkdsMmWi+XPmplEeA7irHGVUuhtqJ1PYWLRgcWrRBWqVx8t+EtqKR4WQgn8uoKAXfG+gsvK/vyl+CdSRrbQ7XODxjA+O1yHwSWUl3KUCtiiGCDNeSzSxFvCWoK28w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788184280; c=relaxed/simple; bh=H8d3uxDopuBOiE3i9ZlGpZn2+sLbnrNFqMtlHPwZrH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c8XKz6aTg5jQWljh9mKTXB/LsxNC969ZJMgS1ELvu49/MUKs+7cguq0Zm0+M3/Cts+JAD9z6bPWbNEi/PNx0awjikpovrnRBNFAjE0zbKB7lfUIe9IN1sfH/hOynW2Ie+kgM876LVMZsItT0urL6scD/iwb4YgGiDO2oUVGDPE0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TGKfVmGo; 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="TGKfVmGo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50EBD1F000E9; Mon, 31 Aug 2026 13:51:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788184277; bh=YKNnbS6BmS9grjttFHPkzlgQsymgyuAYiispn7WGeQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TGKfVmGohQtTOpUPRCKrCy2ZkFtqgzHzDCHuUqUu3wRpYQtpqWKbSxACwvQ5UKIB6 B+i+oukhJNxd2nqm1LH03obwLGzHfzMY1IsEqSpJnZSuAvBmmGJo26kaxv+mrUG41i U0rmqk8jDV3UhQHHaZLpc6eknfB+9BXNLl8ODHBY= 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.12 50/99] HID: ft260: validate i2c input report length Date: Mon, 31 Aug 2026 15:34:19 +0200 Message-ID: <20260831133402.535833637@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831133359.740409777@linuxfoundation.org> References: <20260831133359.740409777@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.12-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)) {