All of lore.kernel.org
 help / color / mirror / Atom feed
From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: Shengzhuo Wei <me@cherr.cc>, Jiri Kosina <jikos@kernel.org>,
	Jonathan Cameron <jic23@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>,
	Bakabaka_9	 <baka9@bakabaka9.tech>
Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org,
	 linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] HID: sensor-hub: fix out-of-bounds access in sensor_hub_get_feature()
Date: Wed, 05 Aug 2026 10:00:55 -0700	[thread overview]
Message-ID: <519ed426adad9031dabe2270b27e1ef7374bcaa5.camel@linux.intel.com> (raw)
In-Reply-To: <20260806-hid-sensor-hub-oob-v1-1-f8e210e7eafe@cherr.cc>

On Thu, 2026-08-06 at 00:38 +0800, Shengzhuo Wei wrote:
> 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).
> 

There was a patch posted "PATCH v2] HID: sensor-hub: Fix out-of-bounds
write in sensor_hub_get_feature"
and I did ACK. But checked it didn't have correct CC list.

"
Fixes: 5459ada2b3cd69 ("HID: sensor-hub: Fix packing of result buffer
for feature report")
Cc: stable@kernel.org
Assisted-by: OpenAI:GPT-5.5-Cyber
Signed-off-by: Xingrui Li <baka9@bakabaka9.tech>
"

Xingrui, Please resend to all in this list here.

Thanks,
Srinivas





> Fixes: 5459ada2b3cd ("HID: sensor-hub: Fix packing of result buffer
> for feature report")
> Cc: stable@vger.kernel.org
> Signed-off-by: Shengzhuo Wei <me@cherr.cc>
> ---
>  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_device *hsdev, u32 report_id,
>  
>  	val_ptr = (u8 *)report->field[field_index]->value;
>  	for (i = 0; i < report->field[field_index]->report_count;
> ++i) {
> +		int copy = report->field[field_index]->report_size /
> 8;
> +		int src_remaining = (report->field[field_index]-
> >report_count - i) *
> +				    sizeof(__s32);
> +
>  		if (buffer_index >= ret)
>  			break;
>  
> -		memcpy(&((u8 *)buffer)[buffer_index], val_ptr,
> -		       report->field[field_index]->report_size / 8);
> +		if (copy > src_remaining)
> +			copy = src_remaining;
> +		if (copy > buffer_size - buffer_index)
> +			copy = buffer_size - buffer_index;
> +		memcpy(&((u8 *)buffer)[buffer_index], val_ptr,
> copy);
>  		val_ptr += sizeof(__s32);
>  		buffer_index += (report->field[field_index]-
> >report_size / 8);
>  	}
> 
> ---
> base-commit: bf0a94fb2b59542f9dd6fea4eec67336f1ccfa56
> change-id: 20260806-hid-sensor-hub-oob-f316fd015b76
> 
> Best regards,

      parent reply	other threads:[~2026-08-05 17:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05 16:38 [PATCH] HID: sensor-hub: fix out-of-bounds access in sensor_hub_get_feature() Shengzhuo Wei
2026-08-05 16:51 ` sashiko-bot
2026-08-05 17:00 ` srinivas pandruvada [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=519ed426adad9031dabe2270b27e1ef7374bcaa5.camel@linux.intel.com \
    --to=srinivas.pandruvada@linux.intel.com \
    --cc=baka9@bakabaka9.tech \
    --cc=bentiss@kernel.org \
    --cc=jic23@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@cherr.cc \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.