================================================================== BUG: KASAN: slab-use-after-free in v4l2_fh_init+0x27d/0x2c0 drivers/media/v4l2-core/v4l2-fh.c:25 Read of size 8 at addr ffff888000518738 by task v4l_id/5518 CPU: 0 PID: 5518 Comm: v4l_id Not tainted 6.4.0-rc1-syzkaller-gcc3c44c9fda2 #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106 print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:351 print_report mm/kasan/report.c:462 [inline] kasan_report+0x11c/0x130 mm/kasan/report.c:572 v4l2_fh_init+0x27d/0x2c0 drivers/media/v4l2-core/v4l2-fh.c:25 v4l2_fh_open+0x8c/0xc0 drivers/media/v4l2-core/v4l2-fh.c:63 em28xx_v4l2_open+0x24a/0x7f0 drivers/media/usb/em28xx/em28xx-video.c:2153 v4l2_open+0x220/0x480 drivers/media/v4l2-core/v4l2-dev.c:427 chrdev_open+0x26a/0x770 fs/char_dev.c:414 do_dentry_open+0x6cc/0x13f0 fs/open.c:920 do_open fs/namei.c:3636 [inline] path_openat+0x1baa/0x2750 fs/namei.c:3791 do_filp_open+0x1ba/0x410 fs/namei.c:3818 do_sys_openat2+0x16d/0x4c0 fs/open.c:1356 do_sys_open fs/open.c:1372 [inline] __do_sys_openat fs/open.c:1388 [inline] __se_sys_openat fs/open.c:1383 [inline] __x64_sys_openat+0x143/0x1f0 fs/open.c:1383 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fb39bd169a4 Code: 24 20 48 8d 44 24 30 48 89 44 24 28 64 8b 04 25 18 00 00 00 85 c0 75 2c 44 89 e2 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 76 60 48 8b 15 55 a4 0d 00 f7 d8 64 89 02 48 83 RSP: 002b:00007ffd7a9e9230 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 00007ffd7a9e9448 RCX: 00007fb39bd169a4 RDX: 0000000000000000 RSI: 00007ffd7a9eaf21 RDI: 00000000ffffff9c RBP: 00007ffd7a9eaf21 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffd7a9e9460 R14: 0000555aca19d670 R15: 00007fb39c1e8a80 Allocated by task 965: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] ____kasan_kmalloc mm/kasan/common.c:333 [inline] __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:559 [inline] kzalloc include/linux/slab.h:680 [inline] em28xx_v4l2_init drivers/media/usb/em28xx/em28xx-video.c:2532 [inline] em28xx_v4l2_init+0x128/0x3ea0 drivers/media/usb/em28xx/em28xx-video.c:2510 em28xx_init_extension+0x133/0x1f0 drivers/media/usb/em28xx/em28xx-core.c:1116 request_module_async+0x61/0x70 drivers/media/usb/em28xx/em28xx-cards.c:3405 process_one_work+0x99a/0x15e0 kernel/workqueue.c:2405 worker_thread+0x67d/0x10c0 kernel/workqueue.c:2552 kthread+0x344/0x440 kernel/kthread.c:379 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 Freed by task 965: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:521 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x13b/0x1a0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:162 [inline] __cache_free mm/slab.c:3389 [inline] __do_kmem_cache_free mm/slab.c:3576 [inline] __kmem_cache_free+0xcd/0x2c0 mm/slab.c:3583 em28xx_free_v4l2 drivers/media/usb/em28xx/em28xx-video.c:2118 [inline] kref_put include/linux/kref.h:65 [inline] em28xx_v4l2_init drivers/media/usb/em28xx/em28xx-video.c:2901 [inline] em28xx_v4l2_init+0xd5e/0x3ea0 drivers/media/usb/em28xx/em28xx-video.c:2510 em28xx_init_extension+0x133/0x1f0 drivers/media/usb/em28xx/em28xx-core.c:1116 request_module_async+0x61/0x70 drivers/media/usb/em28xx/em28xx-cards.c:3405 process_one_work+0x99a/0x15e0 kernel/workqueue.c:2405 worker_thread+0x67d/0x10c0 kernel/workqueue.c:2552 kthread+0x344/0x440 kernel/kthread.c:379 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 The buggy address belongs to the object at ffff888000518000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 1848 bytes inside of freed 8192-byte region [ffff888000518000, ffff88800051a000) The buggy address belongs to the physical page: page:ffffea0000014600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x518 head:ffffea0000014600 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0x7ff00000010200(slab|head|node=0|zone=0|lastcpupid=0x7ff) page_type: 0x1() raw: 007ff00000010200 ffff888012440a00 ffffea0000a9ec10 ffffea0000582510 raw: 0000000000000000 ffff888000518000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Unmovable, gfp_mask 0x2420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_THISNODE), pid 1393, tgid 1393 (kworker/1:2), ts 74643067995, free_ts 73666863691 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2db/0x350 mm/page_alloc.c:1731 prep_new_page mm/page_alloc.c:1738 [inline] get_page_from_freelist+0xf41/0x2c00 mm/page_alloc.c:3502 __alloc_pages_slowpath.constprop.0+0x2e7/0x2170 mm/page_alloc.c:4302 __alloc_pages+0x408/0x4a0 mm/page_alloc.c:4781 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1360 [inline] cache_grow_begin+0x9b/0x3b0 mm/slab.c:2569 cache_alloc_refill+0x27f/0x380 mm/slab.c:2942 ____cache_alloc mm/slab.c:3018 [inline] ____cache_alloc mm/slab.c:3001 [inline] __do_cache_alloc mm/slab.c:3201 [inline] slab_alloc_node mm/slab.c:3249 [inline] __kmem_cache_alloc_node+0x360/0x3f0 mm/slab.c:3540 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1057 kmalloc include/linux/slab.h:559 [inline] kzalloc include/linux/slab.h:680 [inline] em28xx_v4l2_init drivers/media/usb/em28xx/em28xx-video.c:2532 [inline] em28xx_v4l2_init+0x128/0x3ea0 drivers/media/usb/em28xx/em28xx-video.c:2510 em28xx_init_extension+0x133/0x1f0 drivers/media/usb/em28xx/em28xx-core.c:1116 request_module_async+0x61/0x70 drivers/media/usb/em28xx/em28xx-cards.c:3405 process_one_work+0x99a/0x15e0 kernel/workqueue.c:2405 process_scheduled_works kernel/workqueue.c:2468 [inline] worker_thread+0x830/0x10c0 kernel/workqueue.c:2557 kthread+0x344/0x440 kernel/kthread.c:379 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1302 [inline] free_unref_page_prepare+0x62e/0xcb0 mm/page_alloc.c:2564 free_unref_page+0x33/0x370 mm/page_alloc.c:2659 slab_destroy mm/slab.c:1612 [inline] slabs_destroy+0x85/0xc0 mm/slab.c:1632 cache_flusharray mm/slab.c:3360 [inline] ___cache_free+0x2ae/0x3d0 mm/slab.c:3423 qlink_free mm/kasan/quarantine.c:166 [inline] qlist_free_all+0x4f/0x1a0 mm/kasan/quarantine.c:185 kasan_quarantine_reduce+0x195/0x220 mm/kasan/quarantine.c:292 __kasan_slab_alloc+0x63/0x90 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:186 [inline] slab_post_alloc_hook mm/slab.h:711 [inline] slab_alloc_node mm/slab.c:3256 [inline] __kmem_cache_alloc_node+0x1fc/0x3f0 mm/slab.c:3540 __do_kmalloc_node mm/slab_common.c:965 [inline] __kmalloc+0x4e/0x190 mm/slab_common.c:979 kmalloc include/linux/slab.h:563 [inline] tomoyo_realpath_from_path+0xc3/0x600 security/tomoyo/realpath.c:251 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_number_perm+0x21a/0x570 security/tomoyo/file.c:723 security_file_ioctl+0x54/0xb0 security/security.c:2608 __do_sys_ioctl fs/ioctl.c:864 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0xb7/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Memory state around the buggy address: ffff888000518600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888000518680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888000518700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888000518780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888000518800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================