* [PATCH v1] HID: sensor-hub: synchronize multi-value read cancellation
@ 2026-09-10 11:23 Yibo Tan
2026-09-10 15:32 ` Andy Shevchenko
2026-09-10 18:28 ` srinivas pandruvada
0 siblings, 2 replies; 4+ messages in thread
From: Yibo Tan @ 2026-09-10 11:23 UTC (permalink / raw)
To: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada, Benjamin Tissoires
Cc: Zhang Lixu, Andy Shevchenko, linux-input, linux-iio, linux-kernel
sensor_hub_input_attr_read_values() publishes a caller-owned buffer to the
raw-event path. If its interruptible wait times out or is interrupted, it
clears pending.status without taking data->lock and returns.
sensor_hub_raw_event() may already have observed pending.status while
holding that lock. The caller can then release its buffer before raw-event
finishes copying into it.
Take data->lock when cancelling the request. The raw-event path now either
sees the request retired or finishes the copy before cancellation can
return.
On an uninstrumented PREEMPT_RT kernel, a valid 16-byte quaternion report
overwrote a live futex waiter's plist node with the report's 0x41 payload.
Two vulnerable runs produced the same general protection fault in
plist_del(), after 471 and 91 completed trials. The locking fix completed
two 10,000-trial runs without an Oops, panic, warning or payload signature.
The virtual provider setup and FIFO assignment require privilege. The IIO
read, signal handling and futex operations run as uid 65534 without
effective capabilities. No physical-device or normal-priority hit was
tested.
A source reproducer, kernel configuration, complete serial logs and the
vulnerable/fixed result table are available at:
https://github.com/kimaiden1984-boop/linux-kernel-poc-collections/tree/main/cases/hid-sensor-quaternion-root-a
Fixes: f784fcea4506 ("HID: sensor-hub: Add sensor_hub_input_attr_read_values() for multi-byte reads")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://lore.kernel.org/r/20260610083849.067A11F00893@smtp.kernel.org/
Cc: stable@vger.kernel.org
Assisted-by: Codex:GPT-5
Signed-off-by: Yibo Tan <lhfff@tju.edu.cn>
---
drivers/hid/hid-sensor-hub.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 6470a290ebfc..80f18aff6f1f 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -335,7 +335,9 @@ int sensor_hub_input_attr_read_values(struct hid_sensor_hub_device *hsdev,
else if (cycles < 0)
ret = cycles;
+ spin_lock_irqsave(&data->lock, flags);
hsdev->pending.status = false;
+ spin_unlock_irqrestore(&data->lock, flags);
}
mutex_unlock(hsdev->mutex_ptr);
--
2.39.5
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v1] HID: sensor-hub: synchronize multi-value read cancellation
2026-09-10 11:23 [PATCH v1] HID: sensor-hub: synchronize multi-value read cancellation Yibo Tan
@ 2026-09-10 15:32 ` Andy Shevchenko
2026-09-10 18:28 ` srinivas pandruvada
1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2026-09-10 15:32 UTC (permalink / raw)
To: Yibo Tan
Cc: Jiri Kosina, Jonathan Cameron, Srinivas Pandruvada,
Benjamin Tissoires, Zhang Lixu, linux-input, linux-iio,
linux-kernel
On Thu, Sep 10, 2026 at 07:23:38PM +0800, Yibo Tan wrote:
> sensor_hub_input_attr_read_values() publishes a caller-owned buffer to the
> raw-event path. If its interruptible wait times out or is interrupted, it
> clears pending.status without taking data->lock and returns.
>
> sensor_hub_raw_event() may already have observed pending.status while
> holding that lock. The caller can then release its buffer before raw-event
> finishes copying into it.
>
> Take data->lock when cancelling the request. The raw-event path now either
> sees the request retired or finishes the copy before cancellation can
> return.
>
> On an uninstrumented PREEMPT_RT kernel, a valid 16-byte quaternion report
> overwrote a live futex waiter's plist node with the report's 0x41 payload.
> Two vulnerable runs produced the same general protection fault in
> plist_del(), after 471 and 91 completed trials. The locking fix completed
> two 10,000-trial runs without an Oops, panic, warning or payload signature.
>
> The virtual provider setup and FIFO assignment require privilege. The IIO
> read, signal handling and futex operations run as uid 65534 without
> effective capabilities. No physical-device or normal-priority hit was
> tested.
>
> A source reproducer, kernel configuration, complete serial logs and the
> vulnerable/fixed result table are available at:
> https://github.com/kimaiden1984-boop/linux-kernel-poc-collections/tree/main/cases/hid-sensor-quaternion-root-a
Make it a Link tag and refer in the text like [1].
Link: ...$URL... [1]
> Fixes: f784fcea4506 ("HID: sensor-hub: Add sensor_hub_input_attr_read_values() for multi-byte reads")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Link: https://lore.kernel.org/r/20260610083849.067A11F00893@smtp.kernel.org/
What's this for? Make sure you have a reference in the text (see above the example).
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:GPT-5
> Signed-off-by: Yibo Tan <lhfff@tju.edu.cn>
> ---
...
> +++ b/drivers/hid/hid-sensor-hub.c
> + spin_lock_irqsave(&data->lock, flags);
> hsdev->pending.status = false;
> + spin_unlock_irqrestore(&data->lock, flags);
Seems legit. Can you also amend the kernel-doc of this lock at the top of this
file? Currently it says
* @lock: Spin lock to protect pending request structure.
I would replace the tail and make it
* @lock: Spin lock to protect struct sensor_hub_pending request data.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v1] HID: sensor-hub: synchronize multi-value read cancellation
2026-09-10 11:23 [PATCH v1] HID: sensor-hub: synchronize multi-value read cancellation Yibo Tan
2026-09-10 15:32 ` Andy Shevchenko
@ 2026-09-10 18:28 ` srinivas pandruvada
2026-09-11 5:16 ` Zhang, Lixu
1 sibling, 1 reply; 4+ messages in thread
From: srinivas pandruvada @ 2026-09-10 18:28 UTC (permalink / raw)
To: Yibo Tan, Jiri Kosina, Jonathan Cameron, Benjamin Tissoires
Cc: Zhang Lixu, Andy Shevchenko, linux-input, linux-iio, linux-kernel
On Thu, 2026-09-10 at 19:23 +0800, Yibo Tan wrote:
> sensor_hub_input_attr_read_values() publishes a caller-owned buffer
> to the
> raw-event path. If its interruptible wait times out or is
> interrupted, it
> clears pending.status without taking data->lock and returns.
>
Hi Lixu,
Please give me quick test. Change itself looks good, not sure if we
need something more.
Thanks,
Srinivas
> sensor_hub_raw_event() may already have observed pending.status while
> holding that lock. The caller can then release its buffer before raw-
> event
> finishes copying into it.
>
> Take data->lock when cancelling the request. The raw-event path now
> either
> sees the request retired or finishes the copy before cancellation can
> return.
>
> On an uninstrumented PREEMPT_RT kernel, a valid 16-byte quaternion
> report
> overwrote a live futex waiter's plist node with the report's 0x41
> payload.
> Two vulnerable runs produced the same general protection fault in
> plist_del(), after 471 and 91 completed trials. The locking fix
> completed
> two 10,000-trial runs without an Oops, panic, warning or payload
> signature.
>
> The virtual provider setup and FIFO assignment require privilege. The
> IIO
> read, signal handling and futex operations run as uid 65534 without
> effective capabilities. No physical-device or normal-priority hit was
> tested.
>
> A source reproducer, kernel configuration, complete serial logs and
> the
> vulnerable/fixed result table are available at:
>
> https://github.com/kimaiden1984-boop/linux-kernel-poc-collections/tree/main/cases/hid-sensor-quaternion-root-a
>
> Fixes: f784fcea4506 ("HID: sensor-hub: Add
> sensor_hub_input_attr_read_values() for multi-byte reads")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Link:
> https://lore.kernel.org/r/20260610083849.067A11F00893@smtp.kernel.org/
> Cc: stable@vger.kernel.org
> Assisted-by: Codex:GPT-5
> Signed-off-by: Yibo Tan <lhfff@tju.edu.cn>
> ---
> drivers/hid/hid-sensor-hub.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-
> hub.c
> index 6470a290ebfc..80f18aff6f1f 100644
> --- a/drivers/hid/hid-sensor-hub.c
> +++ b/drivers/hid/hid-sensor-hub.c
> @@ -335,7 +335,9 @@ int sensor_hub_input_attr_read_values(struct
> hid_sensor_hub_device *hsdev,
> else if (cycles < 0)
> ret = cycles;
>
> + spin_lock_irqsave(&data->lock, flags);
> hsdev->pending.status = false;
> + spin_unlock_irqrestore(&data->lock, flags);
> }
> mutex_unlock(hsdev->mutex_ptr);
>
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH v1] HID: sensor-hub: synchronize multi-value read cancellation
2026-09-10 18:28 ` srinivas pandruvada
@ 2026-09-11 5:16 ` Zhang, Lixu
0 siblings, 0 replies; 4+ messages in thread
From: Zhang, Lixu @ 2026-09-11 5:16 UTC (permalink / raw)
To: srinivas pandruvada, Yibo Tan, Jiri Kosina, Jonathan Cameron,
Benjamin Tissoires
Cc: Shevchenko, Andriy, linux-input, linux-iio, linux-kernel
>-----Original Message-----
>From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
>Sent: Friday, September 11, 2026 2:29 AM
>To: Yibo Tan <lhfff@tju.edu.cn>; Jiri Kosina <jikos@kernel.org>; Jonathan
>Cameron <jic23@kernel.org>; Benjamin Tissoires <bentiss@kernel.org>
>Cc: Zhang, Lixu <lixu.zhang@intel.com>; Shevchenko, Andriy
><andriy.shevchenko@intel.com>; linux-input@vger.kernel.org; linux-
>iio@vger.kernel.org; linux-kernel@vger.kernel.org
>Subject: Re: [PATCH v1] HID: sensor-hub: synchronize multi-value read
>cancellation
>
>On Thu, 2026-09-10 at 19:23 +0800, Yibo Tan wrote:
>> sensor_hub_input_attr_read_values() publishes a caller-owned buffer to
>> the raw-event path. If its interruptible wait times out or is
>> interrupted, it clears pending.status without taking data->lock and
>> returns.
>>
>
>Hi Lixu,
>
>Please give me quick test. Change itself looks good, not sure if we need
>something more.
Hi Srinivas,
The machine is currently running other tests. Once they are done next week, I will run a quick test on this change and get back to you with feedback.
Thanks,
Lixu
>
>Thanks,
>Srinivas
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-11 5:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-10 11:23 [PATCH v1] HID: sensor-hub: synchronize multi-value read cancellation Yibo Tan
2026-09-10 15:32 ` Andy Shevchenko
2026-09-10 18:28 ` srinivas pandruvada
2026-09-11 5:16 ` Zhang, Lixu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®