syzbot
INFO: trying to register non-static key in dvb_frontend_release
Status:
moderation: reported on 2026/12/05 00:26
Subsystems:
media
Labels:
prio:normal
[Documentation on labels]
Reported-by: syzbot+3f1eaa314067abe93e5d@syzkaller.appspotmail.com
First crash: 1h34m, last: 1h34m
✨ AI-generated root cause summary:
A lifecycle mismatch in the DVB core causes a use-after-free of struct dvb_adapter (fe->dvb) in dvb_frontend_release(). When a DVB frontend device is opened, dvb_frontend_open() takes a reference on struct dvb_frontend (fe->refcount) and struct dvb_device, but struct dvb_adapter is not reference-counted, and dvb_unregister_frontend() and dvb_unregister_adapter() return immediately without waiting for open file descriptors to close. Upon device disconnect, the driver frees the device structure embedding struct dvb_adapter while userspace still holds the frontend fd open. When the fd is later closed in dvb_frontend_release(), accessing fe->dvb->mdev_lock hits the freed (and here reallocated/zeroed) adapter memory, causing KASAN to see live heap memory while lockdep detects an uninitialized non-static lock key.
▶
▼
✨ Full AI root cause analysis
Root Cause Analysis
The lockdep splat in dvb_frontend_release() (drivers/media/dvb-core/dvb_frontend.c:2942) is caused by a use-after-free of struct dvb_adapter (fe->dvb) due to missing lifetime synchronization between frontend/adapter unregistration and open frontend file descriptors.
1. Why mdev_lock Was Originally Initialized
- A DVB adapter is registered via
dvb_register_adapter() (drivers/media/dvb-core/dvbdev.c:890), which clears adap, initializes adap->device_list (line 917), and unconditionally initializes adap->mdev_lock via mutex_init(&adap->mdev_lock) (line 930, under CONFIG_MEDIA_CONTROLLER_DVB).
dvb_register_frontend() (drivers/media/dvb-core/dvb_frontend.c:3027) sets fe->dvb = dvb (line 3067) and registers the device node via dvb_register_device(fe->dvb, ...) (line 3074). Because dvb_register_device() inserts into &adap->device_list (drivers/media/dvb-core/dvbdev.c:524), dvb_register_adapter() must have already run on fe->dvb, meaning fe->dvb->mdev_lock was properly initialized with a static lockdep key at registration time.
2. The Lifecycle / Reference-Counting Defect
-
Open takes a reference on fe and dvbdev, but not on fe->dvb:
- When userspace opens
/dev/dvb/adapterX/frontendY, dvb_device_open() (drivers/media/dvb-core/dvbdev.c:86) takes a reference on dvbdev (dvb_device_get(dvbdev)).
dvb_frontend_open() -> __dvb_frontend_open() (drivers/media/dvb-core/dvb_frontend.c:2764) calls dvb_generic_open() (decrementing dvbdev->users from -1 to -2) and dvb_frontend_get(fe) (incrementing fe->refcount).
- Note that if opened with
O_RDONLY, __dvb_frontend_open() skips the #ifdef CONFIG_MEDIA_CONTROLLER_DVB block (lines 2789-2819) and does not touch fe->dvb->mdev_lock.
- Crucially,
struct dvb_adapter (fe->dvb) has no reference count and no lifetime tie to open dvb_device or dvb_frontend instances.
-
Unregistration does not wait for open file descriptors:
-
Driver teardown frees struct dvb_adapter while the fd remains open:
- On device disconnect or probe failure (e.g., in USB DVB drivers such as
dvb-usb, dvb-usb-v2, ttusb-budget, or as102, which embed struct dvb_adapter inside their per-device struct d / ttusb / as102_dev_t), the driver immediately kfree()s the device structure containing struct dvb_adapter while userspace still holds the open frontend fd.
3. Triggering the Failure in dvb_frontend_release()
Related Lifecycle Issues in dvb_frontend_release()
In addition to fe->dvb (mdev_lock and mdev), dvb_remove_device() already freed dvbdev->entity via dvb_media_device_free(dvbdev) (drivers/media/dvb-core/dvbdev.c:604), and some drivers (e.g., vidtv_bridge_remove() -> dvb_module_release() -> vidtv_demod_i2c_remove() in drivers/media/test-drivers/vidtv/vidtv_demod.c:431) also free the memory embedding struct dvb_frontend itself without waiting for fe->refcount or dvbdev->users == -1.
Sample crash report:
* Struck through repros no longer work on HEAD.