================================================================== BUG: KASAN: use-after-free in v4l2_fh_init+0x279/0x2c0 drivers/media/v4l2-core/v4l2-fh.c:25 Read of size 8 at addr ffff888076bd4738 by task v4l_id/4196 CPU: 1 PID: 4196 Comm: v4l_id Not tainted 6.1.0-rc2-syzkaller-00063-g1a2dcbdde82e #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/11/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:284 [inline] print_report+0x15e/0x461 mm/kasan/report.c:395 kasan_report+0xbb/0x1f0 mm/kasan/report.c:495 v4l2_fh_init+0x279/0x2c0 drivers/media/v4l2-core/v4l2-fh.c:25 v4l2_fh_open+0x88/0xc0 drivers/media/v4l2-core/v4l2-fh.c:63 em28xx_v4l2_open+0x11c/0x570 drivers/media/usb/em28xx/em28xx-video.c:2153 v4l2_open+0x21c/0x3f0 drivers/media/v4l2-core/v4l2-dev.c:427 chrdev_open+0x266/0x770 fs/char_dev.c:414 do_dentry_open+0x6cc/0x13f0 fs/open.c:882 do_open fs/namei.c:3557 [inline] path_openat+0x1bf6/0x2860 fs/namei.c:3713 do_filp_open+0x1b6/0x400 fs/namei.c:3740 do_sys_openat2+0x16d/0x4c0 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_openat fs/open.c:1342 [inline] __se_sys_openat fs/open.c:1337 [inline] __x64_sys_openat+0x13f/0x1f0 fs/open.c:1337 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+0x63/0xcd RIP: 0033:0x7fe143d25697 Code: 25 00 00 41 00 3d 00 00 41 00 74 37 64 8b 04 25 18 00 00 00 85 c0 75 5b 44 89 e2 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 85 00 00 00 48 83 c4 68 5d 41 5c c3 0f 1f RSP: 002b:00007fff00bf7f00 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 000055d0567f3c40 RCX: 00007fe143d25697 RDX: 0000000000000000 RSI: 00007fff00bf8f1f RDI: 00000000ffffff9c RBP: 00007fff00bf8f1f R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 3616: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45 kasan_set_track+0x21/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:371 [inline] ____kasan_kmalloc mm/kasan/common.c:330 [inline] __kasan_kmalloc+0x9f/0xb0 mm/kasan/common.c:380 kmalloc include/linux/slab.h:576 [inline] kzalloc include/linux/slab.h:712 [inline] em28xx_v4l2_init drivers/media/usb/em28xx/em28xx-video.c:2532 [inline] em28xx_v4l2_init.cold+0x93/0x325c drivers/media/usb/em28xx/em28xx-video.c:2510 em28xx_init_extension+0x12f/0x1f0 drivers/media/usb/em28xx/em28xx-core.c:1116 request_module_async+0x5d/0x70 drivers/media/usb/em28xx/em28xx-cards.c:3405 process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289 process_scheduled_works kernel/workqueue.c:2352 [inline] worker_thread+0x803/0x1080 kernel/workqueue.c:2441 kthread+0x2e4/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 Freed by task 3616: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45 kasan_set_track+0x21/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:511 ____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:177 [inline] __cache_free mm/slab.c:3389 [inline] __do_kmem_cache_free mm/slab.c:3585 [inline] __kmem_cache_free+0xc9/0x3a0 mm/slab.c:3592 kref_put.isra.0+0x6f/0xa0 include/linux/kref.h:65 em28xx_v4l2_init drivers/media/usb/em28xx/em28xx-video.c:2901 [inline] em28xx_v4l2_init.cold+0x263/0x325c drivers/media/usb/em28xx/em28xx-video.c:2510 em28xx_init_extension+0x12f/0x1f0 drivers/media/usb/em28xx/em28xx-core.c:1116 request_module_async+0x5d/0x70 drivers/media/usb/em28xx/em28xx-cards.c:3405 process_one_work+0x9bf/0x1710 kernel/workqueue.c:2289 process_scheduled_works kernel/workqueue.c:2352 [inline] worker_thread+0x803/0x1080 kernel/workqueue.c:2441 kthread+0x2e4/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306 The buggy address belongs to the object at ffff888076bd4000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 1848 bytes inside of 8192-byte region [ffff888076bd4000, ffff888076bd6000) The buggy address belongs to the physical page: page:ffffea0001daf500 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x76bd4 head:ffffea0001daf500 order:2 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffffea000071ac08 ffffea0001f57d08 ffff888011840a00 raw: 0000000000000000 ffff888076bd4000 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 0x342040(__GFP_IO|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 4074, tgid 4074 (syz-execprog), ts 71269038783, free_ts 67004298949 prep_new_page mm/page_alloc.c:2538 [inline] get_page_from_freelist+0x10b5/0x2d50 mm/page_alloc.c:4287 __alloc_pages+0x1c7/0x5a0 mm/page_alloc.c:5554 __alloc_pages_node include/linux/gfp.h:223 [inline] kmem_getpages mm/slab.c:1363 [inline] cache_grow_begin+0x75/0x360 mm/slab.c:2570 cache_alloc_refill+0x27f/0x380 mm/slab.c:2943 ____cache_alloc mm/slab.c:3019 [inline] ____cache_alloc mm/slab.c:3002 [inline] __do_cache_alloc mm/slab.c:3202 [inline] slab_alloc_node mm/slab.c:3250 [inline] __kmem_cache_alloc_node+0x442/0x500 mm/slab.c:3549 kmalloc_trace+0x22/0x60 mm/slab_common.c:1046 kmalloc include/linux/slab.h:576 [inline] kzalloc include/linux/slab.h:712 [inline] tomoyo_print_bprm security/tomoyo/audit.c:26 [inline] tomoyo_init_log+0xc86/0x1ed0 security/tomoyo/audit.c:264 tomoyo_supervisor+0x350/0xf10 security/tomoyo/common.c:2088 tomoyo_audit_env_log security/tomoyo/environ.c:36 [inline] tomoyo_env_perm+0x17f/0x1f0 security/tomoyo/environ.c:63 tomoyo_environ security/tomoyo/domain.c:672 [inline] tomoyo_find_next_domain+0x13ce/0x1f80 security/tomoyo/domain.c:879 tomoyo_bprm_check_security security/tomoyo/tomoyo.c:101 [inline] tomoyo_bprm_check_security+0x121/0x1a0 security/tomoyo/tomoyo.c:91 security_bprm_check+0x45/0xa0 security/security.c:869 search_binary_handler fs/exec.c:1715 [inline] exec_binprm fs/exec.c:1768 [inline] bprm_execve fs/exec.c:1837 [inline] bprm_execve+0x732/0x19f0 fs/exec.c:1799 do_execveat_common+0x724/0x890 fs/exec.c:1942 do_execve fs/exec.c:2016 [inline] __do_sys_execve fs/exec.c:2092 [inline] __se_sys_execve fs/exec.c:2087 [inline] __x64_sys_execve+0x8f/0xc0 fs/exec.c:2087 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1458 [inline] free_pcp_prepare+0x65c/0xd90 mm/page_alloc.c:1508 free_unref_page_prepare mm/page_alloc.c:3386 [inline] free_unref_page+0x19/0x4d0 mm/page_alloc.c:3482 slab_destroy mm/slab.c:1615 [inline] slabs_destroy+0x85/0xc0 mm/slab.c:1635 cache_flusharray mm/slab.c:3360 [inline] ___cache_free+0x2a8/0x3d0 mm/slab.c:3423 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x4f/0x1a0 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x5f/0x80 mm/kasan/common.c:302 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook mm/slab.h:737 [inline] slab_alloc_node mm/slab.c:3257 [inline] slab_alloc mm/slab.c:3265 [inline] __kmem_cache_alloc_lru mm/slab.c:3442 [inline] kmem_cache_alloc+0x218/0x450 mm/slab.c:3461 vm_area_dup+0x81/0x380 kernel/fork.c:466 __split_vma+0x9f/0x5c0 mm/mmap.c:2211 split_vma+0x9f/0xe0 mm/mmap.c:2273 mprotect_fixup+0x746/0x960 mm/mprotect.c:623 do_mprotect_pkey+0x6fd/0xa70 mm/mprotect.c:792 __do_sys_mprotect mm/mprotect.c:819 [inline] __se_sys_mprotect mm/mprotect.c:816 [inline] __x64_sys_mprotect+0x74/0xb0 mm/mprotect.c:816 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+0x63/0xcd Memory state around the buggy address: ffff888076bd4600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888076bd4680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888076bd4700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888076bd4780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888076bd4800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================