[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251107181623.2139080-3-Sergey.Nalivayko@kaspersky.com>
Date: Fri, 7 Nov 2025 21:16:23 +0300
From: Nalivayko Sergey <Sergey.Nalivayko@...persky.com>
To: <linux-media@...r.kernel.org>
CC: Nalivayko Sergey <Sergey.Nalivayko@...persky.com>,
<linux-kernel@...r.kernel.org>, <lvc-project@...uxtesting.org>, Mauro
Carvalho Chehab <mchehab@...nel.org>, Michael Krufky <mkrufky@...uxtv.org>,
<syzbot+f9f5333782a854509322@...kaller.appspotmail.com>,
<stable@...r.kernel.org>
Subject: [PATCH v2 2/2] media: mxl111sf: fix i2c race condition during device probe
syzbot reports a KASAN issue as below:
Oops: general protection fault, probably for non-canonical
address 0xdffffc0000000019: 0000 [#1] SMP KASAN PTI
KASAN: null-ptr-deref in range [0x00000000000000c8-0x00000000000000cf]
CPU: 1 UID: 0 PID: 5849 Comm: syz-executor279
Not tainted 6.15.0-rc2-syzkaller #0 PREEMPT(full)
Hardware name: Google Compute Engine/Google Compute Engine,
BIOS Google 02/12/2025
RIP: 0010:__mutex_lock_common kernel/locking/mutex.c:580 [inline]
RIP: 0010:__mutex_lock+0x15d/0x10c0 kernel/locking/mutex.c:746
Call Trace:
<TASK>
dvb_usbv2_generic_write+0x26/0x50
mxl111sf_ctrl_msg+0x172/0x2e0
mxl111sf_write_reg+0xda/0x1f0
mxl111sf_i2c_start
mxl111sf_i2c_sw_xfer_msg
mxl111sf_i2c_xfer+0x923/0x8aa0
__i2c_transfer+0x859/0x2250
i2c_transfer+0x2c2/0x430
i2c_transfer_buffer_flags+0x182/0x260
i2c_master_recv
i2cdev_read+0x10a/0x220
vfs_read+0x21f/0xb90
ksys_read+0x19d/0x2d0
do_syscall_x64
do_syscall_64+0xf3/0x230
entry_SYSCALL_64_after_hwframe+0x77/0x7f
</TASK>
This occurs due to a race condition during DVB-USB-V2 device
initialization. While initialization is in progress, I2C data may be read
from userspace, leading to a NULL pointer dereference in
dvb_usbv2_generic_write and a kernel panic.
Thread 1 (probe device) Thread 2 (receive i2c data)
...
dvb_usbv2_probe()
...
d->priv = kzalloc(
d->props->size_of_priv,
GFP_KERNEL);
...
dvb_usbv2_init()
...
// can read data from i2c
dvb_usbv2_i2c_init()
...
...
i2cdev_read()
...
// d->priv data is invalid. UB
mxl111sf_i2c_xfer()
...
mxl111sf_ctrl_msg()
...
// null ptr deref
dvb_usbv2_generic_write()
...
...
// d->priv data is valid
dvb_usbv2_adapter_init()
...
Add init_ready flag check to prevent I/O on uninitialized DVB-USB-V2
device.
Reported-by: syzbot+f9f5333782a854509322@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f9f5333782a854509322
Fixes: 4c66c9205c07 ("[media] dvb-usb: add ATSC support for the Hauppauge WinTV-Aero-M")
Cc: stable@...r.kernel.org
Signed-off-by: Nalivayko Sergey <Sergey.Nalivayko@...persky.com>
---
drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c
index 100a1052dcbc..b7bad90b16dc 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-i2c.c
@@ -804,7 +804,7 @@ int mxl111sf_i2c_xfer(struct i2c_adapter *adap,
int hwi2c = (state->chip_rev > MXL111SF_V6);
int i, ret;
- if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
+ if (!atomic_read(&d->init_ready) || mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN;
for (i = 0; i < num; i++) {
--
2.39.5
Powered by blists - more mailing lists