[syzbot] [media?] BUG: corrupted list in az6007_i2c_xfer

6 views
Skip to first unread message

syzbot

unread,
Apr 20, 2025, 9:41:33 PMApr 20
to linux-...@vger.kernel.org, linux...@vger.kernel.org, mch...@kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: ac71fabf1567 gcc-15: work around sequence-point warning
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=10b4cc70580000
kernel config: https://syzkaller.appspot.com/x/.config?x=7a7c679f880028f0
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16fedb98580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10edf4cc580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/d368be8878a6/disk-ac71fabf.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/cc783efdaf4c/vmlinux-ac71fabf.xz
kernel image: https://storage.googleapis.com/syzbot-assets/d04c29c82c67/bzImage-ac71fabf.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+019295...@syzkaller.appspotmail.com

usb read operation failed. (-71)
------------[ cut here ]------------
UBSAN: array-index-out-of-bounds in drivers/media/usb/dvb-usb-v2/az6007.c:821:30
index 4096 is out of range for type 'unsigned char [4096]'
CPU: 1 UID: 0 PID: 5832 Comm: syz-executor328 Not tainted 6.15.0-rc2-syzkaller-00493-gac71fabf1567 #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x16c/0x1f0 lib/dump_stack.c:120
ubsan_epilogue lib/ubsan.c:231 [inline]
__ubsan_handle_out_of_bounds+0x11c/0x160 lib/ubsan.c:453
az6007_i2c_xfer+0x549/0xc30 drivers/media/usb/dvb-usb-v2/az6007.c:821
__i2c_transfer+0x6b3/0x2190 drivers/i2c/i2c-core-base.c:2259
i2c_transfer drivers/i2c/i2c-core-base.c:2315 [inline]
i2c_transfer+0x1da/0x380 drivers/i2c/i2c-core-base.c:2291
i2c_transfer_buffer_flags+0x10c/0x190 drivers/i2c/i2c-core-base.c:2343
i2c_master_recv include/linux/i2c.h:79 [inline]
i2cdev_read+0x111/0x280 drivers/i2c/i2c-dev.c:155
do_loop_readv_writev fs/read_write.c:845 [inline]
do_loop_readv_writev fs/read_write.c:833 [inline]
vfs_readv+0x6bc/0x8a0 fs/read_write.c:1018
do_preadv+0x1af/0x270 fs/read_write.c:1130
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x260 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f4d458f3929
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 c1 17 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe002f51e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007ffe002f5230 RCX: 00007f4d458f3929
RDX: 0000000000000001 RSI: 00002000000025c0 RDI: 0000000000000004
RBP: 0000000000000000 R08: 000000000000007e R09: 00007ffe002f5230
R10: 0000000000000002 R11: 0000000000000246 R12: 00000000000f4240
R13: 00007ffe002f54b8 R14: 00007ffe002f521c R15: 00007ffe002f5220
</TASK>
---[ end trace ]---


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

Arnaud Lecomte

unread,
Apr 21, 2025, 9:40:34 AMApr 21
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, linux...@vger.kernel.org, mch...@kernel.org, syzkall...@googlegroups.com
#syz test
diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..784cba9c15ef 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -751,6 +751,9 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
int length;
u8 req, addr;

+ if (!usb_trylock_device(d->udev))
+ return -EBUSY;
+
if (mutex_lock_interruptible(&st->mutex) < 0) {
+ usb_unlock_device(d->udev);
return -EAGAIN;
}

@@ -757,6 +760,10 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],

