From: sashiko-bot@kernel.org
To: "Lee Jones" <lee@kernel.org>, linux-input@vger.kernel.org
Cc: dmitry.torokhov@gmail.com
Subject: Re: [PATCH 04/10] HID: sensor-hub: Serialise synchronous read teardown under data->lock
Date: Mon, 23 Nov 2026 16:13:18 +0000 [thread overview]
Message-ID: <sashiko-outbox-229647@kernel.org> (raw)
In-Reply-To: <20261123155138.2907049-5-lee@kernel.org>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] HID: sensor-hub: use-after-free in sensor_hub_raw_event()
[1]
--
commit 60026af9c0858d9a91fa3bec4905b88a658f6493
Author: Lee Jones <lee@kernel.org>
HID: sensor-hub: Serialise synchronous read teardown under data->lock
This commit acquires data->lock when tearing down synchronous read state
in sensor_hub_input_attr_read_values() and
sensor_hub_input_attr_get_raw_value(), and frees any prior
hsdev->pending.raw_data before allocating a new buffer in
sensor_hub_raw_event().
> diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
> index 028e70ec7bace..6aaf0df4b6dc1 100644
> --- a/drivers/hid/hid-sensor-hub.c
> +++ b/drivers/hid/hid-sensor-hub.c
[ ... ]
> @@ -625,6 +638,7 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
> }
> }
> } else {
> + kfree(hsdev->pending.raw_data);
> hsdev->pending.raw_data = kmemdup(ptr, sz, GFP_ATOMIC);
> if (hsdev->pending.raw_data)
> hsdev->pending.raw_size = sz;
[Severity: Critical]
This problem wasn't introduced by this patch, but can
sensor_hub_raw_event() race with sensor_hub_remove_callback() [1]
and trigger a use-after-free on callback?
sensor_hub_get_callback() returns callback->pcallbacks after dropping
pdata->dyn_callback_lock, while sensor_hub_remove_callback() only takes
pdata->dyn_callback_lock before freeing the entry and returning to the
client driver teardown path:
drivers/hid/hid-sensor-hub.c:sensor_hub_remove_callback() {
...
spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
list_for_each_entry(callback, &pdata->dyn_callback_list, list)
if (callback->usage_id == usage_id &&
callback->hsdev == hsdev) {
list_del(&callback->list);
kfree(callback);
break;
}
spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
...
}
If a client driver unbinds or fails probe while an incoming report is
being processed, the client driver frees its callback structure and driver
data while sensor_hub_raw_event() still holds the returned pointer:
CPU0 CPU1
sensor_hub_raw_event()
spin_lock(&pdata->lock)
callback = sensor_hub_get_callback()
sensor_hub_remove_callback()
spin_lock(&pdata->dyn_callback_lock)
list_del(&callback->list)
kfree(callback)
spin_unlock(&pdata->dyn_callback_lock)
// client driver frees callback and priv
callback->capture_sample(...)
<-- use-after-free
Acquiring pdata->lock around the removal in sensor_hub_remove_callback(),
or holding pdata->dyn_callback_lock across the callback invocations, would
serialize teardown against in-flight events.
[1] https://sashiko.dev/#/bug/linux-a1e2f25c-d273-4b88-b53e-c38049ea2d5d
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123155138.2907049-1-lee@kernel.org?part=4
next prev parent reply other threads:[~2026-11-23 16:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 15:50 [PATCH 00/10] HID: Assorted bug fixes across HID core and drivers Lee Jones
2026-11-23 15:50 ` [PATCH 01/10] HID: core: Protect hid->inputs traversal in hid_check_keys_pressed() Lee Jones
2026-11-23 15:50 ` [PATCH 02/10] HID: mcp2221: Synchronise rxbuf access against raw_event callback Lee Jones
2026-11-23 15:50 ` [PATCH 03/10] HID: logitech-hidpp: Synchronise send_receive_buf against raw events Lee Jones
2026-11-23 16:14 ` sashiko-bot
2026-11-23 15:50 ` [PATCH 04/10] HID: sensor-hub: Serialise synchronous read teardown under data->lock Lee Jones
2026-11-23 16:13 ` sashiko-bot [this message]
2026-11-23 15:50 ` [PATCH 05/10] HID: roccat: pyra: Resolve USB device from parent in actual_profile Lee Jones
2026-11-23 15:50 ` [PATCH 06/10] HID: hyperv: Validate VMBus packet and payload bounds on receive Lee Jones
2026-11-23 15:50 ` [PATCH 07/10] HID: hid-goodix-spi: Validate package sizes in goodix_hid_irq() Lee Jones
2026-11-23 15:50 ` [PATCH 08/10] HID: wacom: Stop HID hardware before releasing resources on mode change Lee Jones
2026-11-23 16:08 ` sashiko-bot
2026-11-23 15:50 ` [PATCH 09/10] HID: debug: Hold driver_input_lock while dumping raw report descriptor Lee Jones
2026-11-23 15:50 ` [PATCH 10/10] HID: playstation: Cancel DualSense output worker on create failure Lee Jones
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=sashiko-outbox-229647@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=lee@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox