[bug report] drm/vblank: Hard lockup in __disable_vblank()
From: Yu Liao
Date: Mon Jul 15 2024 - 03:02:40 EST
Hi,
A hard lockup is happened when I do fuzz test with syzkaller.
Kernel panic - not syncing: Hard LOCKUP
CPU: 3 PID: 0 Comm: swapper/3 Not tainted 6.6.0+ #21
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014
Call Trace:
<IRQ>
hrtimer_cancel+0x52/0x70 kernel/time/hrtimer.c:1449
__disable_vblank drivers/gpu/drm/drm_vblank.c:434 [inline]
drm_vblank_disable_and_save+0x27f/0x3c0 drivers/gpu/drm/drm_vblank.c:478
vblank_disable_fn+0x15d/0x1b0 drivers/gpu/drm/drm_vblank.c:495
call_timer_fn+0x39/0x280 kernel/time/timer.c:1700
expire_timers+0x22d/0x3c0 kernel/time/timer.c:1751
__run_timers kernel/time/timer.c:2022 [inline]
run_timer_softirq+0x315/0x8a0 kernel/time/timer.c:2035
handle_softirqs+0x195/0x580 kernel/softirq.c:553
__do_softirq kernel/softirq.c:587 [inline]
</IRQ>
This is a deadlock issue as follows:
CPU3 CPU 7
vblank_disable_fn()
drm_vblank_disable_and_save()
spin_lock(vblank_time_lock)
hrtimer_interrupt()
vkms_vblank_simulate()
drm_handle_vblank()
//wait for CPU3 to release vblank_time_lock
spin_lock(vblank_time_lock)
vkms_disable_vblank()
//wait for vblank_hrtimer on CPU7 to finish
hrtimer_cancel(vblank_hrtimer)
The call of hrtimer_cancel() should not hold locks which would prevent
completion of the hrtimer's callback function.
Best regards,
Yu