From nobody Fri Oct 2 01:10:40 2026 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 6836333A03A for ; Thu, 6 Aug 2026 13:38:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786023528; cv=none; b=XHc4ocwMA9kXoKjIjnyT6/3tNoZ1dmCcVwpQ9gnb/5tFOXRdxYw7hvpHSC1kNRevRccwrnSQCkwyr9PU+WRk+yTD3yw28P7kPEoSIUftkw3mppQ25WJw2w3Um1rimzcfD84T/CGBN1fsgxrkBv1cLwpJgLhT5//3oJdLqaYawWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786023528; c=relaxed/simple; bh=SJ0CQsymO4jcDTqokRj2XeROVTcXNVQ5WcS9OVMXblk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cJqoybC8YXNRGA4tPBHe2yIygdnIrurCmPPhGIZnDzHod4GrpS/plOUe1qei3A2kqYSdBsJxEpX6hBeWOw2Oyy8ZAE5T8IuJbmnNK2PiEma3cvwv13+KUWYDao5I4CW/NgoLsaSn7FX9vfO4tH/x3Ihk6fPGunb7LyYXptU6VtA= 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=T6TMgMmH; arc=none smtp.client-ip=209.85.210.169 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="T6TMgMmH" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-84f38f3b36eso1391034b3a.1 for ; Thu, 06 Aug 2026 06:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786023526; x=1786628326; 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=n8znQjoP1MnTnyeT/KthZOHx57cQrDSiKl3hZQXMu3I=; b=T6TMgMmHyyD8gZvlgw4sAdYgo2aZk5GWe/Uuw5WBOZYDlskC4OlTN78QcGvFdhaCyf 4o/qpqW13FPKhTCa/WCcZE+lqo5iiHOtZPFdxxeBMVrSeFPLZVp/nmPSE1xlj8dAsY7S yPzbVl7kOmvfZQnXBYa9MW01NKn6CyPkuCm3fTpQQU0p3VWmtLm+IC7vMl6VlJLtRlTJ PBhKkcKfjrf0UA7AA9LQ12xkVrDNWZVKP2TthMQQxQ8p1cOB4ufUjd6tK3qme7Jy60Ut g4jwQ+4/TAl99UrY1C3eTJjtjsQjSrwav7g5Qbs/ipFWn6Ukx3lJ4nA0dT1md5yToBCw jh+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786023526; x=1786628326; 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=n8znQjoP1MnTnyeT/KthZOHx57cQrDSiKl3hZQXMu3I=; b=bYfq0F/Q5QhXzjEHJsHFS9xUhCdvqxp+78NfZiRskbEDkVYMlfvl6dQRy1uxFb6KmY G9ByvMVnznbbxQPyRm2kMWGtlryQ/fBeeeGB81uv96umONecdKzw2TOcQWGFyEnZYBZY iaQdiXiAWhlHT1Wziyn2zicywlSQr3KONMTb6xJIXsxt5mrsSwGEXNu3aG+iI7R2zorp pbW2combBEvGNQ6ZACvEq2Qq0FTzuciqQVAH24PT4iT7lry5vOnWM2iVsjrhG/dUiU76 MBgSEtZp2m9z/FdK2KHiZyskMOB7BFpEywz8O/95dE9EFTd+Pb6/Z7WnpyHDHVRfDF0r e8uQ== X-Forwarded-Encrypted: i=1; AHgh+RqPWOAVQBymtRrhme4CMWlqkjTG4/ztTgwUb06p33XyOiQQ3vZwl68+WlJ42ABiM1r33oFjBVRfMsITn8Q=@vger.kernel.org X-Gm-Message-State: AOJu0Ywyj55KHenzuvfY5BrKR6nlNN5/ZAwhITVC4wFoxoxkqWcI2rbi NBSyfcRo0y8THhLeeEdfSIgz1YNIFc2Ykw0tce4L2zdsIRPZbPzmUulX X-Gm-Gg: AR+sD13NeTFaGp9kftQMyMRXWXs+Ybn75OCescaJ6AJgzbw+xd8eKS72cFsNKdaH3Rr /3IFJktI4zKUmRW75E/YwIKRLPO4rbojGYP2R1N+HpuCioy/2lzVfMQuqET7xo5InO7yTKsXewu R+CtAZP9Di+mEGuW5vdXvI19w7x8/Y6jyI1+xCf7OA0kNBvHUejSb1VEjjxgxKTV2o+dfijHXdN DKLQNHudBFIE95qBdGOsUip4u4JU60f/dlXgdm/u2U8YAoC3Z46WPNPugyOL42GadQg1vniErG+ ydXCf5qoLF85/oLNHgq31PD6hOrAh6YFhmOkWTCSvZd5UzH93NgRi6Llu2unkGTiHgQ72R3ZKs+ 3groS1hfJatJtq5zsQr9LdHT9FXb/FhyfGBA+TBelPu/8Sc3G2ZfSnm0a10UHi9vdHDDYtJqndJ htwb2XtfSEbILmBjTN+ID4zmcxv3HowVCuae9tKhdqnbClx9FM7iKla3InuIZu7KD/H5v95A7oo f4OeU3ghnS96TWUkO4qhHThXfE7zaa0lo78HuSfJj/B3DYGdWVfpg== X-Received: by 2002:a05:6a00:8019:b0:848:4a48:9f9f with SMTP id d2e1a72fcca58-84f4fee000fmr1925189b3a.34.1786023525452; Thu, 06 Aug 2026 06:38:45 -0700 (PDT) Received: from nugod-NUC15CRHU5.tail9f095a.ts.net ([218.237.104.87]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84f453b0cfbsm1463682b3a.19.2026.08.06.06.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Aug 2026 06:38:44 -0700 (PDT) From: HyeongJun An To: Jiri Kosina , Even Xu , Xinpeng Sun Cc: Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, HyeongJun An , Sashiko AI Subject: [PATCH] HID: intel-thc-hid: intel-quickspi: bound GET_REPORT response to the caller buffer Date: Thu, 6 Aug 2026 22:38:38 +0900 Message-ID: <20260806133838.3378362-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" quickspi_hid_raw_request() receives the caller's buffer length in len, but quickspi_get_report() never sees it and copies the whole device-supplied response into buf regardless: memcpy(buf, qsdev->report_buf, qsdev->report_len); qsdev->report_len comes from the input report the touch controller returns, while buf is sized to whatever the caller asked hidraw for through HIDIOCGFEATURE or HIDIOCGINPUT. A response larger than that overflows buf with device-controlled content. The intel-quicki2c sibling already passes the caller length down to quicki2c_get_report() and validates the response against it before the copy. Do the same here. Fixes: 4138f21115ae ("HID: intel-thc-hid: intel-quickspi: Complete THC Quic= kSPI driver") Suggested-by: Sashiko AI Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-5 Signed-off-by: HyeongJun An --- drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c | 2 +- .../hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c | 9 ++++++++- .../hid/intel-thc-hid/intel-quickspi/quickspi-protocol.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c b/driv= ers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c index 91d5807b4a83..a60a0a7f16aa 100644 --- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c +++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c @@ -61,7 +61,7 @@ static int quickspi_hid_raw_request(struct hid_device *hi= d, =20 switch (reqtype) { case HID_REQ_GET_REPORT: - ret =3D quickspi_get_report(qsdev, rtype, reportnum, buf); + ret =3D quickspi_get_report(qsdev, rtype, reportnum, buf, len); break; case HID_REQ_SET_REPORT: ret =3D quickspi_set_report(qsdev, rtype, reportnum, buf, len); 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 cb19057f1191..9c4fce09729d 100644 --- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c +++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c @@ -342,7 +342,8 @@ int reset_tic(struct quickspi_device *qsdev) } =20 int quickspi_get_report(struct quickspi_device *qsdev, - u8 report_type, unsigned int report_id, void *buf) + u8 report_type, unsigned int report_id, void *buf, + u32 buf_len) { int rep_type; int ret; @@ -372,6 +373,12 @@ int quickspi_get_report(struct quickspi_device *qsdev, } qsdev->get_report_cmpl =3D false; =20 + if (qsdev->report_len > buf_len) { + dev_err_once(qsdev->dev, "Get report response too big, %u vs %u\n", + qsdev->report_len, buf_len); + return -EINVAL; + } + memcpy(buf, qsdev->report_buf, qsdev->report_len); =20 return qsdev->report_len; diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.h b= /drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.h index 775e29c1ed13..8a2338bee808 100644 --- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.h +++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.h @@ -12,7 +12,7 @@ struct quickspi_device; =20 void quickspi_handle_input_data(struct quickspi_device *qsdev, u32 buf_len= ); int quickspi_get_report(struct quickspi_device *qsdev, u8 report_type, - unsigned int report_id, void *buf); + unsigned int report_id, void *buf, u32 buf_len); int quickspi_set_report(struct quickspi_device *qsdev, u8 report_type, unsigned int report_id, void *buf, u32 buf_len); int quickspi_get_report_descriptor(struct quickspi_device *qsdev); --=20 2.43.0