From nobody Mon Sep 28 11:39:38 2026 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D52C49363B for ; Sat, 22 Aug 2026 12:45:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787402740; cv=none; b=EZTEPaC+vhq5aKbYwQTvQX8kGyxkhsUaSMlQOcmIunax5autlERv9dquijLWIjwQEimSkkurU1MfglmpKYaM8Jea3wTRgiWwyDkSoK5X2u6kcOQdm9q1y9Ja2OSSqIuEXQT3iAFzYLPf78FVHDsJ/dGPBc/qRlqR6ETZ+bz7awc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787402740; c=relaxed/simple; bh=LZJbmfQ2dqHw1iRvUikp1f1wAvVzItuWaTYQMuOX9hM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rKMgoyXzhnO74vlyYXvR8dXB9O8pAJ/jAWxy3vrMNAmy7FitXbe16wm8K7JI77g+GPMMou9TcUkPW1OkmJGFUPs/N0iJU2wnCGSkt6gM5vLpLIhhmT4YyphPEMx7aHph3H45qdowmgKdfaEI+4tU0Ve8Bxw5dIdfuCLyb3NDPcQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rzTQ5df+; arc=none smtp.client-ip=209.85.215.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rzTQ5df+" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-cbb8b54fcf8so1975028a12.0 for ; Sat, 22 Aug 2026 05:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787402739; x=1788007539; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=3hf5OrcpcITaT5sgCq/QOiAck55Lc6nxzm/MZWxuqlc=; b=rzTQ5df+EUmDslXEGTlCOEYA8vfXMt1hTx3w5TcS7zVvoJBVTjlYH2ALDYMl6+v4Q3 nEWqhgSlGN3G6vGSH0r0tjXWoyYmdMMtFnjMk5XAMRxvPaTvOvgl3rbzEWp0aUCOJlTb jcypzL66ph+hYTmdnfGwkDQtr1zTIlHw6Mx+U6qwUo4bMZLPB5E9jrilCbCTAIsYX0as zHFmFfk/Y3Ucy3+sERw66iOsa/qX1KwKHHvgyN5I6n6itt0RhguuPSuR0zPylc3fGElE 9F1K6s2KIIxoWJsnZINMnYffa6CmMPs0oHMaRKcqQPYq7Al0jgdx9I7Mobr6TD7ZiTkV dPnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787402739; x=1788007539; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3hf5OrcpcITaT5sgCq/QOiAck55Lc6nxzm/MZWxuqlc=; b=azfPxfNlq+QlLXzp6JGnJ1Sm5bhGpbjRkZgY4gdbop1thD1dZwWwDlWZmV+KXTvIfQ SOqCgMrONTBK3CiF1xoxRgt9ghREgu8wWaaF4zDExbTLLMu2eu42gwk0I4vEmBUnDyS4 05MenItTjTwPS8EpAHUaMbrBm1jRBo0XtPRX5hUaabijucnP+/BjJXKKtbdzwtvEiUEX KfB+N+9Nd6YyOGAncxqDwqGvJPr2pkKZp0c0RBHwnJagCr81myeqYoUpmOLyZ6rC5DNw Iimc4vbJtq/VPZuiE+9SUUddTkyFz2Xe7uWewHvMygHPC1EopnjvxYL9y5Amg++YxeYt jkfw== X-Forwarded-Encrypted: i=1; AHgh+Ro/yVNup5imUloBCVU+r4tWVrHTFsnH518LiKwZqK31OrelKTrikwcgIOq4Ow2wKuKaUQc2tGNMT0IF9e8=@vger.kernel.org X-Gm-Message-State: AFuF++nCt9H4i6eN4fNYcrdlybpNx9HoF5df2lO0jzmS8uSCssmpWr5F 9QMFIOMk8d7vW2h+n46fQ1FCSJ1kz45t1kZJnyf8tCglsbi3GwdzsRtD6xBOeHQi X-Gm-Gg: AR+sD12ulylipNHFBjiOTWFmfL8huy/BtXcY15jUTfvIC/BvbztosA2ls+GfLyjXhAs 4iUHkz8VKWNmWvOiSoniuLjeuJUHJA3+ZNQ6ke08yGvv43AgURlgxeVilW/uz+U5Ha09tGaNioq MKS3mhqTw+CE82QU83iBusSotN42uUsT1HsQQlSVYemDESn0AelBRVQEE+1sGVKBvo4m0sjHDGD /PzQqZ4oPHWJ07FwIhzHfN0SMbS30RZDabeKeBF5x1k4Z9GVITttz7T8vRcrtUVOCVMFmGfZmF/ pNcjvSJEgfIcBHuW5a7ccgNFoTxyIi4u+46leTxyZmiqqM57mxTqsygZC3bOk/XTWZXoIUbemfV 5MzKYmx+wkdQ7VN0PeXYAEYnAs9T2HUTCLWmPfrIpQzprQmEyziIDwMjbQFIu0NgGiwibeNjvUv o4rYa9ha0zmXfhFeulgI8mQ0BH3EkJZekWRYZq+wzKT8l6vf4UBkgL99D/cL/I0atMuQ3ga0QhB b3drDgTam0TQEmPXoqZwG7GxiKzjhdLwQtqpIPOEoJYZBXepYzv6A== X-Received: by 2002:a05:6a21:1583:b0:3c4:511e:26ab with SMTP id adf61e73a8af0-3cd2fdb9115mr25629725637.3.1787402738686; Sat, 22 Aug 2026 05:45:38 -0700 (PDT) Received: from nugod-NUC15CRHU5.tail9f095a.ts.net ([218.237.104.87]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cc15523489fsm3842078a12.5.2026.08.22.05.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Aug 2026 05:45:38 -0700 (PDT) From: HyeongJun An To: Even Xu , Xinpeng Sun , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, HyeongJun An Subject: [PATCH] HID: intel-thc-hid: intel-quicki2c: size the input buffer for the DMA Date: Sat, 22 Aug 2026 21:45:31 +0900 Message-ID: <20260822124531.644834-1-sammiee5311@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" quicki2c_alloc_report_buf() sizes input_buf as max(max_input_len, SZ_4K), but two channels deliver into it and dma_set_max_packet_size() rounds both up: RxDMA2 to ALIGN(max_input_len, SZ_4K) and SWDMA to ALIGN(max(max_input_len, report_desc_len), SZ_4K). read_dma_buffer() bounds the copy against those, not against the allocation. quicki2c_get_report() reads into input_buf with prd_tbl_len NULL, so nothing programs a length, and a device declaring report_desc_len 5000 with max_input_len 64 overruns the 4K buffer by 4096 bytes. The RxDMA2 leg additionally needs the I2C max input size clamp to be off. Size input_buf from the SWDMA packet size and keep the 4K floor. Fixes: 66b59bfce6d9 ("HID: intel-thc-hid: intel-quicki2c: Complete THC Quic= kI2C driver") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-5 Signed-off-by: HyeongJun An --- Not reproduced on hardware. Triggering it needs a controller that sends more than the lengths it declared, which is the case the existing comment was already written for. max_report_len is reused for the report_buf allocation below, so that buffer and qcdev->report_len grow with input_buf whenever the SWDMA ceiling is the larger term. Both stay bounded by that ceiling. drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c b/driv= ers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c index 0d2ad7bc3648..f6f9f95296d3 100644 --- a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c +++ b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c @@ -602,9 +602,12 @@ static int quicki2c_alloc_report_buf(struct quicki2c_d= evice *qcdev) =20 /* * Some HIDI2C devices don't declare input/output max length correctly, - * give default 4K buffer to avoid DMA buffer overrun. + * give default 4K buffer to avoid DMA buffer overrun. Both RxDMA2 and + * SWDMA land here, so cover the larger SWDMA packet size. */ - max_report_len =3D max(le16_to_cpu(qcdev->dev_desc.max_input_len), SZ_4K); + max_report_len =3D max(le16_to_cpu(qcdev->dev_desc.max_input_len), + le16_to_cpu(qcdev->dev_desc.report_desc_len)); + max_report_len =3D max_t(size_t, ALIGN(max_report_len, SZ_4K), SZ_4K); =20 qcdev->input_buf =3D devm_kzalloc(qcdev->dev, max_report_len, GFP_KERNEL); if (!qcdev->input_buf) --=20 2.43.0