From: sashiko-bot@kernel.org
To: "Sanjay Chitroda" <sanjayembeddedse@gmail.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v5 13/13] iio: pressure: hid-sensor-press: convert probe and teardown to devm-managed resources
Date: Thu, 06 Aug 2026 12:44:25 +0000 [thread overview]
Message-ID: <20260806124426.B2FFE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806-28-apr-iio-redundant-argument-v5-temp-v5-13-f1f92c1d830f@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Concurrency UAF during device unbind between `sensor_hub_raw_event` and `sensor_hub_remove_callback`.
--
--- Patch [13]: [PATCH v5 13/13] iio: pressure: hid-sensor-press: convert probe and teardown to devm-managed resources ---
commit 45fb35e2b8f4da70b5748e13b1091b8fdbd11a47
Author: Sanjay Chitroda <sanjayembeddedse@gmail.com>
iio: pressure: hid-sensor-press: convert probe and teardown to devm-managed resources
The commit converts HID IIO driver resource management to devm-managed helpers.
This ties the lifetime of all resources to the device and simplifies the probe
path by removing explicit error handling and teardown paths.
> diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
> index 4e0f42fefd6b4..8ebb8f54a0cb9 100644
> --- a/drivers/iio/pressure/hid-sensor-press.c
> +++ b/drivers/iio/pressure/hid-sensor-press.c
[ ... ]
> @@ -288,38 +289,15 @@ static int hid_press_probe(struct platform_device *pdev)
> press_state->callbacks.send_event = press_proc_event;
> press_state->callbacks.capture_sample = press_capture_sample;
> press_state->callbacks.pdev = pdev;
> - ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_PRESSURE,
> - &press_state->callbacks);
> + ret = devm_sensor_hub_register_callback(dev, hsdev,
> + HID_USAGE_SENSOR_PRESSURE,
> + &press_state->callbacks);
[Severity: High]
This is a pre-existing issue, but can unbinding this driver race with event
delivery and cause a use-after-free?
When the child driver unbinds, devm triggers sensor_hub_remove_callback(),
which removes the callback from dyn_callback_list and frees it using
dyn_callback_lock:
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);
...
}
After this, devm frees the IIO device's private data (press_state).
However, there doesn't appear to be any synchronization to ensure that a
concurrently executing sensor_hub_raw_event() on another CPU has finished
using the callback pointer.
If sensor_hub_raw_event() is actively dispatching an event under pdata->lock,
could it invoke the callback with a stale pointer and write to freed memory?
drivers/hid/hid-sensor-hub.c:sensor_hub_raw_event() {
...
callback = sensor_hub_get_callback(hdev,
report->field[i]->physical ? report->field[i]->physical :
report->field[i]->application,
report->field[i]->usage[0].collection_index,
&hsdev, &priv);
if (!callback) {
ptr += sz;
continue;
}
...
if (callback->capture_sample) {
if (report->field[i]->logical)
callback->capture_sample(hsdev,
report->field[i]->logical, sz, ptr,
callback->pdev);
else
callback->capture_sample(hsdev,
report->field[i]->usage->hid, sz, ptr,
callback->pdev);
}
...
}
> if (ret < 0) {
> dev_err(&pdev->dev, "callback reg failed\n");
> - goto error_remove_trigger;
> - }
> -
> - ret = iio_device_register(indio_dev);
> - if (ret) {
> - dev_err(&pdev->dev, "device register failed\n");
> - goto error_remove_callback;
> }
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260806-28-apr-iio-redundant-argument-v5-temp-v5-0-f1f92c1d830f@gmail.com?part=13
prev parent reply other threads:[~2026-08-06 12:44 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 12:25 [PATCH v5 00/13] HID: iio: Introduce devm_ APIs for HID sensors Sanjay Chitroda via B4 Relay
2026-08-06 12:25 ` [PATCH v5 01/13] iio: hid-sensors: remove unused iio_dev argument Sanjay Chitroda via B4 Relay
2026-08-06 12:37 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 02/13] iio: hid-sensors: introduce device managed API Sanjay Chitroda via B4 Relay
2026-08-06 12:25 ` [PATCH v5 03/13] HID: hid-sensor-hub: " Sanjay Chitroda via B4 Relay
2026-08-06 12:40 ` sashiko-bot
2026-08-08 20:10 ` Andy Shevchenko
2026-08-06 12:25 ` [PATCH v5 04/13] iio: gyro: hid-sensor-gyro-3d: convert probe and teardown to devm-managed resources Sanjay Chitroda via B4 Relay
2026-08-06 12:40 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 05/13] iio: accel: hid-sensor-accel-3d: " Sanjay Chitroda via B4 Relay
2026-08-06 12:39 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 06/13] iio: humidity: hid-sensor-humidity: " Sanjay Chitroda via B4 Relay
2026-08-06 12:36 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 07/13] iio: light: hid-sensor-prox: " Sanjay Chitroda via B4 Relay
2026-08-06 12:39 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 08/13] iio: light: hid-sensor-als: " Sanjay Chitroda via B4 Relay
2026-08-06 12:40 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 09/13] iio: magnetometer: hid-sensor-magn-3d: " Sanjay Chitroda via B4 Relay
2026-08-06 12:25 ` [PATCH v5 10/13] iio: orientation: hid-sensor-incl-3d: " Sanjay Chitroda via B4 Relay
2026-08-06 12:25 ` [PATCH v5 11/13] iio: orientation: hid-sensor-rotation: " Sanjay Chitroda via B4 Relay
2026-08-06 12:40 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 12/13] iio: position: hid-sensor-custom-intel-hinge: " Sanjay Chitroda via B4 Relay
2026-08-06 12:48 ` sashiko-bot
2026-08-06 12:25 ` [PATCH v5 13/13] iio: pressure: hid-sensor-press: " Sanjay Chitroda via B4 Relay
2026-08-06 12:44 ` sashiko-bot [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=20260806124426.B2FFE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=sanjayembeddedse@gmail.com \
--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