for (i = 0; i < num; i++) {
addr = msgs[i].addr << 1;
+ if (msgs[i].len < 1 || msgs[i].len >= sizeof(st->data) - 6) {
+ ret = -EIO;
+ goto err;
+ }
if (((i + 1) < num)
&& (msgs[i].len == 1)
&& ((msgs[i].flags & I2C_M_RD) != I2C_M_RD)
@@ -821,6 +828,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
}
err:
mutex_unlock(&st->mutex);
+ usb_unlock_device(d->udev);
if (ret < 0) {
pr_info("%s ERROR: %i\n", __func__, ret);
return ret;

syzbot

unread,
Apr 21, 2025, 9:44:04 AMApr 21
to con...@arnaud-lcm.com, linux-...@vger.kernel.org, linux...@vger.kernel.org, mch...@kernel.org, syzkall...@googlegroups.com
Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to apply patch:
checking file drivers/media/usb/dvb-usb-v2/az6007.c
patch: **** malformed patch at line 15: }




Tested on:

commit: 9d7a0577 gcc-15: disable '-Wunterminated-string-initia..
git tree: upstream
patch: https://syzkaller.appspot.com/x/patch.diff?x=16719ccc580000

Edward Adam Davis

unread,
Apr 21, 2025, 9:44:08 AMApr 21
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
#syz test

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..15d2fe477fcc 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -806,7 +806,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
if (az6007_xfer_debug)
printk(KERN_DEBUG "az6007: I2C R addr=0x%x len=%d\n",
addr, msgs[i].len);
- if (msgs[i].len < 1) {
+ if (msgs[i].len < 1 || msgs[i].len > 4091) {
ret = -EIO;
goto err;
}

Arnaud Lecomte

unread,
Apr 21, 2025, 9:46:12 AMApr 21
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, linux...@vger.kernel.org, mch...@kernel.org, syzkall...@googlegroups.com
#syz test
diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..784cba9c15ef 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -752,11 +752,18 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
int length;
u8 req, addr;

+ if(!usb_trylock_device(d->udev))
+ return -EBUSY;
+
if (mutex_lock_interruptible(&st->mutex) < 0)
return -EAGAIN;

for (i = 0; i < num; i++) {
addr = msgs[i].addr << 1;
+ if (msgs[i].len < 1 || msgs[i].len >= sizeof(st->data) - 6) {
+ ret = -EIO;
+ goto err;
+ }
if (((i + 1) < num)
&& (msgs[i].len == 1)
&& ((msgs[i].flags & I2C_M_RD) != I2C_M_RD)
@@ -788,10 +795,6 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
if (az6007_xfer_debug)
printk(KERN_DEBUG "az6007: I2C W addr=0x%x len=%d\n",
addr, msgs[i].len);
- if (msgs[i].len < 1) {
- ret = -EIO;
- goto err;
- }
req = AZ6007_I2C_WR;
index = msgs[i].buf[0];
value = addr | (1 << 8);
@@ -806,10 +809,6 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
if (az6007_xfer_debug)
printk(KERN_DEBUG "az6007: I2C R addr=0x%x len=%d\n",
addr, msgs[i].len);
- if (msgs[i].len < 1) {
- ret = -EIO;
- goto err;
- }
req = AZ6007_I2C_RD;
index = msgs[i].buf[0];
value = addr;
@@ -825,7 +824,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
}
err:
mutex_unlock(&st->mutex);
-

Arnaud Lecomte

unread,
Apr 21, 2025, 10:22:27 AMApr 21
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, linux...@vger.kernel.org, mch...@kernel.org, syzkall...@googlegroups.com
#syz test
--

syzbot

unread,
Apr 21, 2025, 10:25:03 AMApr 21
to ead...@qq.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
BUG: corrupted list in az6007_i2c_xfer

slab kmalloc-8k start ffff888061394000 pointer offset 80 size 8192
list_del corruption. prev->next should be ffffc900041a7960, but was ffff888061394050. (prev=ffff888061394050)
------------[ cut here ]------------
kernel BUG at lib/list_debug.c:62!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
CPU: 1 UID: 0 PID: 7547 Comm: syz.0.109 Not tainted 6.15.0-rc3-syzkaller-g9d7a0577c9db-dirty #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
RIP: 0010:__list_del_entry_valid_or_report+0x17a/0x200 lib/list_debug.c:62
Code: 00 00 fc ff df 48 c1 ea 03 80 3c 02 00 0f 85 8d 00 00 00 48 8b 55 00 48 89 e9 48 89 de 48 c7 c7 a0 69 f4 8b e8 b7 82 c5 fc 90 <0f> 0b 4c 89 e7 e8 ec 48 29 fd 48 89 ea 48 b8 00 00 00 00 00 fc ff
RSP: 0018:ffffc900041a7870 EFLAGS: 00010086
RAX: 000000000000006d RBX: ffffc900041a7960 RCX: ffffffff819aaf39
RDX: 0000000000000000 RSI: ffffffff819b2dc6 RDI: 0000000000000005
RBP: ffff888061394050 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000080000002 R11: 0000000000000001 R12: ffff888061394050
R13: ffffc900041a7940 R14: 0000000000000246 R15: 1ffff92000834f22
FS: 00007f3527db26c0(0000) GS:ffff888124ab2000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00002000000025c0 CR3: 0000000028dda000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
__list_del_entry_valid include/linux/list.h:124 [inline]
__list_del_entry include/linux/list.h:215 [inline]
list_del include/linux/list.h:229 [inline]
__mutex_remove_waiter+0x1a/0x1a0 kernel/locking/mutex.c:206
__mutex_lock_common kernel/locking/mutex.c:714 [inline]
__mutex_lock+0x85b/0xb90 kernel/locking/mutex.c:746
az6007_i2c_xfer+0x8e/0xc30 drivers/media/usb/dvb-usb-v2/az6007.c:755
__i2c_transfer+0x6b3/0x2190 drivers/i2c/i2c-core-base.c:2259
i2c_transfer drivers/i2c/i2c-core-base.c:2315 [inline]
i2c_transfer+0x1da/0x380 drivers/i2c/i2c-core-base.c:2291
i2c_transfer_buffer_flags+0x10c/0x190 drivers/i2c/i2c-core-base.c:2343
i2c_master_recv include/linux/i2c.h:79 [inline]
i2cdev_read+0x111/0x280 drivers/i2c/i2c-dev.c:155
do_loop_readv_writev fs/read_write.c:845 [inline]
do_loop_readv_writev fs/read_write.c:833 [inline]
vfs_readv+0x6bc/0x8a0 fs/read_write.c:1018
do_preadv+0x1af/0x270 fs/read_write.c:1130
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x260 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f3526f8e169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f3527db2038 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007f35271b5fa0 RCX: 00007f3526f8e169
RDX: 0000000000000001 RSI: 00002000000025c0 RDI: 0000000000000004
RBP: 00007f3527010a68 R08: 000000000000007e R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f35271b5fa0 R15: 00007ffcd08bc1d8
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__list_del_entry_valid_or_report+0x17a/0x200 lib/list_debug.c:62
Code: 00 00 fc ff df 48 c1 ea 03 80 3c 02 00 0f 85 8d 00 00 00 48 8b 55 00 48 89 e9 48 89 de 48 c7 c7 a0 69 f4 8b e8 b7 82 c5 fc 90 <0f> 0b 4c 89 e7 e8 ec 48 29 fd 48 89 ea 48 b8 00 00 00 00 00 fc ff
RSP: 0018:ffffc900041a7870 EFLAGS: 00010086
RAX: 000000000000006d RBX: ffffc900041a7960 RCX: ffffffff819aaf39
RDX: 0000000000000000 RSI: ffffffff819b2dc6 RDI: 0000000000000005
RBP: ffff888061394050 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000080000002 R11: 0000000000000001 R12: ffff888061394050
R13: ffffc900041a7940 R14: 0000000000000246 R15: 1ffff92000834f22
FS: 00007f3527db26c0(0000) GS:ffff888124ab2000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00002000000025c0 CR3: 0000000028dda000 CR4: 00000000003526f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


Tested on:

commit: 9d7a0577 gcc-15: disable '-Wunterminated-string-initia..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16dfcc70580000
kernel config: https://syzkaller.appspot.com/x/.config?x=efa83f9a6dd67d67
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=14c78fcf980000

Edward Adam Davis

unread,
Apr 21, 2025, 10:32:13 AMApr 21
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, linux...@vger.kernel.org, mch...@kernel.org, syzkall...@googlegroups.com
syzbot report a corrupted list in az6007_i2c_xfer. [1]

Before accessing the member data of the struct az6007_device_state, only
the lower boundary of data is checked, but the upper boundary is not checked.
When the value of msgs[i].len is damaged or too large, it will cause out
of bounds access to st->data.

[1]
UBSAN: array-index-out-of-bounds in drivers/media/usb/dvb-usb-v2/az6007.c:821:30
index 4096 is out of range for type 'unsigned char [4096]'
CPU: 1 UID: 0 PID: 5832 Comm: syz-executor328 Not tainted 6.15.0-rc2-syzkaller-00493-gac71fabf1567 #0 PREEMPT(full)
Call Trace:
<TASK>
az6007_i2c_xfer+0x549/0xc30 drivers/media/usb/dvb-usb-v2/az6007.c:821
i2c_transfer_buffer_flags+0x10c/0x190 drivers/i2c/i2c-core-base.c:2343
i2cdev_read+0x111/0x280 drivers/i2c/i2c-dev.c:155
do_loop_readv_writev fs/read_write.c:833 [inline]
do_preadv+0x1af/0x270 fs/read_write.c:1130
do_syscall_64+0xcd/0x260 arch/x86/entry/syscall_64.c:94

Reported-by: syzbot+019295...@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
Signed-off-by: Edward Adam Davis <ead...@qq.com>
---
drivers/media/usb/dvb-usb-v2/az6007.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..6322894eda27 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -806,7 +806,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
if (az6007_xfer_debug)
printk(KERN_DEBUG "az6007: I2C R addr=0x%x len=%d\n",
addr, msgs[i].len);
- if (msgs[i].len < 1) {
+ if (msgs[i].len < 1 ||
+ msgs[i].len > ARRAY_SIZE(st->data) - 5) {
ret = -EIO;
goto err;
}
--
2.43.0

syzbot

unread,
Apr 21, 2025, 10:58:07 AMApr 21
to con...@arnaud-lcm.com, linux-...@vger.kernel.org, linux...@vger.kernel.org, mch...@kernel.org, syzkall...@googlegroups.com
Hello,

syzbot tried to test the proposed patch but the build/boot failed:

failed to apply patch:
checking file drivers/media/usb/dvb-usb-v2/az6007.c
patch: **** unexpected end of file in patch



Tested on:

commit: 9d7a0577 gcc-15: disable '-Wunterminated-string-initia..
git tree: upstream
kernel config: https://syzkaller.appspot.com/x/.config?x=7a7c679f880028f0
patch: https://syzkaller.appspot.com/x/patch.diff?x=124fcc70580000

Arnaud Lecomte

unread,
Apr 21, 2025, 11:11:44 AMApr 21
to Edward Adam Davis, syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, linux...@vger.kernel.org, mch...@kernel.org, syzkall...@googlegroups.com
Hi Edward,
As I am currently trying over there:
https://syzkaller.appspot.com/text?tag=Patch&x=10f3ac70580000, I think
we also have a race condition related to the disconnection of the usb
device.
What do you think ?

Arnaud

syzbot

unread,
Apr 21, 2025, 12:12:06 PMApr 21
to con...@arnaud-lcm.com, linux-...@vger.kernel.org, linux...@vger.kernel.org, mch...@kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+019295...@syzkaller.appspotmail.com
Tested-by: syzbot+019295...@syzkaller.appspotmail.com

Tested on:

commit: 9d7a0577 gcc-15: disable '-Wunterminated-string-initia..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=14604fcf980000
kernel config: https://syzkaller.appspot.com/x/.config?x=efa83f9a6dd67d67
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=10f3ac70580000

Note: testing is done by a robot and is best-effort only.

Jeongjun Park

unread,
Sep 5, 2025, 10:25:42 AM (2 days ago) Sep 5
to syzbot+019295...@syzkaller.appspotmail.com, syzkall...@googlegroups.com, linux-...@vger.kernel.org, aha3...@gmail.com
#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

---
drivers/media/usb/dvb-usb-v2/az6007.c | 67 +++++++++++++++------------
1 file changed, 37 insertions(+), 30 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..34d28daf4679 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -97,13 +97,20 @@ static struct mt2063_config az6007_mt2063_config = {
.refclock = 36125000,
};

-static int __az6007_read(struct usb_device *udev, u8 req, u16 value,
+static int __az6007_read(struct dvb_usb_device *d, u8 req, u16 value,
u16 index, u8 *b, int blen)
{
+ struct az6007_device_state *st = d_to_priv(d);
int ret;

- ret = usb_control_msg(udev,
- usb_rcvctrlpipe(udev, 0),
+ if (blen > sizeof(st->data)) {
+ pr_err("az6007: tried to read %d bytes, but I2C max size is %lu bytes\n",
+ blen, sizeof(st->data));
+ return -EOPNOTSUPP;
+ }
+
+ ret = usb_control_msg(d->udev,
+ usb_rcvctrlpipe(d->udev, 0),
req,
USB_TYPE_VENDOR | USB_DIR_IN,
value, index, b, blen, 5000);
@@ -125,24 +132,31 @@ static int __az6007_read(struct usb_device *udev, u8 req, u16 value,
static int az6007_read(struct dvb_usb_device *d, u8 req, u16 value,
u16 index, u8 *b, int blen)
{
- struct az6007_device_state *st = d->priv;
+ struct az6007_device_state *st = d_to_priv(d);
int ret;

if (mutex_lock_interruptible(&st->mutex) < 0)
return -EAGAIN;

- ret = __az6007_read(d->udev, req, value, index, b, blen);
+ ret = __az6007_read(d, req, value, index, b, blen);

mutex_unlock(&st->mutex);

return ret;
}

-static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
+static int __az6007_write(struct dvb_usb_device *d, u8 req, u16 value,
u16 index, u8 *b, int blen)
{
+ struct az6007_device_state *st = d_to_priv(d);
int ret;

+ if (blen > sizeof(st->data)) {
+ pr_err("az6007: tried to write %d bytes, but I2C max size is %lu bytes\n",
+ blen, sizeof(st->data));
+ return -EOPNOTSUPP;
+ }
+
if (az6007_xfer_debug) {
printk(KERN_DEBUG "az6007: OUT req: %02x, value: %04x, index: %04x\n",
req, value, index);
@@ -150,14 +164,8 @@ static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
DUMP_PREFIX_NONE, b, blen);
}

- if (blen > 64) {
- pr_err("az6007: tried to write %d bytes, but I2C max size is 64 bytes\n",
- blen);
- return -EOPNOTSUPP;
- }
-
- ret = usb_control_msg(udev,
- usb_sndctrlpipe(udev, 0),
+ ret = usb_control_msg(d->udev,
+ usb_sndctrlpipe(d->udev, 0),
req,
USB_TYPE_VENDOR | USB_DIR_OUT,
value, index, b, blen, 5000);
@@ -172,13 +180,13 @@ static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
static int az6007_write(struct dvb_usb_device *d, u8 req, u16 value,
u16 index, u8 *b, int blen)
{
- struct az6007_device_state *st = d->priv;
+ struct az6007_device_state *st = d_to_priv(d);
int ret;

if (mutex_lock_interruptible(&st->mutex) < 0)
return -EAGAIN;

- ret = __az6007_write(d->udev, req, value, index, b, blen);
+ ret = __az6007_write(d, req, value, index, b, blen);

mutex_unlock(&st->mutex);

@@ -775,13 +783,12 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = 6 + msgs[i + 1].len;
len = msgs[i + 1].len;
- ret = __az6007_read(d->udev, req, value, index,
+ ret = __az6007_read(d, req, value, index,
st->data, length);
if (ret >= len) {
for (j = 0; j < len; j++)
msgs[i + 1].buf[j] = st->data[j + 5];
- } else
- ret = -EIO;
+ }
i++;
} else if (!(msgs[i].flags & I2C_M_RD)) {
/* write bytes */
@@ -797,10 +804,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = msgs[i].len - 1;
len = msgs[i].len - 1;
- for (j = 0; j < len; j++)
- st->data[j] = msgs[i].buf[j + 1];
- ret = __az6007_write(d->udev, req, value, index,
- st->data, length);
+ ret = __az6007_write(d, req, value, index,
+ &msgs[i].buf[1], length);
} else {
/* read bytes */
if (az6007_xfer_debug)
@@ -815,10 +820,12 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr;
length = msgs[i].len + 6;
len = msgs[i].len;
- ret = __az6007_read(d->udev, req, value, index,
+ ret = __az6007_read(d, req, value, index,
st->data, length);
- for (j = 0; j < len; j++)
- msgs[i].buf[j] = st->data[j + 5];
+ if (ret >= len) {
+ for (j = 0; j < len; j++)
+ msgs[i].buf[j] = st->data[j + 5];
+ }
}
if (ret < 0)
goto err;
@@ -855,7 +862,7 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
return -ENOMEM;

/* Try to read the mac address */
- ret = __az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+ ret = az6007_read(d, AZ6007_READ_DATA, 6, 0, mac, 6);
if (ret == 6)
ret = WARM;
else
@@ -864,9 +871,9 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
kfree(mac);

if (ret == COLD) {
- __az6007_write(d->udev, 0x09, 1, 0, NULL, 0);
- __az6007_write(d->udev, 0x00, 0, 0, NULL, 0);
- __az6007_write(d->udev, 0x00, 0, 0, NULL, 0);
+ az6007_write(d, 0x09, 1, 0, NULL, 0);
+ az6007_write(d, 0x00, 0, 0, NULL, 0);
+ az6007_write(d, 0x00, 0, 0, NULL, 0);
}

pr_debug("Device is on %s state\n",
--

syzbot

unread,
Sep 5, 2025, 11:53:07 AM (2 days ago) Sep 5
to aha3...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in az6007_identify_state

usb 2-1: config 0 descriptor??
------------[ cut here ]------------
DEBUG_LOCKS_WARN_ON(lock->magic != lock)
WARNING: CPU: 0 PID: 10 at kernel/locking/mutex.c:577 __mutex_lock_common kernel/locking/mutex.c:577 [inline]
WARNING: CPU: 0 PID: 10 at kernel/locking/mutex.c:577 __mutex_lock+0x3a2/0x1060 kernel/locking/mutex.c:760
Modules linked in:
CPU: 0 UID: 0 PID: 10 Comm: kworker/0:1 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Workqueue: usb_hub_wq hub_event
RIP: 0010:__mutex_lock_common kernel/locking/mutex.c:577 [inline]
RIP: 0010:__mutex_lock+0x3a2/0x1060 kernel/locking/mutex.c:760
Code: 08 84 d2 0f 85 7e 0c 00 00 44 8b 0d 78 89 1a 05 45 85 c9 75 19 90 48 c7 c6 20 57 ad 8b 48 c7 c7 60 56 ad 8b e8 ff 11 ea f5 90 <0f> 0b 90 90 90 e9 b5 fd ff ff 48 8d 85 60 ff ff ff 48 89 df 48 89
RSP: 0018:ffffc900000f6de0 EFLAGS: 00010282
RAX: 0000000000000000 RBX: ffff888032d9c000 RCX: ffffffff817a2388
RDX: ffff88801e2c8000 RSI: ffffffff817a2395 RDI: 0000000000000001
RBP: ffffc900000f6f30 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000001 R12: dffffc0000000000
R13: 0000000000000000 R14: 1ffff9200001edc8 R15: ffffffff8800f287
FS: 0000000000000000(0000) GS:ffff8881246e3000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055ac14aafab0 CR3: 000000007d1e6000 CR4: 00000000003526f0
Call Trace:
<TASK>
az6007_read drivers/media/usb/dvb-usb-v2/az6007.c:138 [inline]
az6007_identify_state+0x97/0x310 drivers/media/usb/dvb-usb-v2/az6007.c:865
dvb_usbv2_probe+0x4cc/0x3e50 drivers/media/usb/dvb-usb-v2/dvb_usb_core.c:947
usb_probe_interface+0x300/0xa40 drivers/usb/core/driver.c:396
call_driver_probe drivers/base/dd.c:581 [inline]
really_probe+0x241/0xa90 drivers/base/dd.c:659
__driver_probe_device+0x1de/0x440 drivers/base/dd.c:801
driver_probe_device+0x4c/0x1b0 drivers/base/dd.c:831
__device_attach_driver+0x1df/0x310 drivers/base/dd.c:959
bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:462
__device_attach+0x1e4/0x4b0 drivers/base/dd.c:1031
bus_probe_device+0x17f/0x1c0 drivers/base/bus.c:537
device_add+0x1148/0x1aa0 drivers/base/core.c:3689
usb_set_configuration+0x1187/0x1e20 drivers/usb/core/message.c:2210
usb_generic_driver_probe+0xb1/0x110 drivers/usb/core/generic.c:250
usb_probe_device+0xef/0x3e0 drivers/usb/core/driver.c:291
call_driver_probe drivers/base/dd.c:581 [inline]
really_probe+0x241/0xa90 drivers/base/dd.c:659
__driver_probe_device+0x1de/0x440 drivers/base/dd.c:801
driver_probe_device+0x4c/0x1b0 drivers/base/dd.c:831
__device_attach_driver+0x1df/0x310 drivers/base/dd.c:959
bus_for_each_drv+0x159/0x1e0 drivers/base/bus.c:462
__device_attach+0x1e4/0x4b0 drivers/base/dd.c:1031
bus_probe_device+0x17f/0x1c0 drivers/base/bus.c:537
device_add+0x1148/0x1aa0 drivers/base/core.c:3689
usb_new_device+0xd07/0x1a60 drivers/usb/core/hub.c:2694
hub_port_connect drivers/usb/core/hub.c:5566 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5706 [inline]
port_event drivers/usb/core/hub.c:5870 [inline]
hub_event+0x2f34/0x4fe0 drivers/usb/core/hub.c:5952
process_one_work+0x9cc/0x1b70 kernel/workqueue.c:3236
process_scheduled_works kernel/workqueue.c:3319 [inline]
worker_thread+0x6c8/0xf10 kernel/workqueue.c:3400
kthread+0x3c2/0x780 kernel/kthread.c:463
ret_from_fork+0x5d4/0x6f0 arch/x86/kernel/process.c:148
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>


Tested on:

commit: d69eb204 Merge tag 'net-6.17-rc5' of git://git.kernel...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=112dc962580000
kernel config: https://syzkaller.appspot.com/x/.config?x=2b271b97d244fd0a
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=12c9c962580000

Jeongjun Park

unread,
Sep 5, 2025, 12:06:51 PM (2 days ago) Sep 5
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com, aha3...@gmail.com
drivers/media/usb/dvb-usb-v2/az6007.c | 70 +++++++++++++++------------
1 file changed, 38 insertions(+), 32 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..af750840503e 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -97,13 +97,19 @@ static struct mt2063_config az6007_mt2063_config = {
.refclock = 36125000,
};

-static int __az6007_read(struct usb_device *udev, u8 req, u16 value,
- u16 index, u8 *b, int blen)
+static int __az6007_read(struct dvb_usb_device *d, struct az6007_device_state *st,
+ u8 req, u16 value, u16 index, u8 *b, int blen)
{
int ret;

- ret = usb_control_msg(udev,
- usb_rcvctrlpipe(udev, 0),
+ if (blen > sizeof(st->data)) {
+ pr_err("az6007: tried to read %d bytes, but I2C max size is %lu bytes\n",
+ blen, sizeof(st->data));
+ return -EOPNOTSUPP;
+ }
+
+ ret = usb_control_msg(d->udev,
+ usb_rcvctrlpipe(d->udev, 0),
req,
USB_TYPE_VENDOR | USB_DIR_IN,
value, index, b, blen, 5000);
@@ -125,24 +131,30 @@ static int __az6007_read(struct usb_device *udev, u8 req, u16 value,
static int az6007_read(struct dvb_usb_device *d, u8 req, u16 value,
u16 index, u8 *b, int blen)
{
- struct az6007_device_state *st = d->priv;
+ struct az6007_device_state *st = d_to_priv(d);
int ret;

if (mutex_lock_interruptible(&st->mutex) < 0)
return -EAGAIN;

- ret = __az6007_read(d->udev, req, value, index, b, blen);
+ ret = __az6007_read(d, st, req, value, index, b, blen);

mutex_unlock(&st->mutex);

return ret;
}

-static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
- u16 index, u8 *b, int blen)
+static int __az6007_write(struct dvb_usb_device *d, struct az6007_device_state *st,
+ u8 req, u16 value, u16 index, u8 *b, int blen)
{
int ret;

+ if (blen > sizeof(st->data)) {
+ pr_err("az6007: tried to write %d bytes, but I2C max size is %lu bytes\n",
+ blen, sizeof(st->data));
+ return -EOPNOTSUPP;
+ }
+
if (az6007_xfer_debug) {
printk(KERN_DEBUG "az6007: OUT req: %02x, value: %04x, index: %04x\n",
req, value, index);
@@ -150,14 +162,8 @@ static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
DUMP_PREFIX_NONE, b, blen);
}

- if (blen > 64) {
- pr_err("az6007: tried to write %d bytes, but I2C max size is 64 bytes\n",
- blen);
- return -EOPNOTSUPP;
- }
-
- ret = usb_control_msg(udev,
- usb_sndctrlpipe(udev, 0),
+ ret = usb_control_msg(d->udev,
+ usb_sndctrlpipe(d->udev, 0),
req,
USB_TYPE_VENDOR | USB_DIR_OUT,
value, index, b, blen, 5000);
@@ -172,13 +178,13 @@ static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
static int az6007_write(struct dvb_usb_device *d, u8 req, u16 value,
u16 index, u8 *b, int blen)
{
- struct az6007_device_state *st = d->priv;
+ struct az6007_device_state *st = d_to_priv(d);
int ret;

if (mutex_lock_interruptible(&st->mutex) < 0)
return -EAGAIN;

- ret = __az6007_write(d->udev, req, value, index, b, blen);
+ ret = __az6007_write(d, st, req, value, index, b, blen);

mutex_unlock(&st->mutex);

@@ -775,13 +781,12 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = 6 + msgs[i + 1].len;
len = msgs[i + 1].len;
- ret = __az6007_read(d->udev, req, value, index,
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
if (ret >= len) {
for (j = 0; j < len; j++)
msgs[i + 1].buf[j] = st->data[j + 5];
- } else
- ret = -EIO;
+ }
i++;
} else if (!(msgs[i].flags & I2C_M_RD)) {
/* write bytes */
@@ -797,10 +802,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = msgs[i].len - 1;
len = msgs[i].len - 1;
- for (j = 0; j < len; j++)
- st->data[j] = msgs[i].buf[j + 1];
- ret = __az6007_write(d->udev, req, value, index,
- st->data, length);
+ ret = __az6007_write(d, st, req, value, index,
+ &msgs[i].buf[1], length);
} else {
/* read bytes */
if (az6007_xfer_debug)
@@ -815,10 +818,12 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr;
length = msgs[i].len + 6;
len = msgs[i].len;
- ret = __az6007_read(d->udev, req, value, index,
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- for (j = 0; j < len; j++)
- msgs[i].buf[j] = st->data[j + 5];
+ if (ret >= len) {
+ for (j = 0; j < len; j++)
+ msgs[i].buf[j] = st->data[j + 5];
+ }
}
if (ret < 0)
goto err;
@@ -845,6 +850,7 @@ static const struct i2c_algorithm az6007_i2c_algo = {

static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
{
+ struct az6007_device_state *state = d_to_priv(d);
int ret;
u8 *mac;

@@ -855,7 +861,7 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
return -ENOMEM;

/* Try to read the mac address */
- ret = __az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+ ret = __az6007_read(d, state, AZ6007_READ_DATA, 6, 0, mac, 6);
if (ret == 6)
ret = WARM;
else
@@ -864,9 +870,9 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
kfree(mac);

if (ret == COLD) {
- __az6007_write(d->udev, 0x09, 1, 0, NULL, 0);
- __az6007_write(d->udev, 0x00, 0, 0, NULL, 0);
- __az6007_write(d->udev, 0x00, 0, 0, NULL, 0);
+ __az6007_write(d, state, 0x09, 1, 0, NULL, 0);
+ __az6007_write(d, state, 0x00, 0, 0, NULL, 0);
+ __az6007_write(d, state, 0x00, 0, 0, NULL, 0);

syzbot

unread,
Sep 5, 2025, 12:48:04 PM (2 days ago) Sep 5
to aha3...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in az6007_i2c_xfer

------------[ cut here ]------------
DEBUG_LOCKS_WARN_ON(__owner_task(owner) != get_current())
WARNING: CPU: 1 PID: 6699 at kernel/locking/mutex.c:933 __mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Modules linked in:
CPU: 1 UID: 0 PID: 6699 Comm: syz.3.19 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
RIP: 0010:__mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Code: 08 84 c9 0f 85 78 02 00 00 44 8b 15 f2 d0 1a 05 45 85 d2 75 19 90 48 c7 c6 a0 5a ad 8b 48 c7 c7 60 56 ad 8b e8 79 59 ea f5 90 <0f> 0b 90 90 90 48 c7 c1 80 40 e3 9a 48 b8 00 00 00 00 00 fc ff df
RSP: 0018:ffffc9000381f938 EFLAGS: 00010286
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff817a2388
RDX: ffff888030cbc880 RSI: ffffffff817a2395 RDI: 0000000000000001
RBP: 1ffff92000703f2c R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000003
R13: fffffbfff35c6810 R14: ffffc9000381f9c0 R15: ffff888022ff8000
FS: 00007fd9a0eac6c0(0000) GS:ffff8881247e3000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000557fb7ffc108 CR3: 0000000022b5f000 CR4: 00000000003526f0
Call Trace:
<TASK>
az6007_i2c_xfer+0x8a3/0xa90 drivers/media/usb/dvb-usb-v2/az6007.c:832
__i2c_transfer+0x6b3/0x2190 drivers/i2c/i2c-core-base.c:2264
i2c_transfer drivers/i2c/i2c-core-base.c:2320 [inline]
i2c_transfer+0x1da/0x380 drivers/i2c/i2c-core-base.c:2296
i2c_transfer_buffer_flags+0x10c/0x190 drivers/i2c/i2c-core-base.c:2348
i2c_master_recv include/linux/i2c.h:79 [inline]
i2cdev_read+0x111/0x280 drivers/i2c/i2c-dev.c:155
do_loop_readv_writev fs/read_write.c:847 [inline]
do_loop_readv_writev fs/read_write.c:835 [inline]
vfs_readv+0x5be/0x8b0 fs/read_write.c:1020
do_preadv+0x1a6/0x270 fs/read_write.c:1132
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fd99ff8e169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fd9a0eac038 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007fd9a01b5fa0 RCX: 00007fd99ff8e169
RDX: 0000000000000001 RSI: 00002000000025c0 RDI: 0000000000000004
RBP: 00007fd9a0010a68 R08: 000000000000007e R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fd9a01b5fa0 R15: 00007fffaa2a4bc8
</TASK>


Tested on:

commit: d69eb204 Merge tag 'net-6.17-rc5' of git://git.kernel...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=10a31962580000
kernel config: https://syzkaller.appspot.com/x/.config?x=2b271b97d244fd0a
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=13626134580000

Jeongjun Park

unread,
Sep 5, 2025, 10:58:46 PM (2 days ago) Sep 5
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com, aha3...@gmail.com
drivers/media/usb/dvb-usb-v2/az6007.c | 72 +++++++++++++++------------
1 file changed, 39 insertions(+), 33 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..5de511ffd210 100644
+ if (blen > sizeof(st->data) - 1) {
- if (ret >= len) {
+ if (ret >= len + 5) {
+ if (ret >= len + 5) {

syzbot

unread,
Sep 5, 2025, 11:16:03 PM (2 days ago) Sep 5
to aha3...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in az6007_i2c_xfer

------------[ cut here ]------------
DEBUG_LOCKS_WARN_ON(__owner_task(owner) != get_current())
WARNING: CPU: 0 PID: 6596 at kernel/locking/mutex.c:933 __mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Modules linked in:
CPU: 0 UID: 0 PID: 6596 Comm: syz.0.16 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
RIP: 0010:__mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Code: 08 84 c9 0f 85 78 02 00 00 44 8b 15 f2 ba 1a 05 45 85 d2 75 19 90 48 c7 c6 a0 5a ad 8b 48 c7 c7 60 56 ad 8b e8 79 39 ea f5 90 <0f> 0b 90 90 90 48 c7 c1 80 60 e3 9a 48 b8 00 00 00 00 00 fc ff df
RSP: 0018:ffffc9000363f930 EFLAGS: 00010282
RAX: 0000000000000000 RBX: ffff8880349e8000 RCX: ffffffff817a2388
RDX: ffff888031ecc880 RSI: ffffffff817a2395 RDI: 0000000000000001
RBP: 1ffff920006c7f2b R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000003
R13: fffffbfff35c6c10 R14: ffffc9000363f9b8 R15: ffff88807bb38000
FS: 00007f69a67d26c0(0000) GS:ffff8881246e1000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fc57ebcf368 CR3: 0000000074c33000 CR4: 00000000003526f0
Call Trace:
<TASK>
az6007_i2c_xfer+0x8c5/0xaf0 drivers/media/usb/dvb-usb-v2/az6007.c:832
__i2c_transfer+0x6b6/0x2190 drivers/i2c/i2c-core-base.c:2264
i2c_transfer drivers/i2c/i2c-core-base.c:2320 [inline]
i2c_transfer+0x1da/0x380 drivers/i2c/i2c-core-base.c:2296
i2c_transfer_buffer_flags+0x10c/0x190 drivers/i2c/i2c-core-base.c:2348
i2c_master_recv include/linux/i2c.h:79 [inline]
i2cdev_read+0x111/0x280 drivers/i2c/i2c-dev.c:155
do_loop_readv_writev fs/read_write.c:847 [inline]
do_loop_readv_writev fs/read_write.c:835 [inline]
vfs_readv+0x5c1/0x8b0 fs/read_write.c:1020
do_preadv+0x1a6/0x270 fs/read_write.c:1132
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f69a598e169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f69a67d2038 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007f69a5bb5fa0 RCX: 00007f69a598e169
RDX: 0000000000000001 RSI: 00002000000025c0 RDI: 0000000000000004
RBP: 00007f69a5a10a68 R08: 000000000000007e R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f69a5bb5fa0 R15: 00007ffe339695e8
</TASK>


Tested on:

commit: d1d10cea Merge tag 'perf-tools-fixes-for-v6.17-2025-09..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1028ba42580000
kernel config: https://syzkaller.appspot.com/x/.config?x=bce5d4c1cf285a6c
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=17dee134580000

Jeongjun Park

unread,
Sep 5, 2025, 11:32:53 PM (2 days ago) Sep 5
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com, aha3...@gmail.com

syzbot

unread,
Sep 6, 2025, 12:12:08 AM (yesterday) Sep 6
to aha3...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
UBSAN: array-index-out-of-bounds in az6007_i2c_xfer

usb read operation failed. (-71)
------------[ cut here ]------------
UBSAN: array-index-out-of-bounds in drivers/media/usb/dvb-usb-v2/az6007.c:821:30
index 4096 is out of range for type 'unsigned char [4096]'
CPU: 1 UID: 0 PID: 6553 Comm: syz.1.17 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x16c/0x1f0 lib/dump_stack.c:120
ubsan_epilogue lib/ubsan.c:233 [inline]
__ubsan_handle_out_of_bounds+0x11c/0x160 lib/ubsan.c:455
az6007_i2c_xfer+0x549/0xc30 drivers/media/usb/dvb-usb-v2/az6007.c:821
__i2c_transfer+0x6b6/0x2190 drivers/i2c/i2c-core-base.c:2264
i2c_transfer drivers/i2c/i2c-core-base.c:2320 [inline]
i2c_transfer+0x1da/0x380 drivers/i2c/i2c-core-base.c:2296
i2c_transfer_buffer_flags+0x10c/0x190 drivers/i2c/i2c-core-base.c:2348
i2c_master_recv include/linux/i2c.h:79 [inline]
i2cdev_read+0x111/0x280 drivers/i2c/i2c-dev.c:155
do_loop_readv_writev fs/read_write.c:847 [inline]
do_loop_readv_writev fs/read_write.c:835 [inline]
vfs_readv+0x5c1/0x8b0 fs/read_write.c:1020
do_preadv+0x1a6/0x270 fs/read_write.c:1132
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7faff858e169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007faff9313038 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007faff87b5fa0 RCX: 00007faff858e169
RDX: 0000000000000001 RSI: 00002000000025c0 RDI: 0000000000000004
RBP: 00007faff8610a68 R08: 000000000000007e R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007faff87b5fa0 R15: 00007ffe8b6c0b08
</TASK>
---[ end trace ]---


Tested on:

commit: d1d10cea Merge tag 'perf-tools-fixes-for-v6.17-2025-09..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16c5e134580000
kernel config: https://syzkaller.appspot.com/x/.config?x=bce5d4c1cf285a6c
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40

Note: no patches were applied.

Jeongjun Park

unread,
Sep 6, 2025, 12:56:15 AM (yesterday) Sep 6
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com, aha3...@gmail.com
---
drivers/media/usb/dvb-usb-v2/az6007.c | 79 +++++++++++++++------------
1 file changed, 45 insertions(+), 34 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..f9273e3005ec 100644
@@ -752,8 +758,12 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
int length;
u8 req, addr;

- if (mutex_lock_interruptible(&st->mutex) < 0)
+ if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN;
+ if (mutex_lock_interruptible(&st->mutex) < 0) {
+ mutex_unlock(&d->i2c_mutex);
+ return -EAGAIN;
+ }

for (i = 0; i < num; i++) {
addr = msgs[i].addr << 1;
@@ -775,13 +785,12 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = 6 + msgs[i + 1].len;
len = msgs[i + 1].len;
- ret = __az6007_read(d->udev, req, value, index,
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- if (ret >= len) {
+ if (ret >= len + 5) {
for (j = 0; j < len; j++)
msgs[i + 1].buf[j] = st->data[j + 5];
- } else
- ret = -EIO;
+ }
i++;
} else if (!(msgs[i].flags & I2C_M_RD)) {
/* write bytes */
@@ -797,10 +806,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = msgs[i].len - 1;
len = msgs[i].len - 1;
- for (j = 0; j < len; j++)
- st->data[j] = msgs[i].buf[j + 1];
- ret = __az6007_write(d->udev, req, value, index,
- st->data, length);
+ ret = __az6007_write(d, st, req, value, index,
+ &msgs[i].buf[1], length);
} else {
/* read bytes */
if (az6007_xfer_debug)
@@ -815,16 +822,19 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr;
length = msgs[i].len + 6;
len = msgs[i].len;
- ret = __az6007_read(d->udev, req, value, index,
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- for (j = 0; j < len; j++)
- msgs[i].buf[j] = st->data[j + 5];
+ if (ret >= len + 5) {
+ for (j = 0; j < len; j++)
+ msgs[i].buf[j] = st->data[j + 5];
+ }
}
if (ret < 0)
goto err;
}
err:
mutex_unlock(&st->mutex);
+ mutex_unlock(&d->i2c_mutex);

if (ret < 0) {
pr_info("%s ERROR: %i\n", __func__, ret);
@@ -845,6 +855,7 @@ static const struct i2c_algorithm az6007_i2c_algo = {

static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
{
+ struct az6007_device_state *state = d_to_priv(d);
int ret;
u8 *mac;

@@ -855,7 +866,7 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
return -ENOMEM;

/* Try to read the mac address */
- ret = __az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+ ret = __az6007_read(d, state, AZ6007_READ_DATA, 6, 0, mac, 6);
if (ret == 6)
ret = WARM;
else
@@ -864,9 +875,9 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)

syzbot

unread,
Sep 6, 2025, 1:54:05 AM (yesterday) Sep 6
to aha3...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in az6007_i2c_xfer

az6007: tried to read 4109 bytes, but I2C max size is 4096 bytes
------------[ cut here ]------------
DEBUG_LOCKS_WARN_ON(__owner_task(owner) != get_current())
WARNING: CPU: 0 PID: 6583 at kernel/locking/mutex.c:933 __mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Modules linked in:
CPU: 0 UID: 0 PID: 6583 Comm: syz.0.16 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
RIP: 0010:__mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Code: 08 84 c9 0f 85 78 02 00 00 44 8b 15 f2 ba 1a 05 45 85 d2 75 19 90 48 c7 c6 a0 5a ad 8b 48 c7 c7 60 56 ad 8b e8 79 39 ea f5 90 <0f> 0b 90 90 90 48 c7 c1 80 60 e3 9a 48 b8 00 00 00 00 00 fc ff df
RSP: 0018:ffffc90003a77928 EFLAGS: 00010286
RAX: 0000000000000000 RBX: ffff888031910000 RCX: ffffffff817a2388
RDX: ffff8880269ca440 RSI: ffffffff817a2395 RDI: 0000000000000001
RBP: 1ffff9200074ef2a R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000003
R13: fffffbfff35c6c10 R14: ffffc90003a779b0 R15: ffff888034e30000
FS: 00007f21b41c16c0(0000) GS:ffff8881246e1000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffff5afe0c8 CR3: 000000005b1e0000 CR4: 00000000003526f0
Call Trace:
<TASK>
az6007_i2c_xfer+0x619/0xb30 drivers/media/usb/dvb-usb-v2/az6007.c:836
__i2c_transfer+0x6b6/0x2190 drivers/i2c/i2c-core-base.c:2264
i2c_transfer drivers/i2c/i2c-core-base.c:2320 [inline]
i2c_transfer+0x1da/0x380 drivers/i2c/i2c-core-base.c:2296
i2c_transfer_buffer_flags+0x10c/0x190 drivers/i2c/i2c-core-base.c:2348
i2c_master_recv include/linux/i2c.h:79 [inline]
i2cdev_read+0x111/0x280 drivers/i2c/i2c-dev.c:155
do_loop_readv_writev fs/read_write.c:847 [inline]
do_loop_readv_writev fs/read_write.c:835 [inline]
vfs_readv+0x5c1/0x8b0 fs/read_write.c:1020
do_preadv+0x1a6/0x270 fs/read_write.c:1132
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f21b338e169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f21b41c1038 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007f21b35b5fa0 RCX: 00007f21b338e169
RDX: 0000000000000001 RSI: 00002000000025c0 RDI: 0000000000000004
RBP: 00007f21b3410a68 R08: 000000000000007e R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f21b35b5fa0 R15: 00007fff05cabdd8
</TASK>


Tested on:

commit: d1d10cea Merge tag 'perf-tools-fixes-for-v6.17-2025-09..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1772ba42580000
kernel config: https://syzkaller.appspot.com/x/.config?x=bce5d4c1cf285a6c
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=13080962580000

Jeongjun Park

unread,
Sep 6, 2025, 6:04:22 AM (yesterday) Sep 6
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com, aha3...@gmail.com
drivers/media/usb/dvb-usb-v2/az6007.c | 100 ++++++++++++++++----------
1 file changed, 63 insertions(+), 37 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..86ee62fd5f4f 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -97,19 +97,30 @@ static struct mt2063_config az6007_mt2063_config = {
.refclock = 36125000,
};

-static int __az6007_read(struct usb_device *udev, u8 req, u16 value,
- u16 index, u8 *b, int blen)
+static int __az6007_read(struct dvb_usb_device *d, struct az6007_device_state *st,
+ u8 req, u16 value, u16 index, u8 *b, int blen)
{
int ret;

- ret = usb_control_msg(udev,
- usb_rcvctrlpipe(udev, 0),
+ if (mutex_lock_interruptible(&d->usb_mutex) < 0)
+ return -EAGAIN;
+
+ if (blen > sizeof(st->data)) {
+ pr_err("az6007: tried to read %d bytes, but I2C max size is %lu bytes\n",
+ blen, sizeof(st->data));
+ ret = -EOPNOTSUPP;
+ goto end_unlock;
+ }
+
+ ret = usb_control_msg(d->udev,
+ usb_rcvctrlpipe(d->udev, 0),
req,
USB_TYPE_VENDOR | USB_DIR_IN,
value, index, b, blen, 5000);
if (ret < 0) {
pr_warn("usb read operation failed. (%d)\n", ret);
- return -EIO;
+ ret = -EIO;
+ goto end_unlock;
}

if (az6007_xfer_debug) {
@@ -119,30 +130,42 @@ static int __az6007_read(struct usb_device *udev, u8 req, u16 value,
DUMP_PREFIX_NONE, b, blen);
}

+end_unlock:
+ mutex_unlock(&d->usb_mutex);
return ret;
}

static int az6007_read(struct dvb_usb_device *d, u8 req, u16 value,
u16 index, u8 *b, int blen)
{
- struct az6007_device_state *st = d->priv;
+ struct az6007_device_state *st = d_to_priv(d);
int ret;

if (mutex_lock_interruptible(&st->mutex) < 0)
return -EAGAIN;

- ret = __az6007_read(d->udev, req, value, index, b, blen);
+ ret = __az6007_read(d, st, req, value, index, b, blen);

mutex_unlock(&st->mutex);

return ret;
}

-static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
- u16 index, u8 *b, int blen)
+static int __az6007_write(struct dvb_usb_device *d, struct az6007_device_state *st,
+ u8 req, u16 value, u16 index, u8 *b, int blen)
{
int ret;

+ if (mutex_lock_interruptible(&d->usb_mutex) < 0)
+ return -EAGAIN;
+
+ if (blen > sizeof(st->data) - 1) {
+ pr_err("az6007: tried to write %d bytes, but I2C max size is %lu bytes\n",
+ blen, sizeof(st->data));
+ ret = -EOPNOTSUPP;
+ goto end_unlock;
+ }
+
if (az6007_xfer_debug) {
printk(KERN_DEBUG "az6007: OUT req: %02x, value: %04x, index: %04x\n",
req, value, index);
@@ -150,35 +173,33 @@ static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
DUMP_PREFIX_NONE, b, blen);
}

- if (blen > 64) {
- pr_err("az6007: tried to write %d bytes, but I2C max size is 64 bytes\n",
- blen);
- return -EOPNOTSUPP;
- }
-
- ret = usb_control_msg(udev,
- usb_sndctrlpipe(udev, 0),
+ ret = usb_control_msg(d->udev,
+ usb_sndctrlpipe(d->udev, 0),
req,
USB_TYPE_VENDOR | USB_DIR_OUT,
value, index, b, blen, 5000);
if (ret != blen) {
pr_err("usb write operation failed. (%d)\n", ret);
- return -EIO;
+ ret = -EIO;
+ goto end_unlock;
}

- return 0;
+ ret = 0;
+end_unlock:
+ mutex_unlock(&d->usb_mutex);
+ return ret;
}

static int az6007_write(struct dvb_usb_device *d, u8 req, u16 value,
u16 index, u8 *b, int blen)
{
- struct az6007_device_state *st = d->priv;
+ struct az6007_device_state *st = d_to_priv(d);
int ret;

if (mutex_lock_interruptible(&st->mutex) < 0)
return -EAGAIN;

- ret = __az6007_write(d->udev, req, value, index, b, blen);
+ ret = __az6007_write(d, st, req, value, index, b, blen);

mutex_unlock(&st->mutex);

@@ -752,8 +773,12 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
int length;
u8 req, addr;

- if (mutex_lock_interruptible(&st->mutex) < 0)
+ if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
+ return -EAGAIN;
+ if (mutex_lock_interruptible(&st->mutex) < 0) {
+ mutex_unlock(&d->i2c_mutex);
return -EAGAIN;
+ }

for (i = 0; i < num; i++) {
addr = msgs[i].addr << 1;
@@ -775,13 +800,12 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = 6 + msgs[i + 1].len;
len = msgs[i + 1].len;
- ret = __az6007_read(d->udev, req, value, index,
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- if (ret >= len) {
+ if (ret >= len + 5) {
for (j = 0; j < len; j++)
msgs[i + 1].buf[j] = st->data[j + 5];
- } else
- ret = -EIO;
+ }
i++;
} else if (!(msgs[i].flags & I2C_M_RD)) {
/* write bytes */
@@ -797,10 +821,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = msgs[i].len - 1;
len = msgs[i].len - 1;
- for (j = 0; j < len; j++)
- st->data[j] = msgs[i].buf[j + 1];
- ret = __az6007_write(d->udev, req, value, index,
- st->data, length);
+ ret = __az6007_write(d, st, req, value, index,
+ &msgs[i].buf[1], length);
} else {
/* read bytes */
if (az6007_xfer_debug)
@@ -815,16 +837,19 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr;
length = msgs[i].len + 6;
len = msgs[i].len;
- ret = __az6007_read(d->udev, req, value, index,
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- for (j = 0; j < len; j++)
- msgs[i].buf[j] = st->data[j + 5];
+ if (ret >= len + 5) {
+ for (j = 0; j < len; j++)
+ msgs[i].buf[j] = st->data[j + 5];
+ }
}
if (ret < 0)
goto err;
}
err:
mutex_unlock(&st->mutex);
+ mutex_unlock(&d->i2c_mutex);

if (ret < 0) {
pr_info("%s ERROR: %i\n", __func__, ret);
@@ -845,6 +870,7 @@ static const struct i2c_algorithm az6007_i2c_algo = {

static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
{
+ struct az6007_device_state *state = d_to_priv(d);
int ret;
u8 *mac;

@@ -855,7 +881,7 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
return -ENOMEM;

/* Try to read the mac address */
- ret = __az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+ ret = __az6007_read(d, state, AZ6007_READ_DATA, 6, 0, mac, 6);
if (ret == 6)
ret = WARM;
else
@@ -864,9 +890,9 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)

syzbot

unread,
Sep 6, 2025, 6:24:05 AM (yesterday) Sep 6
to aha3...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in az6007_i2c_xfer

az6007: tried to read 4109 bytes, but I2C max size is 4096 bytes
------------[ cut here ]------------
DEBUG_LOCKS_WARN_ON(__owner_task(owner) != get_current())
WARNING: CPU: 0 PID: 6849 at kernel/locking/mutex.c:933 __mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Modules linked in:
CPU: 0 UID: 0 PID: 6849 Comm: syz.4.34 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
RIP: 0010:__mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Code: 08 84 c9 0f 85 78 02 00 00 44 8b 15 f2 ba 1a 05 45 85 d2 75 19 90 48 c7 c6 a0 5a ad 8b 48 c7 c7 60 56 ad 8b e8 79 39 ea f5 90 <0f> 0b 90 90 90 48 c7 c1 80 60 e3 9a 48 b8 00 00 00 00 00 fc ff df
RSP: 0018:ffffc9000423f928 EFLAGS: 00010286
RAX: 0000000000000000 RBX: ffff88802ada2440 RCX: ffffffff817a2388
RDX: ffff888031ee8000 RSI: ffffffff817a2395 RDI: 0000000000000001
RBP: 1ffff92000847f2a R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 284e4f5f4e524157 R12: 0000000000000003
R13: fffffbfff35c6c10 R14: ffffc9000423f9b0 R15: ffff88803569c000
FS: 00007f0c02ffb6c0(0000) GS:ffff8881246e1000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00005652c153a008 CR3: 000000005260a000 CR4: 00000000003526f0
Call Trace:
<TASK>
az6007_i2c_xfer+0x619/0xb30 drivers/media/usb/dvb-usb-v2/az6007.c:851
__i2c_transfer+0x6b6/0x2190 drivers/i2c/i2c-core-base.c:2264
i2c_transfer drivers/i2c/i2c-core-base.c:2320 [inline]
i2c_transfer+0x1da/0x380 drivers/i2c/i2c-core-base.c:2296
i2c_transfer_buffer_flags+0x10c/0x190 drivers/i2c/i2c-core-base.c:2348
i2c_master_recv include/linux/i2c.h:79 [inline]
i2cdev_read+0x111/0x280 drivers/i2c/i2c-dev.c:155
do_loop_readv_writev fs/read_write.c:847 [inline]
do_loop_readv_writev fs/read_write.c:835 [inline]
vfs_readv+0x5c1/0x8b0 fs/read_write.c:1020
do_preadv+0x1a6/0x270 fs/read_write.c:1132
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f0c0218e169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f0c02ffb038 EFLAGS: 00000246
ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007f0c023b5fa0 RCX: 00007f0c0218e169
RDX: 0000000000000001 RSI: 00002000000025c0 RDI: 0000000000000004
RBP: 00007f0c02210a68 R08: 000000000000007e R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f0c023b5fa0 R15: 00007ffc233dccf8
</TASK>


Tested on:

commit: d1d10cea Merge tag 'perf-tools-fixes-for-v6.17-2025-09..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1351a962580000
kernel config: https://syzkaller.appspot.com/x/.config?x=bce5d4c1cf285a6c
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=1341a962580000

Jeongjun Park

unread,
Sep 6, 2025, 6:56:17 AM (yesterday) Sep 6
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com, aha3...@gmail.com
drivers/media/usb/dvb-usb-v2/az6007.c | 108 +++++++++++++++++---------
1 file changed, 71 insertions(+), 37 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..72ce96e1418b 100644
@@ -752,8 +773,13 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
int length;
u8 req, addr;

- if (mutex_lock_interruptible(&st->mutex) < 0)
+ if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
+ return -EAGAIN;
+ if (mutex_lock_interruptible(&st->mutex) < 0) {
+ mutex_unlock(&d->i2c_mutex);
return -EAGAIN;
+ }
+ printk(KERN_INFO "az6007_i2c_xfer 1 : %lx", atomic_long_read(&st->mutex.owner));

for (i = 0; i < num; i++) {
addr = msgs[i].addr << 1;
@@ -775,13 +801,14 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = 6 + msgs[i + 1].len;
len = msgs[i + 1].len;
- ret = __az6007_read(d->udev, req, value, index,
+ printk(KERN_INFO "az6007_i2c_xfer 2 : %lx", atomic_long_read(&st->mutex.owner));
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- if (ret >= len) {
+ printk(KERN_INFO "az6007_i2c_xfer 3 : %lx", atomic_long_read(&st->mutex.owner));
+ if (ret >= len + 5) {
for (j = 0; j < len; j++)
msgs[i + 1].buf[j] = st->data[j + 5];
- } else
- ret = -EIO;
+ }
i++;
} else if (!(msgs[i].flags & I2C_M_RD)) {
/* write bytes */
@@ -797,10 +824,10 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = msgs[i].len - 1;
len = msgs[i].len - 1;
- for (j = 0; j < len; j++)
- st->data[j] = msgs[i].buf[j + 1];
- ret = __az6007_write(d->udev, req, value, index,
- st->data, length);
+ printk(KERN_INFO "az6007_i2c_xfer 4 : %lx", atomic_long_read(&st->mutex.owner));
+ ret = __az6007_write(d, st, req, value, index,
+ &msgs[i].buf[1], length);
+ printk(KERN_INFO "az6007_i2c_xfer 5 : %lx", atomic_long_read(&st->mutex.owner));
} else {
/* read bytes */
if (az6007_xfer_debug)
@@ -815,16 +842,22 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr;
length = msgs[i].len + 6;
len = msgs[i].len;
- ret = __az6007_read(d->udev, req, value, index,
+ printk(KERN_INFO "az6007_i2c_xfer 6 : %lx", atomic_long_read(&st->mutex.owner));
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- for (j = 0; j < len; j++)
- msgs[i].buf[j] = st->data[j + 5];
+ printk(KERN_INFO "az6007_i2c_xfer 7 : %lx", atomic_long_read(&st->mutex.owner));
+ if (ret >= len + 5) {
+ for (j = 0; j < len; j++)
+ msgs[i].buf[j] = st->data[j + 5];
+ }
}
if (ret < 0)
goto err;
}
err:
+ printk(KERN_INFO "az6007_i2c_xfer 8 : %lx", atomic_long_read(&st->mutex.owner));
mutex_unlock(&st->mutex);
+ mutex_unlock(&d->i2c_mutex);

if (ret < 0) {
pr_info("%s ERROR: %i\n", __func__, ret);
@@ -845,6 +878,7 @@ static const struct i2c_algorithm az6007_i2c_algo = {

static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
{
+ struct az6007_device_state *state = d_to_priv(d);
int ret;
u8 *mac;

@@ -855,7 +889,7 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
return -ENOMEM;

/* Try to read the mac address */
- ret = __az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+ ret = __az6007_read(d, state, AZ6007_READ_DATA, 6, 0, mac, 6);
if (ret == 6)
ret = WARM;
else
@@ -864,9 +898,9 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)

syzbot

unread,
Sep 6, 2025, 8:28:07 AM (yesterday) Sep 6
to aha3...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in az6007_i2c_xfer

az6007_i2c_xfer 1 : ffff8880273c0000
az6007_i2c_xfer 6 : ffff8880273c0000
az6007: tried to read 4109 bytes, but I2C max size is 4096 bytes
az6007_i2c_xfer 7 : 0
az6007_i2c_xfer 8 : 0
------------[ cut here ]------------
DEBUG_LOCKS_WARN_ON(__owner_task(owner) != get_current())
WARNING: CPU: 0 PID: 6819 at kernel/locking/mutex.c:933 __mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Modules linked in:
CPU: 0 UID: 0 PID: 6819 Comm: syz.0.46 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
RIP: 0010:__mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Code: 08 84 c9 0f 85 78 02 00 00 44 8b 15 f2 ac 1a 05 45 85 d2 75 19 90 48 c7 c6 a0 5a ad 8b 48 c7 c7 60 56 ad 8b e8 79 29 ea f5 90 <0f> 0b 90 90 90 48 c7 c1 80 60 e3 9a 48 b8 00 00 00 00 00 fc ff df
RSP: 0018:ffffc90003f77918 EFLAGS: 00010282
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff817a2388
RDX: ffff8880273c0000 RSI: ffffffff817a2395 RDI: 0000000000000001
RBP: 1ffff920007eef28 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000001 R12: 0000000000000003
R13: fffffbfff35c6c10 R14: ffffc90003f779a0 R15: ffff88807cef0000
FS: 00007f6691eda6c0(0000) GS:ffff8881246e1000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00002000000025c0 CR3: 00000000250f0000 CR4: 00000000003526f0
Call Trace:
<TASK>
az6007_i2c_xfer+0x821/0xe50 drivers/media/usb/dvb-usb-v2/az6007.c:859
__i2c_transfer+0x6b6/0x2190 drivers/i2c/i2c-core-base.c:2264
i2c_transfer drivers/i2c/i2c-core-base.c:2320 [inline]
i2c_transfer+0x1da/0x380 drivers/i2c/i2c-core-base.c:2296
i2c_transfer_buffer_flags+0x10c/0x190 drivers/i2c/i2c-core-base.c:2348
i2c_master_recv include/linux/i2c.h:79 [inline]
i2cdev_read+0x111/0x280 drivers/i2c/i2c-dev.c:155
do_loop_readv_writev fs/read_write.c:847 [inline]
do_loop_readv_writev fs/read_write.c:835 [inline]
vfs_readv+0x5c1/0x8b0 fs/read_write.c:1020
do_preadv+0x1a6/0x270 fs/read_write.c:1132
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f6690f8e169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6691eda038 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007f66911b5fa0 RCX: 00007f6690f8e169
RDX: 0000000000000001 RSI: 00002000000025c0 RDI: 0000000000000004
RBP: 00007f6691010a68 R08: 000000000000007e R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f66911b5fa0 R15: 00007ffc5efdc628
</TASK>


Tested on:

commit: d1d10cea Merge tag 'perf-tools-fixes-for-v6.17-2025-09..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=116d5962580000
kernel config: https://syzkaller.appspot.com/x/.config?x=bce5d4c1cf285a6c
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=16d6d312580000

Jeongjun Park

unread,
Sep 6, 2025, 11:24:26 AM (yesterday) Sep 6
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com, aha3...@gmail.com
drivers/media/usb/dvb-usb-v2/az6007.c | 184 ++++++++++++++------------
1 file changed, 103 insertions(+), 81 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..69489cd3a0c4 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -43,6 +43,7 @@ struct az6007_device_state {
struct mutex ca_mutex;
struct dvb_ca_en50221 ca;
unsigned warm:1;
+ unsigned ci_attached:1;
int (*gate_ctrl) (struct dvb_frontend *, int);
unsigned char data[4096];
};
@@ -97,19 +98,30 @@ static struct mt2063_config az6007_mt2063_config = {
@@ -119,30 +131,42 @@ static int __az6007_read(struct usb_device *udev, u8 req, u16 value,
@@ -150,35 +174,33 @@ static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
@@ -574,10 +596,9 @@ static void az6007_ci_uninit(struct dvb_usb_device *d)
}


-static int az6007_ci_init(struct dvb_usb_adapter *adap)
+static int az6007_ci_init(struct dvb_usb_device *d)
{
- struct dvb_usb_device *d = adap_to_d(adap);
- struct az6007_device_state *state = adap_to_priv(adap);
+ struct az6007_device_state *state = d_to_priv(d);
int ret;

pr_debug("%s()\n", __func__);
@@ -594,7 +615,7 @@ static int az6007_ci_init(struct dvb_usb_adapter *adap)
state->ca.poll_slot_status = az6007_ci_poll_slot_status;
state->ca.data = d;

- ret = dvb_ca_en50221_init(&adap->dvb_adap,
+ ret = dvb_ca_en50221_init(&d->adapter[0].dvb_adap,
&state->ca,
0, /* flags */
1);/* n_slots */
@@ -604,6 +625,8 @@ static int az6007_ci_init(struct dvb_usb_adapter *adap)
return ret;
}

+ state->ci_attached = true;
+
pr_debug("CI initialized.\n");

return 0;
@@ -640,8 +663,6 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
st->gate_ctrl = adap->fe[0]->ops.i2c_gate_ctrl;
adap->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;

- az6007_ci_init(adap);
-
return 0;
}

@@ -661,8 +682,6 @@ static int az6007_cablestar_hdci_frontend_attach(struct dvb_usb_adapter *adap)
st->gate_ctrl = adap->fe[0]->ops.i2c_gate_ctrl;
adap->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;

- az6007_ci_init(adap);
-
return 0;
}

@@ -752,8 +771,13 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
int length;
u8 req, addr;

- if (mutex_lock_interruptible(&st->mutex) < 0)
+ if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
+ return -EAGAIN;
+ if (mutex_lock_interruptible(&st->mutex) < 0) {
+ mutex_unlock(&d->i2c_mutex);
return -EAGAIN;
+ }
+ printk(KERN_INFO "az6007_i2c_xfer 1 : %lx", atomic_long_read(&st->mutex.owner));

for (i = 0; i < num; i++) {
addr = msgs[i].addr << 1;
@@ -775,13 +799,14 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = 6 + msgs[i + 1].len;
len = msgs[i + 1].len;
- ret = __az6007_read(d->udev, req, value, index,
+ printk(KERN_INFO "az6007_i2c_xfer 2 : %lx", atomic_long_read(&st->mutex.owner));
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- if (ret >= len) {
+ printk(KERN_INFO "az6007_i2c_xfer 3 : %lx", atomic_long_read(&st->mutex.owner));
+ if (ret >= len + 5) {
for (j = 0; j < len; j++)
msgs[i + 1].buf[j] = st->data[j + 5];
- } else
- ret = -EIO;
+ }
i++;
} else if (!(msgs[i].flags & I2C_M_RD)) {
/* write bytes */
@@ -797,10 +822,10 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = msgs[i].len - 1;
len = msgs[i].len - 1;
- for (j = 0; j < len; j++)
- st->data[j] = msgs[i].buf[j + 1];
- ret = __az6007_write(d->udev, req, value, index,
- st->data, length);
+ printk(KERN_INFO "az6007_i2c_xfer 4 : %lx", atomic_long_read(&st->mutex.owner));
+ ret = __az6007_write(d, st, req, value, index,
+ &msgs[i].buf[1], length);
+ printk(KERN_INFO "az6007_i2c_xfer 5 : %lx", atomic_long_read(&st->mutex.owner));
} else {
/* read bytes */
if (az6007_xfer_debug)
@@ -815,16 +840,22 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr;
length = msgs[i].len + 6;
len = msgs[i].len;
- ret = __az6007_read(d->udev, req, value, index,
+ printk(KERN_INFO "az6007_i2c_xfer 6 : %lx", atomic_long_read(&st->mutex.owner));
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- for (j = 0; j < len; j++)
- msgs[i].buf[j] = st->data[j + 5];
+ printk(KERN_INFO "az6007_i2c_xfer 7 : %lx", atomic_long_read(&st->mutex.owner));
+ if (ret >= len + 5) {
+ for (j = 0; j < len; j++)
+ msgs[i].buf[j] = st->data[j + 5];
+ }
}
if (ret < 0)
goto err;
}
err:
+ printk(KERN_INFO "az6007_i2c_xfer 8 : %lx", atomic_long_read(&st->mutex.owner));
mutex_unlock(&st->mutex);
+ mutex_unlock(&d->i2c_mutex);

if (ret < 0) {
pr_info("%s ERROR: %i\n", __func__, ret);
@@ -845,6 +876,7 @@ static const struct i2c_algorithm az6007_i2c_algo = {

static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
{
+ struct az6007_device_state *state = d_to_priv(d);
int ret;
u8 *mac;

@@ -855,7 +887,7 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
return -ENOMEM;

/* Try to read the mac address */
- ret = __az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+ ret = __az6007_read(d, state, AZ6007_READ_DATA, 6, 0, mac, 6);
if (ret == 6)
ret = WARM;
else
@@ -864,9 +896,9 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
kfree(mac);

if (ret == COLD) {
- __az6007_write(d->udev, 0x09, 1, 0, NULL, 0);
- __az6007_write(d->udev, 0x00, 0, 0, NULL, 0);
- __az6007_write(d->udev, 0x00, 0, 0, NULL, 0);
+ __az6007_write(d, state, 0x09, 1, 0, NULL, 0);
+ __az6007_write(d, state, 0x00, 0, 0, NULL, 0);
+ __az6007_write(d, state, 0x00, 0, 0, NULL, 0);
}

pr_debug("Device is on %s state\n",
@@ -874,13 +906,6 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
return ret;
}

-static void az6007_usb_disconnect(struct usb_interface *intf)
-{
- struct dvb_usb_device *d = usb_get_intfdata(intf);
- az6007_ci_uninit(d);
- dvb_usbv2_disconnect(intf);
-}
-
static int az6007_download_firmware(struct dvb_usb_device *d,
const struct firmware *fw)
{
@@ -889,6 +914,19 @@ static int az6007_download_firmware(struct dvb_usb_device *d,
return cypress_load_firmware(d->udev, fw, CYPRESS_FX2);
}

+static int az6007_init(struct dvb_usb_device *d)
+{
+ return az6007_ci_init(d);
+}
+
+static void az6007_exit(struct dvb_usb_device *d)
+{
+ struct az6007_device_state *state = d_to_priv(d);
+
+ if (state->ci_attached)
+ az6007_ci_uninit(d);
+}
+
/* DVB USB Driver stuff */
static struct dvb_usb_device_properties az6007_props = {
.driver_name = KBUILD_MODNAME,
@@ -906,6 +944,8 @@ static struct dvb_usb_device_properties az6007_props = {
.download_firmware = az6007_download_firmware,
.identify_state = az6007_identify_state,
.power_ctrl = az6007_power_ctrl,
+ .init = az6007_init,
+ .exit = az6007_exit,
.num_adapters = 1,
.adapter = {
{ .stream = DVB_USB_STREAM_BULK(0x02, 10, 4096), }
@@ -929,6 +969,8 @@ static struct dvb_usb_device_properties az6007_cablestar_hdci_props = {
.download_firmware = az6007_download_firmware,
.identify_state = az6007_identify_state,
.power_ctrl = az6007_power_ctrl,
+ .init = az6007_init,
+ .exit = az6007_exit,
.num_adapters = 1,
.adapter = {
{ .stream = DVB_USB_STREAM_BULK(0x02, 10, 4096), }
@@ -949,37 +991,17 @@ static const struct usb_device_id az6007_usb_table[] = {

MODULE_DEVICE_TABLE(usb, az6007_usb_table);

-static int az6007_suspend(struct usb_interface *intf, pm_message_t msg)
-{
- struct dvb_usb_device *d = usb_get_intfdata(intf);
-
- az6007_ci_uninit(d);
- return dvb_usbv2_suspend(intf, msg);
-}
-
-static int az6007_resume(struct usb_interface *intf)
-{
- struct dvb_usb_device *d = usb_get_intfdata(intf);
- struct dvb_usb_adapter *adap = &d->adapter[0];
-
- az6007_ci_init(adap);
- return dvb_usbv2_resume(intf);
-}
-
/* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver az6007_usb_driver = {
- .name = KBUILD_MODNAME,
- .id_table = az6007_usb_table,
- .probe = dvb_usbv2_probe,
- .disconnect = az6007_usb_disconnect,
- .no_dynamic_id = 1,
- .soft_unbind = 1,
- /*
- * FIXME: need to implement reset_resume, likely with
- * dvb-usb-v2 core support
- */
- .suspend = az6007_suspend,
- .resume = az6007_resume,
+ .name = KBUILD_MODNAME,
+ .id_table = az6007_usb_table,
+ .probe = dvb_usbv2_probe,
+ .disconnect = dvb_usbv2_disconnect,
+ .suspend = dvb_usbv2_suspend,
+ .resume = dvb_usbv2_resume,
+ .reset_resume = dvb_usbv2_reset_resume,
+ .no_dynamic_id = 1,
+ .soft_unbind = 1,
};

module_usb_driver(az6007_usb_driver);
--

syzbot

unread,
Sep 6, 2025, 12:09:04 PM (yesterday) Sep 6
to aha3...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in az6007_i2c_xfer

az6007_i2c_xfer 8 : ffff88802743c880
------------[ cut here ]------------
DEBUG_LOCKS_WARN_ON(__owner_task(owner) != get_current())
WARNING: CPU: 1 PID: 7034 at kernel/locking/mutex.c:933 __mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Modules linked in:
CPU: 1 UID: 0 PID: 7034 Comm: syz.3.115 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
RIP: 0010:__mutex_unlock_slowpath+0x528/0x7b0 kernel/locking/mutex.c:933
Code: 08 84 c9 0f 85 78 02 00 00 44 8b 15 f2 ac 1a 05 45 85 d2 75 19 90 48 c7 c6 a0 5a ad 8b 48 c7 c7 60 56 ad 8b e8 79 29 ea f5 90 <0f> 0b 90 90 90 48 c7 c1 80 60 e3 9a 48 b8 00 00 00 00 00 fc ff df
RSP: 0018:ffffc9000420f918 EFLAGS: 00010282
RAX: 0000000000000000 RBX: ffff88802743c880 RCX: ffffffff817a2388
RDX: ffff888027188000 RSI: ffffffff817a2395 RDI: 0000000000000001
RBP: 1ffff92000841f28 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 205d313636365420 R12: 0000000000000003
R13: fffffbfff35c6c10 R14: ffffc9000420f9a0 R15: ffff888029d58000
FS: 00007f0406c336c0(0000) GS:ffff8881247e1000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00002000000025c0 CR3: 0000000062914000 CR4: 00000000003526f0
Call Trace:
<TASK>
az6007_i2c_xfer+0x821/0xe50 drivers/media/usb/dvb-usb-v2/az6007.c:857
__i2c_transfer+0x6b6/0x2190 drivers/i2c/i2c-core-base.c:2264
i2c_transfer drivers/i2c/i2c-core-base.c:2320 [inline]
i2c_transfer+0x1da/0x380 drivers/i2c/i2c-core-base.c:2296
i2c_transfer_buffer_flags+0x10c/0x190 drivers/i2c/i2c-core-base.c:2348
i2c_master_recv include/linux/i2c.h:79 [inline]
i2cdev_read+0x111/0x280 drivers/i2c/i2c-dev.c:155
do_loop_readv_writev fs/read_write.c:847 [inline]
do_loop_readv_writev fs/read_write.c:835 [inline]
vfs_readv+0x5c1/0x8b0 fs/read_write.c:1020
do_preadv+0x1a6/0x270 fs/read_write.c:1132
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f0405d8e169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f0406c33038 EFLAGS: 00000246
ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007f0405fb5fa0 RCX: 00007f0405d8e169
RDX: 0000000000000001 RSI: 00002000000025c0 RDI: 0000000000000004
RBP: 00007f0405e10a68 R08: 000000000000007e R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f0405fb5fa0 R15: 00007ffdf15e6ff8
</TASK>


Tested on:

commit: d1d10cea Merge tag 'perf-tools-fixes-for-v6.17-2025-09..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15986962580000
kernel config: https://syzkaller.appspot.com/x/.config?x=bce5d4c1cf285a6c
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=12cda87c580000

Jeongjun Park

unread,
Sep 6, 2025, 12:40:44 PM (yesterday) Sep 6
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com, aha3...@gmail.com
drivers/media/usb/dvb-usb-v2/az6007.c | 213 +++++++++++++-------------
1 file changed, 108 insertions(+), 105 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..020ab4cb33b5 100644
--- a/drivers/media/usb/dvb-usb-v2/az6007.c
+++ b/drivers/media/usb/dvb-usb-v2/az6007.c
@@ -39,10 +39,10 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
#define AZ6007_READ_IR 0xb4

struct az6007_device_state {
- struct mutex mutex;
struct mutex ca_mutex;
struct dvb_ca_en50221 ca;
unsigned warm:1;
+ unsigned ci_attached:1;
int (*gate_ctrl) (struct dvb_frontend *, int);
unsigned char data[4096];
};
@@ -97,19 +97,30 @@ static struct mt2063_config az6007_mt2063_config = {
@@ -119,30 +130,37 @@ static int __az6007_read(struct usb_device *udev, u8 req, u16 value,
DUMP_PREFIX_NONE, b, blen);
}

+end_unlock:
+ mutex_unlock(&d->usb_mutex);
return ret;
}

static int az6007_read(struct dvb_usb_device *d, u8 req, u16 value,
u16 index, u8 *b, int blen)
{
- struct az6007_device_state *st = d->priv;
+ struct az6007_device_state *st = d_to_priv(d);
int ret;

- if (mutex_lock_interruptible(&st->mutex) < 0)
- return -EAGAIN;
-
- ret = __az6007_read(d->udev, req, value, index, b, blen);
-
- mutex_unlock(&st->mutex);
+ ret = __az6007_read(d, st, req, value, index, b, blen);

return ret;
}

-static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
- u16 index, u8 *b, int blen)
+static int __az6007_write(struct dvb_usb_device *d, struct az6007_device_state *st,
+ u8 req, u16 value, u16 index, u8 *b, int blen)
{
int ret;

+ if (mutex_lock_interruptible(&d->usb_mutex) < 0)
+ return -EAGAIN;
+
+ if (blen > sizeof(st->data) - 1) {
+ pr_err("az6007: tried to write %d bytes, but I2C max size is %lu bytes\n",
+ blen, sizeof(st->data));
+ ret = -EOPNOTSUPP;
+ goto end_unlock;
+ }
+
if (az6007_xfer_debug) {
printk(KERN_DEBUG "az6007: OUT req: %02x, value: %04x, index: %04x\n",
req, value, index);
@@ -150,37 +168,30 @@ static int __az6007_write(struct usb_device *udev, u8 req, u16 value,
- if (mutex_lock_interruptible(&st->mutex) < 0)
- return -EAGAIN;
-
- ret = __az6007_write(d->udev, req, value, index, b, blen);
-
- mutex_unlock(&st->mutex);
+ ret = __az6007_write(d, st, req, value, index, b, blen);

return ret;
}
@@ -574,10 +585,9 @@ static void az6007_ci_uninit(struct dvb_usb_device *d)
}


-static int az6007_ci_init(struct dvb_usb_adapter *adap)
+static int az6007_ci_init(struct dvb_usb_device *d)
{
- struct dvb_usb_device *d = adap_to_d(adap);
- struct az6007_device_state *state = adap_to_priv(adap);
+ struct az6007_device_state *state = d_to_priv(d);
int ret;

pr_debug("%s()\n", __func__);
@@ -594,7 +604,7 @@ static int az6007_ci_init(struct dvb_usb_adapter *adap)
state->ca.poll_slot_status = az6007_ci_poll_slot_status;
state->ca.data = d;

- ret = dvb_ca_en50221_init(&adap->dvb_adap,
+ ret = dvb_ca_en50221_init(&d->adapter[0].dvb_adap,
&state->ca,
0, /* flags */
1);/* n_slots */
@@ -604,6 +614,8 @@ static int az6007_ci_init(struct dvb_usb_adapter *adap)
return ret;
}

+ state->ci_attached = true;
+
pr_debug("CI initialized.\n");

return 0;
@@ -640,8 +652,6 @@ static int az6007_frontend_attach(struct dvb_usb_adapter *adap)
st->gate_ctrl = adap->fe[0]->ops.i2c_gate_ctrl;
adap->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;

- az6007_ci_init(adap);
-
return 0;
}

@@ -661,8 +671,6 @@ static int az6007_cablestar_hdci_frontend_attach(struct dvb_usb_adapter *adap)
st->gate_ctrl = adap->fe[0]->ops.i2c_gate_ctrl;
adap->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;

- az6007_ci_init(adap);
-
return 0;
}

@@ -693,50 +701,55 @@ static int az6007_power_ctrl(struct dvb_usb_device *d, int onoff)

pr_debug("%s()\n", __func__);

- if (!state->warm) {
- mutex_init(&state->mutex);
+ mutex_lock(&d->i2c_mutex);

+ if (!state->warm) {
ret = az6007_write(d, AZ6007_POWER, 0, 2, NULL, 0);
if (ret < 0)
- return ret;
+ goto end_unlock;
msleep(60);
ret = az6007_write(d, AZ6007_POWER, 1, 4, NULL, 0);
if (ret < 0)
- return ret;
+ goto end_unlock;
msleep(100);
ret = az6007_write(d, AZ6007_POWER, 1, 3, NULL, 0);
if (ret < 0)
- return ret;
+ goto end_unlock;
msleep(20);
ret = az6007_write(d, AZ6007_POWER, 1, 4, NULL, 0);
if (ret < 0)
- return ret;
+ goto end_unlock;

msleep(400);
ret = az6007_write(d, FX2_SCON1, 0, 3, NULL, 0);
if (ret < 0)
- return ret;
+ goto end_unlock;
msleep(150);
ret = az6007_write(d, FX2_SCON1, 1, 3, NULL, 0);
if (ret < 0)
- return ret;
+ goto end_unlock;
msleep(430);
ret = az6007_write(d, AZ6007_POWER, 0, 0, NULL, 0);
if (ret < 0)
- return ret;
+ goto end_unlock;

state->warm = true;

- return 0;
+ ret = 0;
+ goto end_unlock;
}

+ ret = 0;
+
if (!onoff)
- return 0;
+ goto end_unlock;

az6007_write(d, AZ6007_POWER, 0, 0, NULL, 0);
az6007_write(d, AZ6007_TS_THROUGH, 0, 0, NULL, 0);

- return 0;
+end_unlock:
+ mutex_unlock(&d->i2c_mutex);
+ return ret;
}

/* I2C */
@@ -752,7 +765,7 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
int length;
u8 req, addr;

- if (mutex_lock_interruptible(&st->mutex) < 0)
+ if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN;

for (i = 0; i < num; i++) {
@@ -775,13 +788,12 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = 6 + msgs[i + 1].len;
len = msgs[i + 1].len;
- ret = __az6007_read(d->udev, req, value, index,
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- if (ret >= len) {
+ if (ret >= len + 5) {
for (j = 0; j < len; j++)
msgs[i + 1].buf[j] = st->data[j + 5];
- } else
- ret = -EIO;
+ }
i++;
} else if (!(msgs[i].flags & I2C_M_RD)) {
/* write bytes */
@@ -797,10 +809,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr | (1 << 8);
length = msgs[i].len - 1;
len = msgs[i].len - 1;
- for (j = 0; j < len; j++)
- st->data[j] = msgs[i].buf[j + 1];
- ret = __az6007_write(d->udev, req, value, index,
- st->data, length);
+ ret = __az6007_write(d, st, req, value, index,
+ &msgs[i].buf[1], length);
} else {
/* read bytes */
if (az6007_xfer_debug)
@@ -815,16 +825,18 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr;
length = msgs[i].len + 6;
len = msgs[i].len;
- ret = __az6007_read(d->udev, req, value, index,
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- for (j = 0; j < len; j++)
- msgs[i].buf[j] = st->data[j + 5];
+ if (ret >= len + 5) {
+ for (j = 0; j < len; j++)
+ msgs[i].buf[j] = st->data[j + 5];
+ }
}
if (ret < 0)
goto err;
}
err:
- mutex_unlock(&st->mutex);
+ mutex_unlock(&d->i2c_mutex);

if (ret < 0) {
pr_info("%s ERROR: %i\n", __func__, ret);
@@ -845,6 +857,7 @@ static const struct i2c_algorithm az6007_i2c_algo = {

static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
{
+ struct az6007_device_state *state = d_to_priv(d);
int ret;
u8 *mac;

@@ -855,7 +868,7 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
return -ENOMEM;

/* Try to read the mac address */
- ret = __az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+ ret = __az6007_read(d, state, AZ6007_READ_DATA, 6, 0, mac, 6);
if (ret == 6)
ret = WARM;
else
@@ -864,9 +877,9 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
kfree(mac);

if (ret == COLD) {
- __az6007_write(d->udev, 0x09, 1, 0, NULL, 0);
- __az6007_write(d->udev, 0x00, 0, 0, NULL, 0);
- __az6007_write(d->udev, 0x00, 0, 0, NULL, 0);
+ __az6007_write(d, state, 0x09, 1, 0, NULL, 0);
+ __az6007_write(d, state, 0x00, 0, 0, NULL, 0);
+ __az6007_write(d, state, 0x00, 0, 0, NULL, 0);
}

pr_debug("Device is on %s state\n",
@@ -874,13 +887,6 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
return ret;
}

-static void az6007_usb_disconnect(struct usb_interface *intf)
-{
- struct dvb_usb_device *d = usb_get_intfdata(intf);
- az6007_ci_uninit(d);
- dvb_usbv2_disconnect(intf);
-}
-
static int az6007_download_firmware(struct dvb_usb_device *d,
const struct firmware *fw)
{
@@ -889,6 +895,19 @@ static int az6007_download_firmware(struct dvb_usb_device *d,
return cypress_load_firmware(d->udev, fw, CYPRESS_FX2);
}

+static int az6007_init(struct dvb_usb_device *d)
+{
+ return az6007_ci_init(d);
+}
+
+static void az6007_exit(struct dvb_usb_device *d)
+{
+ struct az6007_device_state *state = d_to_priv(d);
+
+ if (state->ci_attached)
+ az6007_ci_uninit(d);
+}
+
/* DVB USB Driver stuff */
static struct dvb_usb_device_properties az6007_props = {
.driver_name = KBUILD_MODNAME,
@@ -906,6 +925,8 @@ static struct dvb_usb_device_properties az6007_props = {
.download_firmware = az6007_download_firmware,
.identify_state = az6007_identify_state,
.power_ctrl = az6007_power_ctrl,
+ .init = az6007_init,
+ .exit = az6007_exit,
.num_adapters = 1,
.adapter = {
{ .stream = DVB_USB_STREAM_BULK(0x02, 10, 4096), }
@@ -929,6 +950,8 @@ static struct dvb_usb_device_properties az6007_cablestar_hdci_props = {
.download_firmware = az6007_download_firmware,
.identify_state = az6007_identify_state,
.power_ctrl = az6007_power_ctrl,
+ .init = az6007_init,
+ .exit = az6007_exit,
.num_adapters = 1,
.adapter = {
{ .stream = DVB_USB_STREAM_BULK(0x02, 10, 4096), }
@@ -949,37 +972,17 @@ static const struct usb_device_id az6007_usb_table[] = {

syzbot

unread,
Sep 6, 2025, 1:21:03 PM (yesterday) Sep 6
to aha3...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+019295...@syzkaller.appspotmail.com
Tested-by: syzbot+019295...@syzkaller.appspotmail.com

Tested on:

commit: d1d10cea Merge tag 'perf-tools-fixes-for-v6.17-2025-09..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13687a42580000
kernel config: https://syzkaller.appspot.com/x/.config?x=bce5d4c1cf285a6c
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=17e7d312580000

Jeongjun Park

unread,
4:26 AM (17 hours ago) 4:26 AM
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com, aha3...@gmail.com
#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

---
drivers/media/usb/dvb-usb-v2/az6007.c | 213 +++++++++++++-------------
1 file changed, 108 insertions(+), 105 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..8365787d8c4a 100644
+ blen, sizeof(st->data) - 1);

syzbot

unread,
5:56 AM (16 hours ago) 5:56 AM
to aha3...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+019295...@syzkaller.appspotmail.com
Tested-by: syzbot+019295...@syzkaller.appspotmail.com

Tested on:

commit: b2369207 Merge tag 'rust-fixes-6.17-2' of git://git.ke..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=158ab312580000
kernel config: https://syzkaller.appspot.com/x/.config?x=bce5d4c1cf285a6c
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=12418562580000

Jeongjun Park

unread,
6:05 AM (15 hours ago) 6:05 AM
to syzbot+019295...@syzkaller.appspotmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com, aha3...@gmail.com
drivers/media/usb/dvb-usb-v2/az6007.c | 212 +++++++++++++-------------
1 file changed, 107 insertions(+), 105 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/az6007.c b/drivers/media/usb/dvb-usb-v2/az6007.c
index 65ef045b74ca..b73169f238d8 100644
if (ret >= len) {
for (j = 0; j < len; j++)
msgs[i + 1].buf[j] = st->data[j + 5];
- } else
- ret = -EIO;
+ }
i++;
} else if (!(msgs[i].flags & I2C_M_RD)) {
/* write bytes */
@@ -796,11 +808,8 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
index = msgs[i].buf[0];
value = addr | (1 << 8);
length = msgs[i].len - 1;
- len = msgs[i].len - 1;
- for (j = 0; j < len; j++)
- st->data[j] = msgs[i].buf[j + 1];
- ret = __az6007_write(d->udev, req, value, index,
- st->data, length);
+ ret = __az6007_write(d, st, req, value, index,
+ &msgs[i].buf[1], length);
} else {
/* read bytes */
if (az6007_xfer_debug)
@@ -815,16 +824,18 @@ static int az6007_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
value = addr;
length = msgs[i].len + 6;
len = msgs[i].len;
- ret = __az6007_read(d->udev, req, value, index,
+ ret = __az6007_read(d, st, req, value, index,
st->data, length);
- for (j = 0; j < len; j++)
- msgs[i].buf[j] = st->data[j + 5];
+ if (ret >= len) {
+ for (j = 0; j < len; j++)
+ msgs[i].buf[j] = st->data[j + 5];
+ }
}
if (ret < 0)
goto err;
}
err:
- mutex_unlock(&st->mutex);
+ mutex_unlock(&d->i2c_mutex);

if (ret < 0) {
pr_info("%s ERROR: %i\n", __func__, ret);
@@ -845,6 +856,7 @@ static const struct i2c_algorithm az6007_i2c_algo = {

static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
{
+ struct az6007_device_state *state = d_to_priv(d);
int ret;
u8 *mac;

@@ -855,7 +867,7 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
return -ENOMEM;

/* Try to read the mac address */
- ret = __az6007_read(d->udev, AZ6007_READ_DATA, 6, 0, mac, 6);
+ ret = __az6007_read(d, state, AZ6007_READ_DATA, 6, 0, mac, 6);
if (ret == 6)
ret = WARM;
else
@@ -864,9 +876,9 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
kfree(mac);

if (ret == COLD) {
- __az6007_write(d->udev, 0x09, 1, 0, NULL, 0);
- __az6007_write(d->udev, 0x00, 0, 0, NULL, 0);
- __az6007_write(d->udev, 0x00, 0, 0, NULL, 0);
+ __az6007_write(d, state, 0x09, 1, 0, NULL, 0);
+ __az6007_write(d, state, 0x00, 0, 0, NULL, 0);
+ __az6007_write(d, state, 0x00, 0, 0, NULL, 0);
}

pr_debug("Device is on %s state\n",
@@ -874,13 +886,6 @@ static int az6007_identify_state(struct dvb_usb_device *d, const char **name)
return ret;
}

-static void az6007_usb_disconnect(struct usb_interface *intf)
-{
- struct dvb_usb_device *d = usb_get_intfdata(intf);
- az6007_ci_uninit(d);
- dvb_usbv2_disconnect(intf);
-}
-
static int az6007_download_firmware(struct dvb_usb_device *d,
const struct firmware *fw)
{
@@ -889,6 +894,19 @@ static int az6007_download_firmware(struct dvb_usb_device *d,
return cypress_load_firmware(d->udev, fw, CYPRESS_FX2);
}

+static int az6007_init(struct dvb_usb_device *d)
+{
+ return az6007_ci_init(d);
+}
+
+static void az6007_exit(struct dvb_usb_device *d)
+{
+ struct az6007_device_state *state = d_to_priv(d);
+
+ if (state->ci_attached)
+ az6007_ci_uninit(d);
+}
+
/* DVB USB Driver stuff */
static struct dvb_usb_device_properties az6007_props = {
.driver_name = KBUILD_MODNAME,
@@ -906,6 +924,8 @@ static struct dvb_usb_device_properties az6007_props = {
.download_firmware = az6007_download_firmware,
.identify_state = az6007_identify_state,
.power_ctrl = az6007_power_ctrl,
+ .init = az6007_init,
+ .exit = az6007_exit,
.num_adapters = 1,
.adapter = {
{ .stream = DVB_USB_STREAM_BULK(0x02, 10, 4096), }
@@ -929,6 +949,8 @@ static struct dvb_usb_device_properties az6007_cablestar_hdci_props = {
.download_firmware = az6007_download_firmware,
.identify_state = az6007_identify_state,
.power_ctrl = az6007_power_ctrl,
+ .init = az6007_init,
+ .exit = az6007_exit,
.num_adapters = 1,
.adapter = {
{ .stream = DVB_USB_STREAM_BULK(0x02, 10, 4096), }
@@ -949,37 +971,17 @@ static const struct usb_device_id az6007_usb_table[] = {

syzbot

unread,
6:30 AM (15 hours ago) 6:30 AM
to aha3...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+019295...@syzkaller.appspotmail.com
Tested-by: syzbot+019295...@syzkaller.appspotmail.com

Tested on:

commit: b2369207 Merge tag 'rust-fixes-6.17-2' of git://git.ke..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=123b3962580000
kernel config: https://syzkaller.appspot.com/x/.config?x=bce5d4c1cf285a6c
dashboard link: https://syzkaller.appspot.com/bug?extid=0192952caa411a3be209
compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=162ab312580000
Reply all
Reply to author
Forward
0 new messages