{"id":2215609,"url":"http://patchwork.ozlabs.org/api/patches/2215609/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260324201858.46591-1-sebasjosue84@gmail.com/","project":{"id":35,"url":"http://patchwork.ozlabs.org/api/projects/35/?format=json","name":"Linux I2C development","link_name":"linux-i2c","list_id":"linux-i2c.vger.kernel.org","list_email":"linux-i2c@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260324201858.46591-1-sebasjosue84@gmail.com>","list_archive_url":null,"date":"2026-03-24T20:18:58","name":"[v2] HID: ft260: validate report size and payload length in raw_event","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"1decde542b8752ab92c983d5e50f53ef06079be1","submitter":{"id":92955,"url":"http://patchwork.ozlabs.org/api/people/92955/?format=json","name":"Sebastian Alba Vives","email":"sebasjosue84@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260324201858.46591-1-sebasjosue84@gmail.com/mbox/","series":[{"id":497344,"url":"http://patchwork.ozlabs.org/api/series/497344/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/list/?series=497344","date":"2026-03-24T20:18:58","name":"[v2] HID: ft260: validate report size and payload length in raw_event","version":2,"mbox":"http://patchwork.ozlabs.org/series/497344/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2215609/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2215609/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-i2c+bounces-16720-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-i2c@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=e6vCoVf1;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-i2c+bounces-16720-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"e6vCoVf1\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.222.41","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgM234yQyz1y1K\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 07:23:55 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 1F60430FF4EA\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 24 Mar 2026 20:19:07 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 982B834A773;\n\tTue, 24 Mar 2026 20:19:06 +0000 (UTC)","from mail-ua1-f41.google.com (mail-ua1-f41.google.com\n [209.85.222.41])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id EEF5334A3C1\n\tfor <linux-i2c@vger.kernel.org>; Tue, 24 Mar 2026 20:19:04 +0000 (UTC)","by mail-ua1-f41.google.com with SMTP id\n a1e0cc1a2514c-94e578a0fa5so837814241.0\n        for <linux-i2c@vger.kernel.org>; Tue, 24 Mar 2026 13:19:04 -0700 (PDT)","from localhost.localdomain ([2a09:bac6:d6dd:aa::11:17b])\n        by smtp.gmail.com with ESMTPSA id\n ada2fe7eead31-602b549fff7sm11665211137.7.2026.03.24.13.19.01\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Tue, 24 Mar 2026 13:19:03 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1774383546; cv=none;\n b=Wy6ghoVPCG4NID0M3K63Vgsm88YJJFzf22/4obzI12MBchue9b2S2vLWn+NBOE3XAvAJRHJr/lzKxL0QUdTc6k0i1pDYh5DduEg2GuG4L3f2+mEvKuh0IKPyNod7a4ooonKygcvlnGglT/eZMJi/iuRNG1vZ7OVWGmZivmfIOOQ=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1774383546; c=relaxed/simple;\n\tbh=Dyg46i6NCc1WhVwi8ovx5dhpXtlJuvYJqgKq6QPv0Pc=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=DdVKeDgk2iJLfDn0hL4RP5K2b82MWIxbfFZOG/VbFTydduUspVviyjZuDcPoqO5H3Fv1O9Q2ieL493G2njiE3SQzyds0oubl2CbTXWXPNWOxZYNWrvI64LRs6vQVpBNRSyq4BH2LZWRDSsnk5KM8BBTOrPf78dsyqwqA9xfoYKs=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=e6vCoVf1; arc=none smtp.client-ip=209.85.222.41","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1774383544; x=1774988344;\n darn=vger.kernel.org;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n         :message-id:reply-to;\n        bh=c/LwkGsCAcMgkIjG5Z0vM08NnZ6ybKA3EObcdXRbB+Q=;\n        b=e6vCoVf12gK9VWthRMn61bBa/NccVDO0jp6+PjF+1gUG5lfxCW6Lloo3qiTgcbzK7o\n         UWAtpQ9YKK28PesKG0rLIAedXyI/0nD1swFFk6XPzyl2mBdcb3seQOz3nEhdf4bZq9uB\n         EGmF2C+5lfuGxGxTL3WIZq5wH0V092DYfTyuaYnC6oL5iXbypLgE305y0Y4m6mHrcc6f\n         3nzxCMRssTptHAgaolWDwMolk+l6XgqgJFCabVIgG0i24QbVuC/oWc5Ke/tpCLlxPW3K\n         24OArcrdEiHivf4LCu7yZG6D0xrVagMIRTvdogvgB6wtzFA6XroaH2xmI70oJZAU5RQC\n         yaTQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1774383544; x=1774988344;\n        h=content-transfer-encoding:mime-version:references:in-reply-to\n         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n         :to:cc:subject:date:message-id:reply-to;\n        bh=c/LwkGsCAcMgkIjG5Z0vM08NnZ6ybKA3EObcdXRbB+Q=;\n        b=ArKsc5ropMdmroDc173On8ZJDx59YXnQ5x6wHh8ALEOH972hvj0qukulrnOKDbreeu\n         gXmZdl3jCSBD/1qcOx50E+8UOS5Eg8QQCzEFxqqpnFa7xY43mknWXIUnXxk6jFGFsPfa\n         x26/mE9Pi2bO3TEaRXljGldDBSxshi+o+iM3Jbnv7ESkyRv8iQd2ervg6tdZ8u1C6aXI\n         sN1GpKZ8y2lz5GvV4q6ftX3L0FxMNPx+4Px+MpxiD1S9DZebfEYAKsFvzsqodS5bZ+tA\n         RR+vRL/HPrBMg1zzV8pIz67NNGo6ngDpmVJbBF38taQolwUdVRXsfVI7kESu2x6mUNQk\n         64+A==","X-Gm-Message-State":"AOJu0YxDrnyW0OgKJthYNZEpAqUD7BxCLlxjJ8K9eUHakfpWjw9Tzg1E\n\tuGnB0zDWBxDiQF0bvdy98mKd2bfyqUejLSkITGyDEw7vesaOoiNjCf+tmRv091kiQy4=","X-Gm-Gg":"ATEYQzxWzAyEnVo0uvM9g6Q+d8Sb58501w9NDeiVUmdQHL1TCQ6BKHlR6uyBWNFHp+Y\n\tJB2jsyhVxJnXQQ/sovgHvymgwkKcyeWQsOHX84voxXFNsQcrEpV2uYaannrHgW7iKt0fyezqPFI\n\tVBBt7ZKu+vKPBklOnfsrX8+0gsLtS/Jl63TKSaBCpKn/k/v5vLqS6EabvaDPVYHYc0eVwTWq0uH\n\tydwpQ2FYMYkys+Uban1ioz5IrAAU05Rq8k9elE8S0Q407SKvhIVkqXP0Twd0wskiRURmaaSHJE3\n\teeeaa6qcg0Sr1Y2HIi5Lk++kBVeu7jvPwxwhwpxctDDM2eWOUjRlJeK/NHTAhBnpsX5WP3JVSSr\n\tV0a1G34N8pCGAOO0DiIwFOIhD4ITU/Ul0aoOl5m+zXE+8Ti5Y/YuCzo+bXLQLVACnz1qdAOAIDp\n\tNQbHa7dOmA3CxYRwXhT1qc6hNY7Abszzehnw==","X-Received":"by 2002:a05:6102:4425:b0:602:a4af:5fe with SMTP id\n ada2fe7eead31-603870b6353mr706587137.9.1774383543988;\n        Tue, 24 Mar 2026 13:19:03 -0700 (PDT)","From":"Sebastian Josue Alba Vives <sebasjosue84@gmail.com>","To":"michael.zaidman@gmail.com,\n\tjikos@kernel.org,\n\tbentiss@kernel.org","Cc":"linux-i2c@vger.kernel.org,\n\tlinux-input@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tstable@vger.kernel.org,\n\tSebastian Josue Alba Vives <sebasjosue84@gmail.com>","Subject":"[PATCH v2] HID: ft260: validate report size and payload length in\n raw_event","Date":"Tue, 24 Mar 2026 14:18:58 -0600","Message-ID":"<20260324201858.46591-1-sebasjosue84@gmail.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260324173527.11321-1-sebasjosue84@gmail.com>","References":"<20260324173527.11321-1-sebasjosue84@gmail.com>","Precedence":"bulk","X-Mailing-List":"linux-i2c@vger.kernel.org","List-Id":"<linux-i2c.vger.kernel.org>","List-Subscribe":"<mailto:linux-i2c+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-i2c+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"ft260_raw_event() casts the raw data buffer to a\nft260_i2c_input_report struct and accesses its fields without\nvalidating the size parameter. Since __hid_input_report() invokes\nthe driver's raw_event callback before hid_report_raw_event()\nperforms its own report-size validation, a device sending a\ntruncated HID report can cause out-of-bounds heap reads.\n\nAdditionally, even with a full-sized report, a corrupted\nxfer->length field can cause memcpy to read beyond the report\nbuffer. The existing check only validates against the destination\nbuffer size, not the source data available in the report.\n\nAdd two checks: reject reports shorter than FT260_REPORT_MAX_LENGTH,\nand verify that xfer->length does not exceed the actual data\navailable in the report. Log warnings to aid debugging.\n\nCc: stable@vger.kernel.org\nSigned-off-by: Sebastian Josue Alba Vives <sebasjosue84@gmail.com>\n---\n drivers/hid/hid-ft260.c | 11 +++++++++++\n 1 file changed, 11 insertions(+)","diff":"diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c\nindex 333341e80..68008a423 100644\n--- a/drivers/hid/hid-ft260.c\n+++ b/drivers/hid/hid-ft260.c\n@@ -1068,6 +1068,17 @@ static int ft260_raw_event(struct hid_device *hdev, struct hid_report *report,\n \tstruct ft260_device *dev = hid_get_drvdata(hdev);\n \tstruct ft260_i2c_input_report *xfer = (void *)data;\n \n+\tif (size < FT260_REPORT_MAX_LENGTH) {\n+\t\thid_warn(hdev, \"short report: %d\\n\", size);\n+\t\treturn 0;\n+\t}\n+\n+\tif (xfer->length > size - offsetof(struct ft260_i2c_input_report, data)) {\n+\t\thid_warn(hdev, \"payload %d exceeds report size %d\\n\",\n+\t\t\t xfer->length, size);\n+\t\treturn 0;\n+\t}\n+\n \tif (xfer->report >= FT260_I2C_REPORT_MIN &&\n \t    xfer->report <= FT260_I2C_REPORT_MAX) {\n \t\tft260_dbg(\"i2c resp: rep %#02x len %d\\n\", xfer->report,\n","prefixes":["v2"]}