================================================================== 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 ffff888106740730 by task v4l_id/3114 CPU: 1 PID: 3114 Comm: v4l_id Not tainted 6.4.0-rc5-syzkaller-00265-ge4cf7f195d60 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023 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+0x6c7/0x12a0 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:0x7fe3fe7559a4 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:00007ffe4bc09440 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 00007ffe4bc09658 RCX: 00007fe3fe7559a4 RDX: 0000000000000000 RSI: 00007ffe4bc09f25 RDI: 00000000ffffff9c RBP: 00007ffe4bc09f25 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffe4bc09670 R14: 000055e1ace14670 R15: 00007fe3feb9ea80 Allocated by task 9: 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+0x7b/0x90 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 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 Freed by task 9: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2e/0x40 mm/kasan/generic.c:521 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x144/0x1b0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:162 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook mm/slub.c:1807 [inline] slab_free mm/slub.c:3786 [inline] __kmem_cache_free+0x99/0x320 mm/slub.c:3799 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 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 The buggy address belongs to the object at ffff888106740000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 1840 bytes inside of freed 8192-byte region [ffff888106740000, ffff888106742000) The buggy address belongs to the physical page: page:ffffea000419d000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x106740 head:ffffea000419d000 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0 anon flags: 0x200000000010200(slab|head|node=0|zone=2) page_type: 0xffffffff() raw: 0200000000010200 ffff888100042280 ffffea000419f200 0000000000000003 raw: 0000000000000000 0000000080020002 00000001ffffffff 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 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 2441, tgid 2441 (sh), ts 26662762551, free_ts 26651212954 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+0x13a1/0x2aa0 mm/page_alloc.c:3502 __alloc_pages+0x1cb/0x4a0 mm/page_alloc.c:4768 alloc_pages+0x1aa/0x270 mm/mempolicy.c:2279 alloc_slab_page mm/slub.c:1851 [inline] allocate_slab+0x25f/0x390 mm/slub.c:1998 new_slab mm/slub.c:2051 [inline] ___slab_alloc+0xa91/0x1400 mm/slub.c:3192 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3291 __slab_alloc_node mm/slub.c:3344 [inline] slab_alloc_node mm/slub.c:3441 [inline] __kmem_cache_alloc_node+0x291/0x2d0 mm/slub.c:3490 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1057 kmalloc include/linux/slab.h:559 [inline] kzalloc include/linux/slab.h:680 [inline] tomoyo_print_bprm security/tomoyo/audit.c:26 [inline] tomoyo_init_log+0xcdd/0x1f00 security/tomoyo/audit.c:264 tomoyo_supervisor+0x34e/0xec0 security/tomoyo/common.c:2088 tomoyo_audit_env_log security/tomoyo/environ.c:36 [inline] tomoyo_env_perm+0x183/0x200 security/tomoyo/environ.c:63 tomoyo_environ security/tomoyo/domain.c:672 [inline] tomoyo_find_next_domain+0x148f/0x1ff0 security/tomoyo/domain.c:879 tomoyo_bprm_check_security security/tomoyo/tomoyo.c:101 [inline] tomoyo_bprm_check_security+0x136/0x1d0 security/tomoyo/tomoyo.c:91 security_bprm_check+0x49/0xb0 security/security.c:1102 search_binary_handler fs/exec.c:1725 [inline] exec_binprm fs/exec.c:1779 [inline] bprm_execve fs/exec.c:1854 [inline] bprm_execve+0x740/0x1970 fs/exec.c:1810 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+0x613/0xc80 mm/page_alloc.c:2564 free_unref_page+0x33/0x2a0 mm/page_alloc.c:2659 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2636 qlink_free mm/kasan/quarantine.c:166 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:185 kasan_quarantine_reduce+0x195/0x220 mm/kasan/quarantine.c:292 __kasan_slab_alloc+0x45/0x60 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/slub.c:3451 [inline] slab_alloc mm/slub.c:3459 [inline] __kmem_cache_alloc_lru mm/slub.c:3466 [inline] kmem_cache_alloc+0x177/0x370 mm/slub.c:3475 getname_flags.part.0+0x50/0x4f0 fs/namei.c:140 getname_flags include/linux/audit.h:321 [inline] getname+0x92/0xd0 fs/namei.c:219 do_sys_openat2+0xf5/0x4c0 fs/open.c:1350 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 Memory state around the buggy address: ffff888106740600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888106740680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888106740700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888106740780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888106740800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================