bisecting fixing commit since 4010a528219e01dd02e768b22168f7f0e78365ce building syzkaller on 9a4781d43abfb86fe8521cb6fb084519e237454c testing commit 4010a528219e01dd02e768b22168f7f0e78365ce compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 030d6b6724621dc857b1d0db70c6342e74649bae266c754ace8ec11300ea81cf all runs: crashed: KASAN: use-after-free Read in v4l2_fh_init testing current HEAD 9e1ff307c779ce1f0f810c7ecce3d95bbae40896 testing commit 9e1ff307c779ce1f0f810c7ecce3d95bbae40896 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: c715ccd9e66e25187ed62916d0e630dce39c644981b34e49e42f5f08ec73a444 all runs: crashed: KASAN: use-after-free Read in v4l2_fh_init revisions tested: 2, total time: 21m43.395014933s (build: 13m35.06182996s, test: 7m25.896338308s) the crash still happens on HEAD commit msg: Linux 5.15-rc4 crash: KASAN: use-after-free Read in v4l2_fh_init ================================================================== BUG: KASAN: use-after-free in v4l2_fh_init+0x274/0x2c0 drivers/media/v4l2-core/v4l2-fh.c:25 Read of size 8 at addr ffff88805a538900 by task v4l_id/9744 CPU: 1 PID: 9744 Comm: v4l_id Not tainted 5.15.0-rc4-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x57/0x7d lib/dump_stack.c:106 print_address_description.constprop.0.cold+0x6c/0x2d6 mm/kasan/report.c:256 __kasan_report mm/kasan/report.c:442 [inline] kasan_report.cold+0x83/0xdf mm/kasan/report.c:459 v4l2_fh_init+0x274/0x2c0 drivers/media/v4l2-core/v4l2-fh.c:25 v4l2_fh_open+0x78/0xb0 drivers/media/v4l2-core/v4l2-fh.c:63 em28xx_v4l2_open+0xd6/0x430 drivers/media/usb/em28xx/em28xx-video.c:2163 v4l2_open+0x1e3/0x370 drivers/media/v4l2-core/v4l2-dev.c:427 chrdev_open+0x20f/0x650 fs/char_dev.c:414 do_dentry_open+0x42a/0xfc0 fs/open.c:822 do_open fs/namei.c:3428 [inline] path_openat+0x12fb/0x2240 fs/namei.c:3561 do_filp_open+0x199/0x3d0 fs/namei.c:3588 do_sys_openat2+0x11e/0x400 fs/open.c:1200 do_sys_open fs/open.c:1216 [inline] __do_sys_open fs/open.c:1224 [inline] __se_sys_open fs/open.c:1220 [inline] __x64_sys_open+0xfd/0x1a0 fs/open.c:1220 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f301e7e6840 Code: 73 01 c3 48 8b 0d 68 77 20 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d 89 bb 20 00 00 75 10 b8 02 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 1e f6 ff ff 48 89 04 24 RSP: 002b:00007ffe12ce8f18 EFLAGS: 00000246 ORIG_RAX: 0000000000000002 RAX: ffffffffffffffda RBX: 00007ffe12ce9088 RCX: 00007f301e7e6840 RDX: 00007f301e7d2ea0 RSI: 0000000000000000 RDI: 00007ffe12ceaf1d RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000002 R11: 0000000000000246 R12: 0000557d399348d0 R13: 00007ffe12ce9080 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 8980: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:434 [inline] ____kasan_kmalloc mm/kasan/common.c:513 [inline] ____kasan_kmalloc mm/kasan/common.c:472 [inline] __kasan_kmalloc+0xa1/0xd0 mm/kasan/common.c:522 kasan_kmalloc include/linux/kasan.h:264 [inline] kmem_cache_alloc_trace+0x1e4/0x480 mm/slab.c:3575 kmalloc include/linux/slab.h:591 [inline] kzalloc include/linux/slab.h:721 [inline] em28xx_v4l2_init drivers/media/usb/em28xx/em28xx-video.c:2542 [inline] em28xx_v4l2_init.cold+0x91/0x2d6d drivers/media/usb/em28xx/em28xx-video.c:2520 em28xx_init_extension+0x106/0x1c0 drivers/media/usb/em28xx/em28xx-core.c:1126 process_one_work+0x87f/0x1450 kernel/workqueue.c:2297 worker_thread+0x598/0x1040 kernel/workqueue.c:2444 kthread+0x38b/0x460 kernel/kthread.c:319 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Freed by task 8980: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_set_track+0x1c/0x30 mm/kasan/common.c:46 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:360 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free mm/kasan/common.c:328 [inline] __kasan_slab_free+0xd1/0x110 mm/kasan/common.c:374 kasan_slab_free include/linux/kasan.h:230 [inline] __cache_free mm/slab.c:3445 [inline] kfree+0x10a/0x2c0 mm/slab.c:3803 em28xx_v4l2_init drivers/media/usb/em28xx/em28xx-video.c:2911 [inline] em28xx_v4l2_init.cold+0x24a/0x2d6d drivers/media/usb/em28xx/em28xx-video.c:2520 em28xx_init_extension+0x106/0x1c0 drivers/media/usb/em28xx/em28xx-core.c:1126 process_one_work+0x87f/0x1450 kernel/workqueue.c:2297 worker_thread+0x598/0x1040 kernel/workqueue.c:2444 kthread+0x38b/0x460 kernel/kthread.c:319 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Last potentially related work creation: kasan_save_stack+0x1b/0x40 mm/kasan/common.c:38 kasan_record_aux_stack+0xa7/0xd0 mm/kasan/generic.c:348 insert_work+0x42/0x300 kernel/workqueue.c:1353 __queue_work+0x4a5/0xc80 kernel/workqueue.c:1519 queue_work_on+0x70/0x80 kernel/workqueue.c:1546 queue_work include/linux/workqueue.h:502 [inline] schedule_work include/linux/workqueue.h:563 [inline] request_modules drivers/media/usb/em28xx/em28xx-cards.c:3430 [inline] em28xx_usb_probe.cold+0x1226/0x2282 drivers/media/usb/em28xx/em28xx-cards.c:4088 usb_probe_interface+0x274/0x6a0 drivers/usb/core/driver.c:396 call_driver_probe drivers/base/dd.c:517 [inline] really_probe+0x1c2/0xb60 drivers/base/dd.c:596 __driver_probe_device+0x2a6/0x460 drivers/base/dd.c:751 driver_probe_device+0x44/0x110 drivers/base/dd.c:781 __device_attach_driver+0x185/0x250 drivers/base/dd.c:898 bus_for_each_drv+0x11e/0x1a0 drivers/base/bus.c:427 __device_attach+0x1db/0x410 drivers/base/dd.c:969 bus_probe_device+0x19d/0x250 drivers/base/bus.c:487 device_add+0xa57/0x1b90 drivers/base/core.c:3395 usb_set_configuration+0xc1d/0x1710 drivers/usb/core/message.c:2170 usb_generic_driver_probe+0x74/0xa0 drivers/usb/core/generic.c:238 usb_probe_device+0x95/0x240 drivers/usb/core/driver.c:293 call_driver_probe drivers/base/dd.c:517 [inline] really_probe+0x1c2/0xb60 drivers/base/dd.c:596 __driver_probe_device+0x2a6/0x460 drivers/base/dd.c:751 driver_probe_device+0x44/0x110 drivers/base/dd.c:781 __device_attach_driver+0x185/0x250 drivers/base/dd.c:898 bus_for_each_drv+0x11e/0x1a0 drivers/base/bus.c:427 __device_attach+0x1db/0x410 drivers/base/dd.c:969 bus_probe_device+0x19d/0x250 drivers/base/bus.c:487 device_add+0xa57/0x1b90 drivers/base/core.c:3395 usb_new_device.cold+0x5cf/0xedf drivers/usb/core/hub.c:2563 hub_port_connect drivers/usb/core/hub.c:5348 [inline] hub_port_connect_change drivers/usb/core/hub.c:5488 [inline] port_event drivers/usb/core/hub.c:5634 [inline] hub_event+0x10a3/0x36c0 drivers/usb/core/hub.c:5716 process_one_work+0x87f/0x1450 kernel/workqueue.c:2297 worker_thread+0x598/0x1040 kernel/workqueue.c:2444 kthread+0x38b/0x460 kernel/kthread.c:319 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 The buggy address belongs to the object at ffff88805a538000 which belongs to the cache kmalloc-16k of size 16384 The buggy address is located 2304 bytes inside of 16384-byte region [ffff88805a538000, ffff88805a53c000) The buggy address belongs to the page: page:ffffea0001694e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5a538 head:ffffea0001694e00 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffffea0001694c08 ffffea0001695008 ffff88800fc40b00 raw: 0000000000000000 ffff88805a538000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0x2420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_THISNODE), pid 8989, ts 70043495465, free_ts 8927819066 prep_new_page mm/page_alloc.c:2424 [inline] get_page_from_freelist+0xa6f/0x2f50 mm/page_alloc.c:4153 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5375 __alloc_pages_node include/linux/gfp.h:570 [inline] kmem_getpages mm/slab.c:1377 [inline] cache_grow_begin+0x75/0x460 mm/slab.c:2593 cache_alloc_refill+0x27f/0x380 mm/slab.c:2965 ____cache_alloc mm/slab.c:3048 [inline] ____cache_alloc mm/slab.c:3031 [inline] __do_cache_alloc mm/slab.c:3275 [inline] slab_alloc mm/slab.c:3316 [inline] kmem_cache_alloc_trace+0x38c/0x480 mm/slab.c:3573 kmalloc include/linux/slab.h:591 [inline] kzalloc include/linux/slab.h:721 [inline] em28xx_usb_probe+0x198/0xfc0 drivers/media/usb/em28xx/em28xx-cards.c:3855 usb_probe_interface+0x274/0x6a0 drivers/usb/core/driver.c:396 call_driver_probe drivers/base/dd.c:517 [inline] really_probe+0x1c2/0xb60 drivers/base/dd.c:596 __driver_probe_device+0x2a6/0x460 drivers/base/dd.c:751 driver_probe_device+0x44/0x110 drivers/base/dd.c:781 __device_attach_driver+0x185/0x250 drivers/base/dd.c:898 bus_for_each_drv+0x11e/0x1a0 drivers/base/bus.c:427 __device_attach+0x1db/0x410 drivers/base/dd.c:969 bus_probe_device+0x19d/0x250 drivers/base/bus.c:487 device_add+0xa57/0x1b90 drivers/base/core.c:3395 usb_set_configuration+0xc1d/0x1710 drivers/usb/core/message.c:2170 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1338 [inline] free_pcp_prepare+0x2c5/0x780 mm/page_alloc.c:1389 free_unref_page_prepare mm/page_alloc.c:3315 [inline] free_unref_page+0x19/0x690 mm/page_alloc.c:3394 free_contig_range+0xa8/0xf0 mm/page_alloc.c:9254 destroy_args+0x7e/0x503 mm/debug_vm_pgtable.c:1016 debug_vm_pgtable+0x1eb8/0x1f3c mm/debug_vm_pgtable.c:1329 do_one_initcall+0xbe/0x440 init/main.c:1303 do_initcall_level init/main.c:1376 [inline] do_initcalls init/main.c:1392 [inline] do_basic_setup init/main.c:1411 [inline] kernel_init_freeable+0x5ab/0x605 init/main.c:1614 kernel_init+0x14/0x120 init/main.c:1505 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Memory state around the buggy address: ffff88805a538800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88805a538880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88805a538900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88805a538980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88805a538a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================