Hello,
syzbot found the following issue on:
HEAD commit: 9cdbf646 Merge tag 'io_uring-5.12-2021-04-16' of git://git..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=136ce5a6d00000
kernel config: https://syzkaller.appspot.com/x/.config?x=fd35e661e44323ea
dashboard link: https://syzkaller.appspot.com/bug?extid=d1e69c888f0d3866ead4
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16ecba29d00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=143cf955d00000
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]
BUG: memory leak
unreferenced object 0xffff8881120e1400 (size 1024):
comm "kworker/0:2", pid 3660, jiffies 4294952380 (age 24.950s)
hex dump (first 32 bytes):
c8 78 3c 12 81 88 ff ff c8 78 3c 12 81 88 ff ff .x<......x<.....
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff82ba5d37>] kmalloc include/linux/slab.h:554 [inline]
[<ffffffff82ba5d37>] kzalloc include/linux/slab.h:684 [inline]
[<ffffffff82ba5d37>] usb_set_configuration+0x187/0xb90 drivers/usb/core/message.c:1992
[<ffffffff82bb69ec>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
[<ffffffff82ba874c>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
[<ffffffff825f67f9>] really_probe+0x159/0x4a0 drivers/base/dd.c:559
[<ffffffff825f6bc4>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745
[<ffffffff825f72de>] __device_attach_driver+0xee/0x110 drivers/base/dd.c:851
[<ffffffff825f3747>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
[<ffffffff825f6e72>] __device_attach+0x122/0x250 drivers/base/dd.c:919
[<ffffffff825f53e6>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
[<ffffffff825f1935>] device_add+0x5d5/0xc40 drivers/base/core.c:3242
[<ffffffff841df2d9>] usb_new_device.cold+0x16a/0x582 drivers/usb/core/hub.c:2555
[<ffffffff82b9b24e>] hub_port_connect drivers/usb/core/hub.c:5223 [inline]
[<ffffffff82b9b24e>] hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
[<ffffffff82b9b24e>] port_event drivers/usb/core/hub.c:5509 [inline]
[<ffffffff82b9b24e>] hub_event+0x142e/0x20c0 drivers/usb/core/hub.c:5591
[<ffffffff81259619>] process_one_work+0x2c9/0x600 kernel/workqueue.c:2275
[<ffffffff81259f09>] worker_thread+0x59/0x5d0 kernel/workqueue.c:2421
[<ffffffff81261638>] kthread+0x178/0x1b0 kernel/kthread.c:292
[<ffffffff8100227f>] ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
BUG: memory leak
unreferenced object 0xffff888110a217a0 (size 32):
comm "kworker/0:2", pid 3660, jiffies 4294952380 (age 24.950s)
hex dump (first 32 bytes):
31 2d 31 3a 30 2e 32 34 31 00 00 00 00 00 00 00 1-1:0.241.......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8223411c>] kvasprintf+0x6c/0xf0 lib/kasprintf.c:25
[<ffffffff822341f8>] kvasprintf_const+0x58/0x110 lib/kasprintf.c:49
[<ffffffff822f402b>] kobject_set_name_vargs+0x3b/0xe0 lib/kobject.c:289
[<ffffffff825ec413>] dev_set_name+0x63/0x90 drivers/base/core.c:3028
[<ffffffff82ba6269>] usb_set_configuration+0x6b9/0xb90 drivers/usb/core/message.c:2099
[<ffffffff82bb69ec>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
[<ffffffff82ba874c>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
[<ffffffff825f67f9>] really_probe+0x159/0x4a0 drivers/base/dd.c:559
[<ffffffff825f6bc4>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745
[<ffffffff825f72de>] __device_attach_driver+0xee/0x110 drivers/base/dd.c:851
[<ffffffff825f3747>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
[<ffffffff825f6e72>] __device_attach+0x122/0x250 drivers/base/dd.c:919
[<ffffffff825f53e6>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
[<ffffffff825f1935>] device_add+0x5d5/0xc40 drivers/base/core.c:3242
[<ffffffff841df2d9>] usb_new_device.cold+0x16a/0x582 drivers/usb/core/hub.c:2555
[<ffffffff82b9b24e>] hub_port_connect drivers/usb/core/hub.c:5223 [inline]
[<ffffffff82b9b24e>] hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
[<ffffffff82b9b24e>] port_event drivers/usb/core/hub.c:5509 [inline]
[<ffffffff82b9b24e>] hub_event+0x142e/0x20c0 drivers/usb/core/hub.c:5591
BUG: memory leak
unreferenced object 0xffff88810c472800 (size 256):
comm "kworker/0:2", pid 3660, jiffies 4294952409 (age 24.660s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 08 28 47 0c 81 88 ff ff .........(G.....
08 28 47 0c 81 88 ff ff b0 c4 5e 82 ff ff ff ff .(G.......^.....
backtrace:
[<ffffffff825f1b71>] kmalloc include/linux/slab.h:554 [inline]
[<ffffffff825f1b71>] kzalloc include/linux/slab.h:684 [inline]
[<ffffffff825f1b71>] device_private_init drivers/base/core.c:3084 [inline]
[<ffffffff825f1b71>] device_add+0x811/0xc40 drivers/base/core.c:3134
[<ffffffff82ba6589>] usb_set_configuration+0x9d9/0xb90 drivers/usb/core/message.c:2164
[<ffffffff82bb69ec>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
[<ffffffff82ba874c>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
[<ffffffff825f67f9>] really_probe+0x159/0x4a0 drivers/base/dd.c:559
[<ffffffff825f6bc4>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745
[<ffffffff825f72de>] __device_attach_driver+0xee/0x110 drivers/base/dd.c:851
[<ffffffff825f3747>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
[<ffffffff825f6e72>] __device_attach+0x122/0x250 drivers/base/dd.c:919
[<ffffffff825f53e6>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
[<ffffffff825f1935>] device_add+0x5d5/0xc40 drivers/base/core.c:3242
[<ffffffff841df2d9>] usb_new_device.cold+0x16a/0x582 drivers/usb/core/hub.c:2555
[<ffffffff82b9b24e>] hub_port_connect drivers/usb/core/hub.c:5223 [inline]
[<ffffffff82b9b24e>] hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
[<ffffffff82b9b24e>] port_event drivers/usb/core/hub.c:5509 [inline]
[<ffffffff82b9b24e>] hub_event+0x142e/0x20c0 drivers/usb/core/hub.c:5591
[<ffffffff81259619>] process_one_work+0x2c9/0x600 kernel/workqueue.c:2275
[<ffffffff81259f09>] worker_thread+0x59/0x5d0 kernel/workqueue.c:2421
[<ffffffff81261638>] kthread+0x178/0x1b0 kernel/kthread.c:292
[ 176.
---
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 [email protected].
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
On Wed, Apr 21, 2021 at 08:12:18AM -0700, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 9cdbf646 Merge tag 'io_uring-5.12-2021-04-16' of git://git..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=136ce5a6d00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=fd35e661e44323ea
> dashboard link: https://syzkaller.appspot.com/bug?extid=d1e69c888f0d3866ead4
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16ecba29d00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=143cf955d00000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
>
> BUG: memory leak
> unreferenced object 0xffff8881120e1400 (size 1024):
> comm "kworker/0:2", pid 3660, jiffies 4294952380 (age 24.950s)
> hex dump (first 32 bytes):
> c8 78 3c 12 81 88 ff ff c8 78 3c 12 81 88 ff ff .x<......x<.....
> 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> backtrace:
> [<ffffffff82ba5d37>] kmalloc include/linux/slab.h:554 [inline]
> [<ffffffff82ba5d37>] kzalloc include/linux/slab.h:684 [inline]
> [<ffffffff82ba5d37>] usb_set_configuration+0x187/0xb90 drivers/usb/core/message.c:1992
> [<ffffffff82bb69ec>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
> [<ffffffff82ba874c>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
> [<ffffffff825f67f9>] really_probe+0x159/0x4a0 drivers/base/dd.c:559
> [<ffffffff825f6bc4>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745
> [<ffffffff825f72de>] __device_attach_driver+0xee/0x110 drivers/base/dd.c:851
> [<ffffffff825f3747>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
> [<ffffffff825f6e72>] __device_attach+0x122/0x250 drivers/base/dd.c:919
> [<ffffffff825f53e6>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
> [<ffffffff825f1935>] device_add+0x5d5/0xc40 drivers/base/core.c:3242
> [<ffffffff841df2d9>] usb_new_device.cold+0x16a/0x582 drivers/usb/core/hub.c:2555
> [<ffffffff82b9b24e>] hub_port_connect drivers/usb/core/hub.c:5223 [inline]
> [<ffffffff82b9b24e>] hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
> [<ffffffff82b9b24e>] port_event drivers/usb/core/hub.c:5509 [inline]
> [<ffffffff82b9b24e>] hub_event+0x142e/0x20c0 drivers/usb/core/hub.c:5591
> [<ffffffff81259619>] process_one_work+0x2c9/0x600 kernel/workqueue.c:2275
> [<ffffffff81259f09>] worker_thread+0x59/0x5d0 kernel/workqueue.c:2421
> [<ffffffff81261638>] kthread+0x178/0x1b0 kernel/kthread.c:292
> [<ffffffff8100227f>] ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
>
> BUG: memory leak
> unreferenced object 0xffff888110a217a0 (size 32):
> comm "kworker/0:2", pid 3660, jiffies 4294952380 (age 24.950s)
> hex dump (first 32 bytes):
> 31 2d 31 3a 30 2e 32 34 31 00 00 00 00 00 00 00 1-1:0.241.......
> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> backtrace:
> [<ffffffff8223411c>] kvasprintf+0x6c/0xf0 lib/kasprintf.c:25
> [<ffffffff822341f8>] kvasprintf_const+0x58/0x110 lib/kasprintf.c:49
> [<ffffffff822f402b>] kobject_set_name_vargs+0x3b/0xe0 lib/kobject.c:289
> [<ffffffff825ec413>] dev_set_name+0x63/0x90 drivers/base/core.c:3028
> [<ffffffff82ba6269>] usb_set_configuration+0x6b9/0xb90 drivers/usb/core/message.c:2099
> [<ffffffff82bb69ec>] usb_generic_driver_probe+0x8c/0xc0 drivers/usb/core/generic.c:238
> [<ffffffff82ba874c>] usb_probe_device+0x5c/0x140 drivers/usb/core/driver.c:293
> [<ffffffff825f67f9>] really_probe+0x159/0x4a0 drivers/base/dd.c:559
> [<ffffffff825f6bc4>] driver_probe_device+0x84/0x100 drivers/base/dd.c:745
> [<ffffffff825f72de>] __device_attach_driver+0xee/0x110 drivers/base/dd.c:851
> [<ffffffff825f3747>] bus_for_each_drv+0xb7/0x100 drivers/base/bus.c:431
> [<ffffffff825f6e72>] __device_attach+0x122/0x250 drivers/base/dd.c:919
> [<ffffffff825f53e6>] bus_probe_device+0xc6/0xe0 drivers/base/bus.c:491
> [<ffffffff825f1935>] device_add+0x5d5/0xc40 drivers/base/core.c:3242
> [<ffffffff841df2d9>] usb_new_device.cold+0x16a/0x582 drivers/usb/core/hub.c:2555
> [<ffffffff82b9b24e>] hub_port_connect drivers/usb/core/hub.c:5223 [inline]
> [<ffffffff82b9b24e>] hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
> [<ffffffff82b9b24e>] port_event drivers/usb/core/hub.c:5509 [inline]
> [<ffffffff82b9b24e>] hub_event+0x142e/0x20c0 drivers/usb/core/hub.c:5591
This looks like a job for the linux-media people.
The CPiA2 driver in drivers/media/usb/cpia2 calls v4l2_device_register()
from within cpia2_init_camera_struct() in the probe routine, but doesn't
call v4l2_device_unregister() on any of the probe failure paths.
Alan Stern
Am Mittwoch, den 21.04.2021, 08:12 -0700 schrieb syzbot:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 9cdbf646 Merge tag 'io_uring-5.12-2021-04-16' of git://git..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=136ce5a6d00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=fd35e661e44323ea
> dashboard link: https://syzkaller.appspot.com/bug?extid=d1e69c888f0d3866ead4
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16ecba29d00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=143cf955d00000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
#syz test: https://github.com/google/kasan.git 9cdbf646
From 1704504f905fe8e3eb83d63cbbbe9af60f002585 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
Date: Thu, 22 Apr 2021 14:14:21 +0200
Subject: [PATCH] cpia2: unregister device on probe error
The v4l2 device must be unregistered in case probe() fails,
lest we get a leak.
Signed-off-by: Oliver Neukum <[email protected]>
---
drivers/media/usb/cpia2/cpia2_usb.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
index 3ab80a7b4498..db3b5d6d2d9a 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -844,15 +844,13 @@ static int cpia2_usb_probe(struct usb_interface *intf,
ret = set_alternate(cam, USBIF_CMDONLY);
if (ret < 0) {
ERR("%s: usb_set_interface error (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto error;
}
if((ret = cpia2_init_camera(cam)) < 0) {
ERR("%s: failed to initialize cpia2 camera (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto error;
}
LOG(" CPiA Version: %d.%02d (%d.%d)\n",
cam->params.version.firmware_revision_hi,
@@ -872,11 +870,14 @@ static int cpia2_usb_probe(struct usb_interface *intf,
ret = cpia2_register_camera(cam);
if (ret < 0) {
ERR("%s: Failed to register cpia2 camera (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto error;
}
return 0;
+error:
+ v4l2_device_unregister(&cam->v4l2_dev);
+ kfree(cam);
+ return ret;
}
/******************************************************************************
--
2.26.2
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-and-tested-by: [email protected]
Tested on:
commit: 9cdbf646 Merge tag 'io_uring-5.12-2021-04-16' of git://git..
git tree: https://github.com/google/kasan.git
kernel config: https://syzkaller.appspot.com/x/.config?x=f23c86207baa4afe
dashboard link: https://syzkaller.appspot.com/bug?extid=d1e69c888f0d3866ead4
compiler:
patch: https://syzkaller.appspot.com/x/patch.diff?x=1699cf75d00000
Note: testing is done by a robot and is best-effort only.