All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sanjay Chitroda" <sanjayembeddedse@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v5 01/13] iio: hid-sensors: remove unused iio_dev argument
Date: Thu, 06 Aug 2026 12:37:37 +0000	[thread overview]
Message-ID: <20260806123738.5103F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806-28-apr-iio-redundant-argument-v5-temp-v5-1-f1f92c1d830f@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Concurrent execution of `sensor_hub_raw_event` and a child IIO driver's `remove` function can cause a Use-After-Free on the IIO device state.
--

--- Patch [1]: [PATCH v5 01/13] iio: hid-sensors: remove unused iio_dev argument ---
commit c12a28d854a2931313f7d217face266eaf20a33a
Author: Sanjay Chitroda <sanjayembeddedse@gmail.com>

iio: hid-sensors: remove unused iio_dev argument

hid_sensor_remove_trigger() no longer uses the iio_dev argument. Remove the
unused argument from all HID IIO drivers to match updated function prototype.

> diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
> --- a/drivers/iio/accel/hid-sensor-accel-3d.c
> +++ b/drivers/iio/accel/hid-sensor-accel-3d.c
[ ... ]
> @@ -415,7 +415,7 @@ static void hid_accel_3d_remove(struct platform_device *pdev)
>  
>  	iio_device_unregister(indio_dev);
>  	sensor_hub_remove_callback(hsdev, hsdev->usage);

[Severity: High]
This isn't a bug introduced by this patch, but does the concurrent execution
of sensor_hub_raw_event() and this remove() function cause a use-after-free
on the IIO device state?

Looking at sensor_hub_remove_callback() in drivers/hid/hid-sensor-hub.c, it
removes the callback using dyn_callback_lock but does not synchronize with
pdata->lock:

drivers/hid/hid-sensor-hub.c:sensor_hub_remove_callback() {
    spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
    // list removal
    spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
}

If an unbind happens concurrently with an incoming hardware event:

CPU1
sensor_hub_raw_event()
    acquires pdata->lock
    finds registered callback

CPU2
hid_accel_3d_remove()
    sensor_hub_remove_callback()
        removes callback and returns
    devres framework frees the IIO device state

CPU1
sensor_hub_raw_event()
    if (callback->capture_sample) {
        callback->capture_sample(...) // Dereferences freed IIO state

Can this lead to memory corruption during physical device removal or sysfs
unbind?

> -	hid_sensor_remove_trigger(indio_dev, &accel_state->common_attributes);
> +	hid_sensor_remove_trigger(&accel_state->common_attributes);
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806-28-apr-iio-redundant-argument-v5-temp-v5-0-f1f92c1d830f@gmail.com?part=1

  reply	other threads:[~2026-08-06 12:37 UTC|newest]

Thread overview: 39+ 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 ` Sanjay Chitroda
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:25   ` Sanjay Chitroda
2026-08-06 12:37   ` sashiko-bot [this message]
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   ` Sanjay Chitroda
2026-08-06 12:25 ` [PATCH v5 03/13] HID: hid-sensor-hub: " Sanjay Chitroda via B4 Relay
2026-08-06 12:25   ` Sanjay Chitroda
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:25   ` Sanjay Chitroda
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:25   ` Sanjay Chitroda
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:25   ` Sanjay Chitroda
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:25   ` Sanjay Chitroda
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:25   ` Sanjay Chitroda
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   ` Sanjay Chitroda
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   ` Sanjay Chitroda
2026-08-06 12:25 ` [PATCH v5 11/13] iio: orientation: hid-sensor-rotation: " Sanjay Chitroda via B4 Relay
2026-08-06 12:25   ` Sanjay Chitroda
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:25   ` Sanjay Chitroda
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:25   ` Sanjay Chitroda
2026-08-06 12:44   ` sashiko-bot

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=20260806123738.5103F1F000E9@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 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.