From nobody Fri Oct 2 02:34:39 2026 Received: from va-2-58.ptr.blmpb.com (va-2-58.ptr.blmpb.com [209.127.231.58]) (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 94B14483BF2 for ; Wed, 5 Aug 2026 16:38:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.231.58 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785947929; cv=none; b=F4ZSE8WNm9T6j5Y4jB8mr8obg3IxiDr6sj8Pfu1QHQbNa9vvbsgM1CopLzCoI3OMivpbmBevhk/vNVcM2qOOcoxr2sLeO/gJTENgnJUVN1J1Uf/vknEyQOUpVk+EkIOuv39ZAzzBfZDJzJ3jpXSBe2G0bpw+XBWiA+XPeQ0Jsso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785947929; c=relaxed/simple; bh=1eaZjSyQiauYjPvavxFDl1LvGdOwtRGiMfDerN/NcNc=; h=Date:Mime-Version:To:From:Subject:Message-Id:Content-Type:Cc; b=U4xT+HI1vEUByzvUnM/8o9bDAKoI99C7bZj9DmfD+PJs488ijN+BPBsUztNwKgh6cILRsqA7NDvcicTJLpahziHaF4o1cDV6N+RphjJiNIRKOuQSNoj+BU4NLhWp53genCXIzQpmumJ7+f3IoSyI/gaCLiYstpxirZwF3wjnYY4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cherr.cc; spf=pass smtp.mailfrom=cherr.cc; dkim=pass (2048-bit key) header.d=cherr.cc header.i=@cherr.cc header.b=VZImHwDo; arc=none smtp.client-ip=209.127.231.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cherr.cc Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cherr.cc Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cherr.cc header.i=@cherr.cc header.b="VZImHwDo" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2604220257; d=cherr.cc; t=1785947916; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=LnsE1iNZiHSw8OO+Ugls5I5U6nYU7LBTDmRHK5suJ3U=; b=VZImHwDo0JalED+kG++QnWTV07wV81cfVk+C7p3gAVIg6XB6+fLvsdOKfQcn7dQ/HFb9gp /ivk5pibGare/KttFMfhNCqLlpzAtRAPOQiCfEDeMuXpPS3WxxGNVTJRnepA3VgCIeCbms jV/h+x9Htne7h5CRD/ukPQ+Dia7niPhluK2R3T1KPFHibDDSc/vhuDPgtlYkF9w3oaKm0Y bAg9JzStRHaMGRk8BQNBhv7KypOyj9rAJHYs7LhzcGgwhA7sliOssHmRnX8I9/adTuZSdD DXBzhBqKFiwFqwkn+UZXgrtqo5ygp4f6+OI6hZ0ybT/bpLPE5y0bX0zfVNdXqA== Date: Thu, 06 Aug 2026 00:38:19 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Received: from [192.168.9.107] ([111.40.58.243]) by smtp.feishu.cn with ESMTPS; Thu, 06 Aug 2026 00:38:33 +0800 To: "Jiri Kosina" , "Jonathan Cameron" , "Srinivas Pandruvada" , "Benjamin Tissoires" From: "Shengzhuo Wei" Subject: [PATCH] HID: sensor-hub: fix out-of-bounds access in sensor_hub_get_feature() Message-Id: <20260806-hid-sensor-hub-oob-v1-1-f8e210e7eafe@cherr.cc> X-Change-Id: 20260806-hid-sensor-hub-oob-f316fd015b76 Content-Transfer-Encoding: quoted-printable X-Mailer: b4 0.14.2 X-Original-From: Shengzhuo Wei Cc: , , , , "Shengzhuo Wei" X-B4-Tracking: v=1; b=H4sIAPpmc2oC/x3MQQqAIBBA0avErBvQIouuEi0yx5yNhkMRSHdPW r7F/wWEMpPA3BTIdLNwihW6bWAPWzwI2VVDpzqjJmUwsEOhKCljuCymZNH32nin9GBHAzU8M3l +/umyvu8HR4BHdWQAAAA= X-Lms-Return-Path: Content-Type: text/plain; charset="utf-8" sensor_hub_get_feature() copies each field value with memcpy(..., report->field[...]->report_size / 8), a size taken only from the descriptor and bounded neither to the caller buffer nor to the field->value[] array. When report_size exceeds the remaining buffer (e.g. a 64-bit power-state field into a 4-byte int) the copy overflows the caller's stack on the first iteration; when report_size > 32 it also reads past field->value[] (one __s32 per logical value) into slab, leaking bytes to userspace via callers that expose the buffer (hid-sensor-custom show_value over sysfs). Reachable from an untrusted USB or Bluetooth HID device with no local privileges. Bound the per-iteration copy to min(report_size/8, (report_count-i)*sizeof(__s32), buffer_size - buffer_index). Fixes: 5459ada2b3cd ("HID: sensor-hub: Fix packing of result buffer for fea= ture report") Cc: stable@vger.kernel.org Signed-off-by: Shengzhuo Wei --- drivers/hid/hid-sensor-hub.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 34f710c465b80a0c46cc207e3d99a07c5767f291..978335db71b09617c87e879911b= 8e75b6bfdebb8 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -270,11 +270,18 @@ int sensor_hub_get_feature(struct hid_sensor_hub_devi= ce *hsdev, u32 report_id, =20 val_ptr =3D (u8 *)report->field[field_index]->value; for (i =3D 0; i < report->field[field_index]->report_count; ++i) { + int copy =3D report->field[field_index]->report_size / 8; + int src_remaining =3D (report->field[field_index]->report_count - i) * + sizeof(__s32); + if (buffer_index >=3D ret) break; =20 - memcpy(&((u8 *)buffer)[buffer_index], val_ptr, - report->field[field_index]->report_size / 8); + if (copy > src_remaining) + copy =3D src_remaining; + if (copy > buffer_size - buffer_index) + copy =3D buffer_size - buffer_index; + memcpy(&((u8 *)buffer)[buffer_index], val_ptr, copy); val_ptr +=3D sizeof(__s32); buffer_index +=3D (report->field[field_index]->report_size / 8); } --- base-commit: bf0a94fb2b59542f9dd6fea4eec67336f1ccfa56 change-id: 20260806-hid-sensor-hub-oob-f316fd015b76 Best regards, --=20 Shengzhuo Wei