media: mxl111sf: initialize state->d and fe_lock in probe
Subsystems (2)
syzbot
syzbotDuring device initialization in dvb_usbv2_probe(), the dvb-usb-v2 core allocates the dvb_usb_device structure and its private state (struct mxl111sf_state) via kzalloc(), then invokes dvb_usbv2_init(). Within dvb_usbv2_init(), dvb_usbv2_i2c_init() registers the I2C adapter with i2c_add_adapter(), which immediately exposes the I2C adapter to userspace via the /dev/i2c-X character device.
However, state->d was only assigned later during frontend attachment inside dvb_usbv2_adapter_frontend_init() via d->props->frontend_attach(). If userspace performs an I2C transaction before frontend_attach() completes, mxl111sf_i2c_xfer() delegates to mxl111sf_ctrl_msg(), which reads state->d and passes it to dvb_usbv2_generic_write() or dvb_usbv2_generic_rw(). Since state->d is still NULL, dereferencing &d->usb_mutex inside dvb_usbv2_generic_write() triggers a null-pointer dereference crash:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000018: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x00000000000000c0-0x00000000000000c7] RIP: 0010:__mutex_lock_common kernel/locking/mutex.c:625 [inline] RIP: 0010:__mutex_lock+0x149/0x1550 kernel/locking/mutex.c:821 Call Trace: <TASK> dvb_usbv2_generic_write+0x26/0x60 drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c:77 mxl111sf_ctrl_msg+0x160/0x2f0 drivers/media/usb/dvb-usb-v2/mxl111sf.c:73 mxl111sf_write_reg+0xa9/0x1b0 drivers/media/usb/dvb-usb-v2/mxl111sf.c:123 mxl111sf_i2c_start drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c:130 [inline] mxl111sf_i2c_sw_xfer_msg drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c:-1 [inline] mxl111sf_i2c_xfer+0x463/0x5060 drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c:813 __i2c_transfer+0x7bf/0x1fe0 drivers/i2c/i2c-core-base.c:-1 i2c_transfer+0x1cb/0x2d0 drivers/i2c/i2c-core-base.c:2350 i2cdev_ioctl_rdwr+0x460/0x740 drivers/i2c/i2c-dev.c:306 i2cdev_ioctl+0x6a5/0x880 drivers/i2c/i2c-dev.c:467 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:597 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
Additionally, state->fe_lock was initialized in mxl111sf_init() (called via d->props->init()), which runs after frontend attachment, leaving the mutex uninitialized during frontend registration.
Fix this by setting state->d = dev and initializing state->fe_lock in mxl111sf_probe(), which runs before dvb_usbv2_init() registers the I2C adapter or attaches frontends. Furthermore, remove the redundant mutex_init(&state->fe_lock) from mxl111sf_init() and the redundant assignments of state->d in the frontend attach functions.
To: <[email protected]>
To: "Mauro Carvalho Chehab" <[email protected]>
To: "Michael Krufky" <[email protected]>
To: "Antti Palosaari" <[email protected]>
Cc: <[email protected]>
---
drivers/media/usb/dvb-usb-v2/mxl111sf.c +2 -12
@@ -431,8 +431,6 @@ static int mxl111sf_lgdt3305_frontend_attach(struct dvb_usb_adapter *adap, u8 fepr_debug ("%s()\n" , __func__); -/* save a pointer to the dvb_usb_device in device state */ - state->d = d; adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ?2 :1 ; state->alt_mode = adap_state->alt_mode;
@@ -502,8 +500,6 @@ static int mxl111sf_lg2160_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_ipr_debug ("%s()\n" , __func__); -/* save a pointer to the dvb_usb_device in device state */ - state->d = d; adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ?2 :1 ; state->alt_mode = adap_state->alt_mode;
@@ -587,8 +583,6 @@ static int mxl111sf_lg2161_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_ipr_debug ("%s()\n" , __func__); -/* save a pointer to the dvb_usb_device in device state */ - state->d = d; adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ?2 :1 ; state->alt_mode = adap_state->alt_mode;
@@ -674,8 +668,6 @@ static int mxl111sf_lg2161_ep6_frontend_attach(struct dvb_usb_adapter *adap, u8pr_debug ("%s()\n" , __func__); -/* save a pointer to the dvb_usb_device in device state */ - state->d = d; adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ?2 :1 ; state->alt_mode = adap_state->alt_mode;
@@ -749,8 +741,6 @@ static int mxl111sf_attach_demod(struct dvb_usb_adapter *adap, u8 fe_id)pr_debug ("%s()\n" , __func__); -/* save a pointer to the dvb_usb_device in device state */ - state->d = d; adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ?1 :2 ; state->alt_mode = adap_state->alt_mode;
@@ -935,8 +925,6 @@ static int mxl111sf_init(struct dvb_usb_device *d)if (mxl_fail (ret))pr_err ("failed to get chip info during probe" ); -mutex_init (&state->fe_lock); -if (state->chip_rev >MXL111SF_V6 )mxl111sf_config_pin_mux_modes (state,PIN_MUX_TS_SPI_IN_MODE_1 );
@@ -1068,7 +1056,9 @@ static int mxl111sf_probe(struct dvb_usb_device *dev) {struct mxl111sf_state *state =d_to_priv (dev); + state->d = dev;mutex_init (&state->msg_lock); +mutex_init (&state->fe_lock);return 0 ; }
base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
Signature · 9 lines
This is an AI-generated patch subject to moderation.
Reply with '#syz upstream' to Sign-off the patch as a human author
and send it to the upstream kernel mailing lists.
Reply with '#syz reject' to reject it ('#syz unreject' to undo).
See https://goo.gle/syzbot-ai-patches for information about AI-generated patches.
You can comment on the patch as usual, syzbot will try to address
the comments and send a new version of the patch if necessary.
syzbot engineers can be reached at [email protected].The v1 code change is sound in the tested scenario. The assembled patch still needs the submission corrections below; no code rewrite is requested.
Required changes:
- Correct the formatter-owned Fixes: metadata. Replace 8572211842af with 4c66c9205c07, or provide source history supporting a narrower conversion-specific claim. The syzkaller-side metadata owner must make this change; editing the generated description alone cannot change the trailer.
- Revise the description to distinguish its quoted x64/NOPTI trace from the selected 2026-10-02 PTI/compat report, or quote that selected report. Describe fe_lock as initialized before frontend registration; the selected I2C fault does not demonstrate a frontend lock race.
Testing:
In a matched 240-second run, the unpatched kernel hit the target fault in 3/4 guests and the patched kernel had no target crash in 4/4 guests. The C reproducer was confirmed to start on both sides. This supports the code change for the tested scenario; it is not a claim of general regression safety.
Context:mxl111sf_probe() assigns state->d and initializes fe_lock before the I2C adapter is published; the later back-pointer stores are redundant. The MxL111SF introduction, 4c66c9205c07 ("[media] dvb-usb: add ATSC support for the Hauppauge WinTV-Aero-M"), already registered I2C before frontend attachment and assigned state->d only during frontend attachment. The later 8572211842af DVB USB v2 conversion did not introduce that ordering defect. Syzkaller appends Fixes: from patch metadata after the generated description.
The selected historical-kernel run had four setup attempts, all stopped before the reproducer started. It therefore supplies neither a repro nor a no-repro result. Source-order checks did not exercise an I2C transfer concurrently with disconnect. Resolve the historical setup failure and exercise that overlap before claiming those cases are covered.
Impact assessment:
A userspace I2C transaction through the registered adapter
can reach the null back pointer and cause a kernel oops; panic-on-oops policy can turn that into an outage. No confidentiality or integrity effect is proven.
Kind Regards / Mit freundlichen Grüßen
BART CHRONOWSKI
Quoted 152 lines · syzbot' via syzkaller-upstream-moderation
During device initialization in
dvb_usbv2_probe(), the dvb-usb-v2 core allocates thedvb_usb_devicestructure and its private state (structmxl111sf_state) viakzalloc(), then invokesdvb_usbv2_init(). Withindvb_usbv2_init(),dvb_usbv2_i2c_init()registers the I2C adapter withi2c_add_adapter(), which immediately exposes the I2C adapter to userspace via the/dev/i2c-Xcharacter device.However,
state->dwas only assigned later during frontend attachment insidedvb_usbv2_adapter_frontend_init()viad->props->frontend_attach(). If userspace performs an I2C transaction beforefrontend_attach()completes,mxl111sf_i2c_xfer()delegates tomxl111sf_ctrl_msg(), which readsstate->dand passes it todvb_usbv2_generic_write()ordvb_usbv2_generic_rw(). Sincestate->dis still NULL, dereferencing&d->usb_mutexinsidedvb_usbv2_generic_write()triggers a null-pointer dereference crash:Oops: general protection fault, probably for non-canonical address 0xdffffc0000000018: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x00000000000000c0-0x00000000000000c7] RIP: 0010:__mutex_lock_common kernel/locking/mutex.c:625 [inline] RIP: 0010:__mutex_lock+0x149/0x1550 kernel/locking/mutex.c:821 Call Trace: <TASK> dvb_usbv2_generic_write+0x26/0x60 drivers/media/usb/dvb-usb-v2/dvb_usb_urb.c:77 mxl111sf_ctrl_msg+0x160/0x2f0 drivers/media/usb/dvb-usb-v2/mxl111sf.c:73 mxl111sf_write_reg+0xa9/0x1b0 drivers/media/usb/dvb-usb-v2/mxl111sf.c:123 mxl111sf_i2c_start drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c:130 [inline] mxl111sf_i2c_sw_xfer_msg drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c:-1 [inline] mxl111sf_i2c_xfer+0x463/0x5060 drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c:813 __i2c_transfer+0x7bf/0x1fe0 drivers/i2c/i2c-core-base.c:-1 i2c_transfer+0x1cb/0x2d0 drivers/i2c/i2c-core-base.c:2350 i2cdev_ioctl_rdwr+0x460/0x740 drivers/i2c/i2c-dev.c:306 i2cdev_ioctl+0x6a5/0x880 drivers/i2c/i2c-dev.c:467 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:597 [inline] __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline] do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>Additionally,
state->fe_lockwas initialized inmxl111sf_init()(called viad->props->init()), which runs after frontend attachment, leaving the mutex uninitialized during frontend registration.Fix this by setting
state->d= dev and initializingstate->fe_lockinmxl111sf_probe(), which runs beforedvb_usbv2_init()registers the I2C adapter or attaches frontends. Furthermore, remove the redundantmutex_init(&state->fe_lock)frommxl111sf_init()and the redundant assignments ofstate->din the frontend attach functions.Fixes 8572211842af ("[media] mxl111sf: convert to new DVB USB")Assisted-by Gemini:gemini-4-argon Gemini:gemini-3.8-flash syzbotReported-by [email protected]To: <[email protected]>
To: "Mauro Carvalho Chehab" <[email protected]>
To: "Michael Krufky" <[email protected]>
To: "Antti Palosaari" <[email protected]>
Cc: <[email protected]>---
drivers/media/usb/dvb-usb-v2/mxl111sf.c +2
-12@@ -431,8 +431,6 @@ static int mxl111sf_lgdt3305_frontend_attach(struct dvb_usb_adapter *adap, u8 fepr_debug ("%s()\n" , __func__); -/* save a pointer to the dvb_usb_device in device state */ - state->d = d; adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ?2 :1 ; state->alt_mode = adap_state->alt_mode;@@ -502,8 +500,6 @@ static int mxl111sf_lg2160_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_ipr_debug ("%s()\n" , __func__); -/* save a pointer to the dvb_usb_device in device state */ - state->d = d; adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ?2 :1 ; state->alt_mode = adap_state->alt_mode;@@ -587,8 +583,6 @@ static int mxl111sf_lg2161_frontend_attach(struct dvb_usb_adapter *adap, u8 fe_ipr_debug ("%s()\n" , __func__); -/* save a pointer to the dvb_usb_device in device state */ - state->d = d; adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ?2 :1 ; state->alt_mode = adap_state->alt_mode;@@ -674,8 +668,6 @@ static int mxl111sf_lg2161_ep6_frontend_attach(struct dvb_usb_adapter *adap, u8pr_debug ("%s()\n" , __func__); -/* save a pointer to the dvb_usb_device in device state */ - state->d = d; adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ?2 :1 ; state->alt_mode = adap_state->alt_mode;@@ -749,8 +741,6 @@ static int mxl111sf_attach_demod(struct dvb_usb_adapter *adap, u8 fe_id)pr_debug ("%s()\n" , __func__); -/* save a pointer to the dvb_usb_device in device state */ - state->d = d; adap_state->alt_mode = (dvb_usb_mxl111sf_isoc) ?1 :2 ; state->alt_mode = adap_state->alt_mode;@@ -935,8 +925,6 @@ static int mxl111sf_init(struct dvb_usb_device *d)if (mxl_fail (ret))pr_err ("failed to get chip info during probe" ); -mutex_init (&state->fe_lock); -if (state->chip_rev >MXL111SF_V6 )mxl111sf_config_pin_mux_modes (state,PIN_MUX_TS_SPI_IN_MODE_1 );@@ -1068,7 +1056,9 @@ static int mxl111sf_probe(struct dvb_usb_device *dev) {struct mxl111sf_state *state =d_to_priv (dev); + state->d = dev;mutex_init (&state->msg_lock); +mutex_init (&state->fe_lock);return 0 ; }base-commit:
c03c1a14507dfaf8b856c2608f9ac216021fc222Signature · 14 lines
This is an AI-generated patch subject to moderation. Reply with '#syz upstream' to Sign-off the patch as a human author and send it to the upstream kernel mailing lists. Reply with '#syz reject' to reject it ('#syz unreject' to undo). See https://goo.gle/syzbot-ai-patches for information about AI-generated patches. You can comment on the patch as usual, syzbot will try to address the comments and send a new version of the patch if necessary. syzbot engineers can be reached at [email protected]. -- You received this message because you are subscribed to the Google Groups "syzkaller-upstream-moderation" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/syzkaller-upstream-moderation/b8b6fc2d-1c9a-4046-bba5-c9ef864bfae3%40mail.kernel.org.