From nobody Mon Sep 28 16:21:51 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.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 767BE41F7FD for ; Thu, 20 Aug 2026 11:16:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787224574; cv=none; b=qjRHouR+8BtIOq/LHtSytfpDQd87livzSIEgFHlHnqUrDr+EKKCK9L5+LfqhXJhBngVpEgoPgjMKjn2rlyccln+f8oWxeYd4AMoLgDMueQpb8nDtBF2p3d4ETVVBIUnx2IHUXXHHXgbb4s8tcBYXpSk9UZG5lxqJ8CLbzlMtz+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787224574; c=relaxed/simple; bh=rHwP4XfA9jRj+RHRKEKyTJXOCcW4DcDGXwa8aSdNjkQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EWUBr5PmIOEP+/h1jXxcjbIv4aML+3IaPP5fQgEpp8JyJOFY+3PXBpMc0GWdDzhcMCTk/xkDZ++jrJaf3sgvyK3Zm90ZTA6i8Biqi47j9NoSTX0ar2pRrIwUQcoaIDPaeY27D2nudLGulb6m/YhxQDO+1CEYO7bztgAQjcsPe2M= 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=K74blQIr; arc=none smtp.client-ip=209.85.210.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="K74blQIr" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-8486ac3f347so628163b3a.1 for ; Thu, 20 Aug 2026 04:16:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787224573; x=1787829373; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aUdHCBJZOHM/va9FiVML/hn1mg9LRuKeIIYVF8glt60=; b=K74blQIrSh/UssZZ78uXjrRKNv6N4HumxwusJgVzth8os3kIaWSSK6acGE4r5pvzJe vwP0p/vTY/pSabEANau6VfbXMCkAgLIgTVCE3aaUOwmwDP/qQAAQj5Ml9X7/scGUOsCj q880YiiRqOo5sS4mKU/2tHf7neZJgSfBiS5mfrFT/sdQ/Eo6d7RrrdJ4WnvvzqZS2K0r JSSEBHzuD08UXA2FqXVZIdgX7GcrKlL2QuPsXBcxYCKWKVgot0zpHxRIIgf1oWyR7WNd a7mQE3QWSO/K3dQ7lXR4yv/c0gVtrYqUdqzz+0oUaHc6Ym7Vfjo38ZMhRXN5VTTId5q8 G9mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787224573; x=1787829373; h=content-transfer-encoding:mime-version:references:in-reply-to :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=aUdHCBJZOHM/va9FiVML/hn1mg9LRuKeIIYVF8glt60=; b=kPIm/Vx/S5ZcbuIBuuobB9vo+XmN0qJpxoUOgDmSnWHQvi4q1d4V9NJlW1rRquZ/au v7KLpRpS6QbjA7+4dRXD8RdV3Q484G2M5ZXUjk4ruyG+Oo2zV2nFbPOatG8lsSuRE+DQ /CQJ44dNKEY4AUihCGTaNvf9VGYn/Ij1MlhD9Rmfeq+NcrSezz/+9aDOyxnL54nwV9fl mADqpe0Qb+3lC4ZSBwfzQ4j0z04bjME3Ii1+2Yy8+VqOjM+wsFLUnWfIG0FJ7YyR5f37 fALUTQRyMrdzOziaILP1UmmpxVldL5UyKbL+mqztl94rqYKj1/zhoYoFY1tCdMsLLDzY XOFA== X-Forwarded-Encrypted: i=1; AHgh+RqqOGEjg1zKz3toIWWOimWn9cdHeQxYQdYWvTDFzopLCIViensC3yvcDuJxHXl3swYtXk4ie9hbUK1lwwk=@vger.kernel.org X-Gm-Message-State: AOJu0YwfqroBCmCmWewcqT4qpwgzQ4O9o9xqGydMOqhwK3VFXRxAL58v 7lWrMMo5CqWk04cQdbG7QRkY5KD4fnnyssF3CuWVULIixekUKaHQJif8 X-Gm-Gg: AR+sD12jBnuGE9MuK7h5bx+kY09ET5QcBrIa6O2U2kKt6dsdqXaXeUDUrSFS4axx1EB 7ftDcSLln1oAfiA38Xl4pVBItG2u4UiPBlodhgqyKGxrjNd5aF3thaWpa8A31WT8iN1uqQu/d5Y 8UVcxIuKUrHBkphd+r7oJCix83+sl5qz2S+QPiDem9XA6lGNyqXeAl2D8P6UVIUnAKV5Pqml4yK Ob9k1WykApWmjQbCry+wifGhydh5Fa/ZAaBroyVpvRZ1hecupxEggB1+9Wc6tGrlu7GN6TyYPoF HGGd6n2XOWbL7aozmaWJTkfYDn5AtnNiJeDUW5huAdw7zfKH1ynaBnUL0qMQdUWNnx4yhGWovc7 pW4nxEEgS1dKy8G06BO+7YXSHZlPWlq92PHld+hOrlRAbi1ICQ1wicwZL9TmVD5/tRCJ567kFx+ NfRUFJKPV13dSxuQZAgVgazdxh5sGMphjq+WlAeqZhy20NZkV0Ajd+U6Rrrbs1KhS0yz7vlbmwl Kx3UFI1bs0PFyEmWv1sCSR70t803TaDp/UVYPurMog6HrkOpAkmJBQ06L8/xA3Q X-Received: by 2002:a05:6a21:6f11:b0:39b:bc11:9ec5 with SMTP id adf61e73a8af0-3cd14faf56emr7432453637.13.1787224572709; Thu, 20 Aug 2026 04:16:12 -0700 (PDT) Received: from nugod-NUC15CRHU5.tail9f095a.ts.net ([218.237.104.87]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cc15cada6fesm1236455a12.27.2026.08.20.04.16.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2026 04:16:11 -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 1/2] HID: intel-thc-hid: intel-quickspi: size the input buffer for the DMA Date: Thu, 20 Aug 2026 20:15:57 +0900 Message-ID: <20260820111558.475304-2-sammiee5311@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820111558.475304-1-sammiee5311@gmail.com> References: <20260820111558.475304-1-sammiee5311@gmail.com> 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" quickspi_alloc_report_buf() sizes input_buf from max_input_len, but the RXDMA2 channel it feeds is programmed with ALIGN(max_input_len, SZ_4K): quickspi_dma_init() passes the raw value and dma_set_max_packet_size() rounds it up. setup_dma_buffers() maps that rounded size and read_dma_buffer() bounds the message against it, so a controller reporting max_input_len 64 and rep_desc_len 600 gets a 600 byte buffer behind a 4096 byte DMA. thc_rxdma_read() has no capacity argument, so nothing downstream can catch it. The intel-quicki2c sibling floors its input buffer at SZ_4K for this reason, with the comment "give default 4K buffer to avoid DMA buffer overrun". Round up the same way the DMA does. Fixes: 4138f21115ae ("HID: intel-thc-hid: intel-quickspi: Complete THC Quic= kSPI driver") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-5 Signed-off-by: HyeongJun An --- drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c b/driv= ers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c index 89226f5ce45e..9ef33574c202 100644 --- a/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c +++ b/drivers/hid/intel-thc-hid/intel-quickspi/pci-quickspi.c @@ -9,6 +9,7 @@ #include #include #include +#include #include =20 #include @@ -549,8 +550,12 @@ static int quickspi_alloc_report_buf(struct quickspi_d= evice *qsdev) if (!qsdev->report_descriptor) return -ENOMEM; =20 - max_input_len =3D max(le16_to_cpu(qsdev->dev_desc.rep_desc_len), - le16_to_cpu(qsdev->dev_desc.max_input_len)); + /* + * thc_dma_set_max_packet_sizes() rounds the RXDMA2 packet size up to + * 4K, so the DMA can hand back more than max_input_len bytes. + */ + max_input_len =3D max_t(size_t, le16_to_cpu(qsdev->dev_desc.rep_desc_len), + ALIGN(le16_to_cpu(qsdev->dev_desc.max_input_len), SZ_4K)); =20 qsdev->input_buf =3D devm_kzalloc(qsdev->dev, max_input_len, GFP_KERNEL); if (!qsdev->input_buf) --=20 2.43.0 From nobody Mon Sep 28 16:21:51 2026 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 43A6F421236 for ; Thu, 20 Aug 2026 11:16:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787224579; cv=none; b=AsSl+op+DARMVl5VrKJdZ1HmSt+PVWEJVmO7J90YjpMZ+y5xh4oM0Us5sggmoAaeDGyWUZ2eZT36aS8MTuIjyWWfPv8xBuNOrgQhpCGEocqT2oaDMtVVUuZ5h9YA/6AOWlISB/c0Ozuoo/B+rDCiSVhswTigxjfgioKV2L8yY/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787224579; c=relaxed/simple; bh=vO0izHD2f1ofrT6G0UqWkyQBcgoDbMLoEZdWgvw592E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JAGpIhBkat664KWJTVm7rTc+R+emfArijBNUHQOHjPyHv7hThQTtyQiHQcq9o/oSold7z+FO4E/jIx5oMBrHBTdpMUx7taWYZGHYzIP1cDC1O4NU1Mzfag+C0SO8vpEr0H0gHFcyvOuP8gPBC7iUs4+VaVeLsmloXLKlVDn7KYw= 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=RdwBoTS+; arc=none smtp.client-ip=209.85.210.173 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="RdwBoTS+" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-8486ac3f347so628209b3a.1 for ; Thu, 20 Aug 2026 04:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787224578; x=1787829378; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xmFjaomKOSQJ0x9BcEAzGij2qfGuvuK5f2g46VdQqOU=; b=RdwBoTS+PBqktKaMXyAE0n7knUQGLTqRAbZJrSyvMR1n01dqwiWdJ/lyDXMQKyMwj3 SdtETFoCpeqLKNCDoc+TC4sdQRzevmwYi98T1wjOA1DFCXrG7ArmBioHfZStTj9OT2Kb r6IR9NRorpuThsnJvkDocdqtYp9zhm6qHzMIyHdAZgJ6ZQGePlnBLIy4xJM7ji+2MnDq ZMruzVRDRkpOhKmvzKXEGfsB5tZYm56Mo5n5TYmG+cNeKIeiYRwpChg611UiyFI2h3PP fkNXCll3Ut7WttNd4pCIeqqt+LjGR9fgLClBlPmA9/eLCgFPx4lH/zQFVmbXz7OYHXUO lXhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787224578; x=1787829378; h=content-transfer-encoding:mime-version:references:in-reply-to :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=xmFjaomKOSQJ0x9BcEAzGij2qfGuvuK5f2g46VdQqOU=; b=FvLzOwPXT4VAkkv73/9PbQ+BahKOA46Co8X45Lc6rfzAZxCLLlB2WPIV7wlsctQQlg twOP4TGivhKVtFdzQV7OQYCVWGlBdGwTevMPcsAwT4jGxkMiB+pTJGtDovYdXxsnTCuv vSeR4nEGs1xwBBnzhjoVvlhX+jj5Yd3gWRabC6vdz/94v2Cpj4ljtK1umoUloC/n3/og eddVuuofHjpRQ1Mflin+M1w6sSOWOJqeZ4sxbNuX0gtRQ+tJ7BajygeEqZQdlGNdYOuT brR3SUz9yRSvQJt6uGoeZPi4eP6vFrbMI9NRRFPTNUZgVkQYiUvIV4GPt5lQ6FOQKCyd EJMQ== X-Forwarded-Encrypted: i=1; AHgh+RrQt7yiEyHWUQjRM69qQjRY8ZVUBN65p6oDfd0S4g9lKeCdR8vbXFMcz0PbaodHluQFTOX4yPvZZnrFsJc=@vger.kernel.org X-Gm-Message-State: AOJu0YyXLpYizzJR3F4cqZyEoaAQF/ts+C5bPk/3SOfx2N3kg5QZQT9W 4PL8u3ooRjo0WJEtUQO4nLqpzdExs+CUc/+bnjwY/RhncfS3MlzWnGGK X-Gm-Gg: AR+sD10sdTS4Jzo9NsoXw36TQsTlfkt5vjADqD8HR16MhWK3O4oefSPv6c9pBhCcD1y dewaXYvqx+JaRGBWdYN4Lz+TdyS0R/C1E5XFawLM+kxLsoi3uEvEB8PeDI3apwPDvMImxvyJid4 I7e6ALwsxoIS6H9erUz+rnXa/8q/6DbtuUhElB0y3uTxcKAfEeqEHO+nbAfihO2DGZWRpo+pk79 RENHgmtwDK9mGAO0ZjVeA/MYe2OjXA/yqWhwsHpN0+1+Azr0NgdCcvbzdROct7X4MrxmCinr6Ev J/uPjBY/AbV6hF9qBLGOx0WqPFnba6g/O3ZeOcuUCR1aQdLqYfiX0k94GQYlGi1sScNTHzvz7yt 8GamCuZmlyfQ4Esg6X+ywV4mqqT0jBMNaxYx+r9cdZNEHinyLmhxH9rjzpKEyJVRLOhOheYGneo XxtylSWevg/xrthzpWyxpL1I9noNOBJsa0zDOTw0v4n8azU7RaeXQC8IyCa061An8CBnLQwNWMB K5sc+sC88Sutuu5wLFica1Tzb0zJdNAb2/62+5dAwQQcXOLBXd/GjQBRKErCwN/ X-Received: by 2002:a05:6372:a70f:b0:3cb:b6b0:1b83 with SMTP id adf61e73a8af0-3cd14f251acmr5785817637.9.1787224577549; Thu, 20 Aug 2026 04:16:17 -0700 (PDT) Received: from nugod-NUC15CRHU5.tail9f095a.ts.net ([218.237.104.87]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cc15cada6fesm1236455a12.27.2026.08.20.04.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2026 04:16:16 -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 2/2] HID: intel-thc-hid: intel-quickspi: bound the GET REPORT response to report_buf Date: Thu, 20 Aug 2026 20:15:58 +0900 Message-ID: <20260820111558.475304-3-sammiee5311@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260820111558.475304-1-sammiee5311@gmail.com> References: <20260820111558.475304-1-sammiee5311@gmail.com> 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" quickspi_handle_input_data() copies a GET_FEATURE or GET_INPUT_REPORT response into qsdev->report_buf using a length the controller supplied. The only check it passes is against buf_len, the number of bytes the DMA delivered, which says nothing about the destination. report_buf holds HIDSPI_OUTPUT_REPORT_SIZE(max(max_output_len, max_input_len)), 68 bytes for a controller reporting 64 for both, while the copy is bounded only by the 4K DMA packet. The REPORT_DESCRIPTOR_RESPONSE case a few lines up validates against the size of its own destination. Do the same here and let the waiter in quickspi_get_report() time out, as the other malformed-frame checks do. Fixes: 9d8d51735a3a ("HID: intel-thc-hid: intel-quickspi: Add HIDSPI protoc= ol implementation") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-5 Signed-off-by: HyeongJun An Reviewed-by: Even Xu --- This needs commit a59cf84441f9 ("HID: intel-thc-hid: intel-quickspi: validate report size before copy") for qsdev->report_buf_size, which is in hid.git for-next but not mainline yet. Same Fixes: tag, so a stable backport wants the two in that order. .../intel-thc-hid/intel-quickspi/quickspi-protocol.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c b= /drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c index 847c5ec55569..7d34cc22a11a 100644 --- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c +++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c @@ -161,6 +161,7 @@ void quickspi_handle_input_data(struct quickspi_device = *qsdev, u32 buf_len) struct input_report_body *input_body; u8 *input_report; u32 input_len; + u32 report_len; int ret =3D 0; =20 input_body =3D (struct input_report_body *)qsdev->input_buf; @@ -210,10 +211,17 @@ void quickspi_handle_input_data(struct quickspi_devic= e *qsdev, u32 buf_len) =20 case GET_FEATURE_RESPONSE: case GET_INPUT_REPORT_RESPONSE: - qsdev->report_len =3D sizeof(body_hdr->content_id) + input_len; + report_len =3D sizeof(body_hdr->content_id) + input_len; + if (report_len > qsdev->report_buf_size) { + dev_err_once(qsdev->dev, "Get report response too big: %u\n", + report_len); + return; + } + + qsdev->report_len =3D report_len; input_report =3D input_body->content - sizeof(body_hdr->content_id); =20 - memcpy(qsdev->report_buf, input_report, qsdev->report_len); + memcpy(qsdev->report_buf, input_report, report_len); =20 qsdev->get_report_cmpl =3D true; wake_up_interruptible(&qsdev->get_report_cmpl_wq); --=20 2.43.0