{"id":2215482,"url":"http://patchwork.ozlabs.org/api/patches/2215482/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/patch/20260324170606.5407-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":"<20260324170606.5407-1-sebasjosue84@gmail.com>","list_archive_url":null,"date":"2026-03-24T17:06:06","name":"[v2] HID: mcp2221: validate report size in raw_event handler","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"08a9d5aaede12191ec650d2d0ef47efcf29e14b1","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/20260324170606.5407-1-sebasjosue84@gmail.com/mbox/","series":[{"id":497319,"url":"http://patchwork.ozlabs.org/api/series/497319/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-i2c/list/?series=497319","date":"2026-03-24T17:06:06","name":"[v2] HID: mcp2221: validate report size in raw_event handler","version":2,"mbox":"http://patchwork.ozlabs.org/series/497319/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2215482/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2215482/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-i2c+bounces-16705-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=XPHrwHAH;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-i2c+bounces-16705-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=\"XPHrwHAH\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.221.175","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 [172.234.253.10])\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 4fgGp72VTHz1y1g\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 04:13:19 +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 1525130E6292\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 24 Mar 2026 17:06:17 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 773883F65F4;\n\tTue, 24 Mar 2026 17:06:14 +0000 (UTC)","from mail-vk1-f175.google.com (mail-vk1-f175.google.com\n [209.85.221.175])\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 D22C339EF28\n\tfor <linux-i2c@vger.kernel.org>; Tue, 24 Mar 2026 17:06:12 +0000 (UTC)","by mail-vk1-f175.google.com with SMTP id\n 71dfb90a1353d-56cc6fe8815so2427075e0c.1\n        for <linux-i2c@vger.kernel.org>; Tue, 24 Mar 2026 10:06:12 -0700 (PDT)","from localhost.localdomain ([2a09:bac6:d6de:aa::11:17b])\n        by smtp.gmail.com with ESMTPSA id\n a1e0cc1a2514c-95136b4ac1fsm12420024241.3.2026.03.24.10.06.09\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Tue, 24 Mar 2026 10:06:11 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1774371974; cv=none;\n b=hQ0J/eFtGh60KVGopKX/wGBRYdudVD06QRcUr9u1AOobM61ND+ZnMwBwxx/FXzToOOm86VIcJ/+g5rhss7E3XP5HK6zRKUxSOuf88KcqGAU7wo7vg2sKpTClxkadF8a0EipZeqkAA+TUqnxEDOK4vyDFez2EBNrYLaSbnAi4zac=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1774371974; c=relaxed/simple;\n\tbh=HMPY83hDOtEh2uH8sesLzoJ/Zhf64/JSuRtvJ9f2po4=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=ShxIZi5pl+Ofh9KZEFhPbTboKhC84dxxBBzAsEQ+8QS950hXLf7yL/iu3z+8f/4xm7dO9XOchjSCq9G4RofN06eSJ/oVmOuXvctG4JoFa6HrojbDlcw3Vy6SdagSDAyp7w5AseIlBC0majOnuMyDWXy0la640jTEiVxCbRUxm8g=","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=XPHrwHAH; arc=none smtp.client-ip=209.85.221.175","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1774371972; x=1774976772;\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=26QADu2V5kInSwvDprX/X5k3HI6g/YNPM7XdH9A3Fig=;\n        b=XPHrwHAHMGgq2OLAx+Mw7ht2m9acEdS03JXFuzHT+DPBZYrjKMddKfMUIA3QlnAyDN\n         TlepGO5C+nngknTjOQTrBJv7ZWyot2RKSMb/GTtuIQFrPDmMNXpthVESHrZLBXG56S9f\n         5lRE0Qn1tWj5jOkA12BDiJdAdvVAVLT3QHCQt+sVLucWhrJgnotYTT+BwwhQTMPa6Ljo\n         rmmDzQI/rpV6RDFW+bPRewf4WY/Z0jiO2KbQA/e0aVzsHVdSITdYEPuwYYGkWevPiOTG\n         mVYni14z8wW/JyzHk7RPtdX/z49RXfRb8ijlsh9Mlqaq6IvHTK/0GhTM5QnDdBB0EjWO\n         518A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1774371972; x=1774976772;\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=26QADu2V5kInSwvDprX/X5k3HI6g/YNPM7XdH9A3Fig=;\n        b=NP1PfrGt510Dk9FEs0eue5YlBgTvPnjwFoPA4W/CPhTxOluP1xloMvw0bplBvkY3le\n         7yE2qnOR9qLJsawwDteO80Sc28PFj1OwlFfrjIY4uXl4iGXD+rpM6ykow6AL77ldbrg1\n         927LPPZT9DeRoRvwjnY5Bffje8eFmLlFmV1WuX0NOf1HBYTwrIyHrdpkwGgQF5PIu7qk\n         4h+DMdGV3ktUx5whScVSQL1xuX8Y/2023UvqLF7BhsHCLpBVCQzDk1I2v5xjE5PKgYGV\n         kdThE/LDuRasSB4r1ZCLlD0rOzbOU0SO3ihm2icmyRSh1zUtcV1q+yidQQu1vpQBdlW+\n         VZCg==","X-Gm-Message-State":"AOJu0Yyyclp5lUSjcgeXsJMRGZlutLktV3ygE+TEvAtVXhd8pB4A8OTw\n\t7hVyWsN4G1HXBVW3jRn4eRoRVJzcQcg0VykF6YfNLoXge2YtpwpRopdO","X-Gm-Gg":"ATEYQzxskEuwIZZ85M6cfhhg6E9+MB+YOoD2zjBExp/30YlRgxwxx4gIUtBMakenpoa\n\tXWi9G31ywTARDDPHOMIQJCHnajEeoCp8zGQZ4X+eu7J+4CxForCp2DMlTKXPMm3i4AaioT+anne\n\t/Qb/6JmQ0phjrGAe2kGWY/J3kjZxe5ipqHtEyMQWskdaUrxSI69w2hesOASNG1vo/Ju9NZr3ItN\n\tmg6Ok+GkMpJ7NMhIiF6z3f0c3QZUGdrUxN9GebqjoNeOvgE+0efZ+aVETGu0nagucEtmVw8HWdN\n\t35DDsLoHBvh7W7fl7bTX997z7+VmrvfkGYBAGg3WJgjMRjVs8YoV0Xz/qx07ROD3dN+RI//dMZg\n\twYPfEFE/XRZdlmrTJBB8YE+mdVemRLZZ6kNSfWPDVf+iwGz8qYZcdBRZvDxNrxD46TyWbNntFu3\n\tfovqT1BgIy6SJXqSblOAXLTyig7abnEpSgJQ==","X-Received":"by 2002:a05:6122:6311:b0:56c:d81a:5863 with SMTP id\n 71dfb90a1353d-56d21f7af6emr321071e0c.8.1774371971751;\n        Tue, 24 Mar 2026 10:06:11 -0700 (PDT)","From":"Sebastian Josue Alba Vives <sebasjosue84@gmail.com>","To":"gupt21@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: mcp2221: validate report size in raw_event handler","Date":"Tue, 24 Mar 2026 11:06:06 -0600","Message-ID":"<20260324170606.5407-1-sebasjosue84@gmail.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260324062403.341855-1-sebasjosue84@gmail.com>","References":"<20260324062403.341855-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":"mcp2221_raw_event() accesses the data buffer at offsets up to 55\nwithout validating the size parameter. Since __hid_input_report()\ninvokes the driver's raw_event callback before\nhid_report_raw_event() performs its own report-size validation, a\ndevice sending a truncated HID report can cause out-of-bounds heap\nreads in the kernel.\n\nThe most critical access is the memcpy from data[50] into\nmcp->adc_values (6 bytes) when CONFIG_IIO is reachable. Other\nunchecked accesses include data[20] and a memcpy at data[22].\nAdditionally, a memcpy with device-controlled length (data[3],\nup to 60 bytes) from data[4] does not verify that size is large\nenough to cover the copy.\n\nMCP2221 devices use 64-byte HID reports. Add a check at the top of\nthe handler to reject any report shorter than expected, and log a\nwarning to aid debugging.\n\nCc: stable@vger.kernel.org\nSigned-off-by: Sebastian Josue Alba Vives <sebasjosue84@gmail.com>\n---\n drivers/hid/hid-mcp2221.c | 5 +++++\n 1 file changed, 5 insertions(+)","diff":"diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c\nindex ef3b5c77c..770c305d8 100644\n--- a/drivers/hid/hid-mcp2221.c\n+++ b/drivers/hid/hid-mcp2221.c\n@@ -850,6 +850,11 @@ static int mcp2221_raw_event(struct hid_device *hdev,\n {\n \tu8 *buf;\n \tstruct mcp2221 *mcp = hid_get_drvdata(hdev);\n+\t/* MCP2221 always sends 64-byte reports */\n+\tif (size < 64) {\n+\t\thid_warn(hdev, \"report too short: %d < 64\\n\", size);\n+\t\treturn 0;\n+\t}\n \n \tswitch (data[0]) {\n \n","prefixes":["v2"]}