Re: [PATCH] HID: sensor-hub: Avoid holding spinlock across child iteration

From: syzbot

Date: Fri Nov 20 2026 - 06:10:00 EST


>
>
> On 20/11/2026 11:50, Joshua Crofts wrote:
>> On 20/11/2026 08:56, Zheng Shuhao wrote:
>>> syzbot reports a SOFTIRQ-safe -> SOFTIRQ-unsafe lock order warning during
>>> sensor hub removal.
>>>
>>> sensor_hub_remove() currently holds sensor_data->lock while calling
>>> device_for_each_child(). The child iteration enters the device core and may
>>> acquire the klist lock. Since sensor_data->lock is also acquired with
>>> interrupts disabled by sensor_hub_raw_event(), lockdep reports a possible
>>> lock-order inversion.
>>>
>>> The callback only needs sensor_data->lock while checking pending.status and
>>> completing pending.ready. Pass sensor_data to the callback and take the lock
>>> only around that short critical section instead of holding it across
>>> device_for_each_child().
>>>
>>> This preserves synchronization of pending.status while avoiding the lock-order
>>> dependency between sensor_data->lock and the device core's klist lock.
>>>
>>> The syzbot report is available at:
>>> https://syzkaller.appspot.com/bug?id=c7c429f6851638ece81338f90c5b29ac9c0dea1f
>>>
>>> Testing:
>>> - Reproduced the target lockdep warning with the unmodified kernel in 3/3
>>> two-CPU QEMU runs.
>>> - The warning was absent with this patch in 3/3 equivalent runs.
>>> - Ran the HID selftests against both baseline and patched kernels:
>>> hid_bpf: 45 passed, 1 skipped, 0 failed
>>> hidraw: 27 passed, 0 failed
>>> hid-core, hid-apple, hid-gamepad, hid-ite, hid-keyboard, hid-mouse,
>>> hid-multitouch, hid-sony, and hid-tablet all passed in both runs.
>>> - hid-usb_crash.sh and hid-wacom.sh produced TAP 1..0 / rc=2 in both
>>> kernels because no executable test cases were collected in this minimal
>>> QEMU environment.
>>> - No KASAN report, use-after-free, Oops, BUG, panic, or general protection
>>> fault was observed.
>>> - checkpatch.pl --strict --no-signoff reports 0 errors and 0 warnings.
>>>
>>> Reported-by: syzbot+c7c429f6851638ece81338f90c5b29ac9c0dea1f@xxxxxxxxxxxxxxxxxxxxxxxxx
>>> Closes: https://syzkaller.appspot.com/bug?id=c7c429f6851638ece81338f90c5b29ac9c0dea1f
>>> Signed-off-by: Zheng Shuhao <viennaoffh@xxxxxxxxx>
>>> Tested-by: Zheng Shuhao <viennaoffh@xxxxxxxxx>
>> You cannot add a Tested-by tag with your name. This is reserved for when
>> someone independent of you tests your patch. Looking at the syzbot report
>> there is a reproducer, so syzbot should test it. You can make syzbot test
>> a patch by sending the following (note, this will trigger a test):
>
> Ah, did some digging and the syzbot email is incorrect, it should be:
>
> syzbot+fb951970a334aaff00ba@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> Cc'd the right syzbot and triggering the test.
>
> #syz test

Patch testing via #syz test is temporarily disabled.
See https://github.com/google/syzkaller/issues/8122 for details.

>
> --
> Kind regards,
> Joshua Crofts
>