memory leak in zr364xx_probe

8 views
Skip to first unread message

syzbot

unread,
Dec 23, 2020, 10:25:18ā€ÆAM12/23/20
to linux-...@vger.kernel.org, linux...@vger.kernel.org, linu...@vger.kernel.org, mch...@kernel.org, roy...@zerezo.com, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 3644e2d2 mm/filemap: fix infinite loop in generic_file_buf..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16f80eff500000
kernel config: https://syzkaller.appspot.com/x/.config?x=37c889fb8b2761af
dashboard link: https://syzkaller.appspot.com/bug?extid=b4d54814b339b5c6bbd4
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1089df07500000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1671c77f500000

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

BUG: memory leak
unreferenced object 0xffffc90000e71000 (size 200704):
comm "kworker/0:2", pid 3653, jiffies 4294942426 (age 13.820s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000110a155e>] __vmalloc_node_range+0x3a5/0x410 mm/vmalloc.c:2585
[<000000008a1ee970>] __vmalloc_node mm/vmalloc.c:2617 [inline]
[<000000008a1ee970>] vmalloc+0x49/0x50 mm/vmalloc.c:2650
[<00000000a6a3abfa>] zr364xx_board_init drivers/media/usb/zr364xx/zr364xx.c:1348 [inline]
[<00000000a6a3abfa>] zr364xx_probe+0x60b/0x833 drivers/media/usb/zr364xx/zr364xx.c:1509
[<0000000014a572f5>] usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
[<00000000f30ee977>] really_probe+0x159/0x480 drivers/base/dd.c:561
[<00000000ddb29374>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745
[<0000000073c89cb9>] __device_attach_driver+0xee/0x110 drivers/base/dd.c:851
[<000000009f56a99c>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
[<00000000848d591a>] __device_attach+0x122/0x250 drivers/base/dd.c:919
[<00000000168be5bb>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
[<00000000464f40a6>] device_add+0x5be/0xc30 drivers/base/core.c:3091
[<000000008c75a2b5>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2164
[<00000000071d14a5>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
[<00000000f325b973>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
[<00000000f30ee977>] really_probe+0x159/0x480 drivers/base/dd.c:561
[<00000000ddb29374>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745



---
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.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

Andy Shevchenko

unread,
Dec 30, 2020, 4:11:09ā€ÆPM12/30/20
to syzbot, Linux Kernel Mailing List, Linux Media Mailing List, USB, Mauro Carvalho Chehab, roy...@zerezo.com, syzkaller-bugs
If I am not mistaken the following should work and fix the issue (can
somebody in syzcaller test below patch, sorry it may be mangled?):

--- a/drivers/media/usb/zr364xx/zr364xx.c
+++ b/drivers/media/usb/zr364xx/zr364xx.c
@@ -1533,9 +1533,7 @@ static int zr364xx_probe(struct usb_interface *intf,
return 0;

fail:
- v4l2_ctrl_handler_free(hdl);
- v4l2_device_unregister(&cam->v4l2_dev);
- kfree(cam);
+ v4l2_device_put(&cam->v4l2_dev);
return err;
}

--
With Best Regards,
Andy Shevchenko

syzbot

unread,
Dec 30, 2020, 8:49:06ā€ÆPM12/30/20
to ezeq...@vanguardiasur.com.ar, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
BUG: unable to handle kernel NULL pointer dereference in __videobuf_free

zr364xx 2-1:0.0: model 06d6:003b detected
usb 2-1: 320x240 mode selected
zr364xx: start read pipe failed
BUG: kernel NULL pointer dereference, address: 0000000000000000
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 118675067 P4D 118675067 PUD 1082de067 PMD 0
Oops: 0000 [#1] PREEMPT SMP
CPU: 0 PID: 10599 Comm: kworker/0:5 Not tainted 5.10.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: usb_hub_wq hub_event
RIP: 0010:__videobuf_free+0x62/0x180 drivers/media/v4l2-core/videobuf-core.c:243
Code: 9d 70 01 00 00 31 ff 83 e3 03 89 de e8 b7 da 4a fe 84 db 0f 85 00 01 00 00 e8 2a e1 4a fe 48 8b 85 68 01 00 00 bf 03 10 26 12 <44> 8b 20 44 89 e6 e8 d3 da 4a fe 41 81 fc 03 10 26 12 0f 85 c4 2c
RSP: 0018:ffffc90002d3f7b8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff82e82989
RDX: ffff888113d9d000 RSI: ffffffff82e82996 RDI: 0000000012261003
RBP: ffff888126d5f780 R08: ffff888126d0fab8 R09: 00000000000008fd
R10: 0000000000000000 R11: 3a7878343633727a R12: 0000000000000001
R13: ffff888126d5f000 R14: ffffc90002e81000 R15: 00000000ffffffa6
FS: 0000000000000000(0000) GS:ffff88813bc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 0000000118654000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
videobuf_mmap_free+0x1f/0x60 drivers/media/v4l2-core/videobuf-core.c:377
zr364xx_release+0x26/0xa0 drivers/media/usb/zr364xx/zr364xx.c:1192
v4l2_device_release drivers/media/v4l2-core/v4l2-device.c:51 [inline]
kref_put include/linux/kref.h:65 [inline]
v4l2_device_put+0x82/0xc0 drivers/media/v4l2-core/v4l2-device.c:56
zr364xx_probe+0x80c/0x823 drivers/media/usb/zr364xx/zr364xx.c:1536
usb_probe_interface+0x177/0x370 drivers/usb/core/driver.c:396
really_probe+0x159/0x480 drivers/base/dd.c:554
driver_probe_device+0x84/0x100 drivers/base/dd.c:738
__device_attach_driver+0xee/0x110 drivers/base/dd.c:844
bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
__device_attach+0x122/0x250 drivers/base/dd.c:912
bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
device_add+0x5ac/0xc30 drivers/base/core.c:2936
usb_set_configuration+0x9de/0xb90 drivers/usb/core/message.c:2159
usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
really_probe+0x159/0x480 drivers/base/dd.c:554
driver_probe_device+0x84/0x100 drivers/base/dd.c:738
__device_attach_driver+0xee/0x110 drivers/base/dd.c:844
bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
__device_attach+0x122/0x250 drivers/base/dd.c:912
bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
device_add+0x5ac/0xc30 drivers/base/core.c:2936
usb_new_device.cold+0x166/0x578 drivers/usb/core/hub.c:2554
hub_port_connect drivers/usb/core/hub.c:5222 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5362 [inline]
port_event drivers/usb/core/hub.c:5508 [inline]
hub_event+0x144a/0x20d0 drivers/usb/core/hub.c:5590
process_one_work+0x27d/0x590 kernel/workqueue.c:2272
worker_thread+0x59/0x5d0 kernel/workqueue.c:2418
kthread+0x178/0x1b0 kernel/kthread.c:292
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296
Modules linked in:
CR2: 0000000000000000
---[ end trace 46aec711da91fb13 ]---
RIP: 0010:__videobuf_free+0x62/0x180 drivers/media/v4l2-core/videobuf-core.c:243
Code: 9d 70 01 00 00 31 ff 83 e3 03 89 de e8 b7 da 4a fe 84 db 0f 85 00 01 00 00 e8 2a e1 4a fe 48 8b 85 68 01 00 00 bf 03 10 26 12 <44> 8b 20 44 89 e6 e8 d3 da 4a fe 41 81 fc 03 10 26 12 0f 85 c4 2c
RSP: 0018:ffffc90002d3f7b8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff82e82989
RDX: ffff888113d9d000 RSI: ffffffff82e82996 RDI: 0000000012261003
RBP: ffff888126d5f780 R08: ffff888126d0fab8 R09: 00000000000008fd
R10: 0000000000000000 R11: 3a7878343633727a R12: 0000000000000001
R13: ffff888126d5f000 R14: ffffc90002e81000 R15: 00000000ffffffa6
FS: 0000000000000000(0000) GS:ffff88813bc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 0000000118654000 CR4: 00000000001506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


Tested on:

commit: a1714d22 media: zr364xx: Fix memory leak in ->probe()
git tree: https://gitlab.collabora.com/linux/0day.git
console output: https://syzkaller.appspot.com/x/log.txt?x=17ce3693500000
kernel config: https://syzkaller.appspot.com/x/.config?x=ec2338be23ae163e

Ezequiel Garcia

unread,
Dec 31, 2020, 3:47:37ā€ÆPM12/31/20
to syzbot, Andy Shevchenko, Linux Kernel Mailing List, linux-media, linux-usb, Mauro Carvalho Chehab, roy...@zerezo.com, syzkaller-bugs
Let's see if this works:

#syz test: https://gitlab.collabora.com/linux/0day.git
a1714d224e516b579d09cc1b4c3d85042e42f14c

syzbot

unread,
Dec 31, 2020, 3:56:11ā€ÆPM12/31/20
to andriy.s...@linux.intel.com, ezeq...@vanguardiasur.com.ar, linux-...@vger.kernel.org, linux...@vger.kernel.org, linu...@vger.kernel.org, mch...@kernel.org, roy...@zerezo.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
BUG: unable to handle kernel NULL pointer dereference in __videobuf_free

zr364xx 4-1:0.0: model 06d6:003b detected
usb 4-1: 320x240 mode selected
zr364xx: start read pipe failed
BUG: kernel NULL pointer dereference, address: 0000000000000000
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 0 P4D 0
Oops: 0000 [#1] PREEMPT SMP
CPU: 1 PID: 8717 Comm: kworker/1:4 Not tainted 5.10.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: usb_hub_wq hub_event
RIP: 0010:__videobuf_free+0x62/0x180 drivers/media/v4l2-core/videobuf-core.c:243
Code: 9d 70 01 00 00 31 ff 83 e3 03 89 de e8 b7 da 4a fe 84 db 0f 85 00 01 00 00 e8 2a e1 4a fe 48 8b 85 68 01 00 00 bf 03 10 26 12 <44> 8b 20 44 89 e6 e8 d3 da 4a fe 41 81 fc 03 10 26 12 0f 85 c4 2c
RSP: 0018:ffffc900024ef7b8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff82e82989
RDX: ffff88811813d040 RSI: ffffffff82e82996 RDI: 0000000012261003
RBP: ffff888125921780 R08: ffff888125ffe008 R09: 00000000000008fd
R10: 0000000000000000 R11: 3a7878343633727a R12: 0000000000000001
R13: ffff888125921000 R14: ffffc900032b1000 R15: 00000000ffffffa6
FS: 0000000000000000(0000) GS:ffff88813bd00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 0000000109bb5000 CR4: 00000000001506e0
---[ end trace 90e0be95dcb7e0d1 ]---
RIP: 0010:__videobuf_free+0x62/0x180 drivers/media/v4l2-core/videobuf-core.c:243
Code: 9d 70 01 00 00 31 ff 83 e3 03 89 de e8 b7 da 4a fe 84 db 0f 85 00 01 00 00 e8 2a e1 4a fe 48 8b 85 68 01 00 00 bf 03 10 26 12 <44> 8b 20 44 89 e6 e8 d3 da 4a fe 41 81 fc 03 10 26 12 0f 85 c4 2c
RSP: 0018:ffffc900024ef7b8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff82e82989
RDX: ffff88811813d040 RSI: ffffffff82e82996 RDI: 0000000012261003
RBP: ffff888125921780 R08: ffff888125ffe008 R09: 00000000000008fd
R10: 0000000000000000 R11: 3a7878343633727a R12: 0000000000000001
R13: ffff888125921000 R14: ffffc900032b1000 R15: 00000000ffffffa6
FS: 0000000000000000(0000) GS:ffff88813bd00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 0000000109bb5000 CR4: 00000000001506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


Tested on:

commit: a1714d22 media: zr364xx: Fix memory leak in ->probe()
git tree: https://gitlab.collabora.com/linux/0day.git
console output: https://syzkaller.appspot.com/x/log.txt?x=11415e0b500000
kernel config: https://syzkaller.appspot.com/x/.config?x=ec2338be23ae163e

Andy Shevchenko

unread,
Jan 5, 2021, 10:02:00ā€ÆAM1/5/21
to Ezequiel Garcia, syzbot, Linux Kernel Mailing List, linux-media, linux-usb, Mauro Carvalho Chehab, roy...@zerezo.com, syzkaller-bugs
On Thu, Dec 31, 2020 at 05:47:20PM -0300, Ezequiel Garcia wrote:
> Let's see if this works:
>
> #syz test: https://gitlab.collabora.com/linux/0day.git
> a1714d224e516b579d09cc1b4c3d85042e42f14c

Thanks for the hint!
Reply all
Reply to author
Forward
0 new messages