================================================================== BUG: KASAN: slab-use-after-free in v4l2_fh_init drivers/media/v4l2-core/v4l2-fh.c:25 [inline] BUG: KASAN: slab-use-after-free in v4l2_fh_open+0xcb/0x430 drivers/media/v4l2-core/v4l2-fh.c:63 Read of size 8 at addr ffff888017fbc738 by task v4l_id/6302 CPU: 0 PID: 6302 Comm: v4l_id Not tainted 6.3.0-rc6-syzkaller-00046-gde4664485abb #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:319 [inline] print_report+0x163/0x540 mm/kasan/report.c:430 kasan_report+0x176/0x1b0 mm/kasan/report.c:536 v4l2_fh_init drivers/media/v4l2-core/v4l2-fh.c:25 [inline] v4l2_fh_open+0xcb/0x430 drivers/media/v4l2-core/v4l2-fh.c:63 em28xx_v4l2_open+0x14b/0x9b0 drivers/media/usb/em28xx/em28xx-video.c:2153 v4l2_open+0x22c/0x360 drivers/media/v4l2-core/v4l2-dev.c:427 chrdev_open+0x54e/0x630 fs/char_dev.c:414 do_dentry_open+0x7f9/0x10f0 fs/open.c:920 do_open fs/namei.c:3560 [inline] path_openat+0x27b3/0x3170 fs/namei.c:3715 do_filp_open+0x234/0x490 fs/namei.c:3742 do_sys_openat2+0x13f/0x500 fs/open.c:1348 do_sys_open fs/open.c:1364 [inline] __do_sys_openat fs/open.c:1380 [inline] __se_sys_openat fs/open.c:1375 [inline] __x64_sys_openat+0x247/0x290 fs/open.c:1375 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x41/0xc0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7faed8525697 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:00007fff2e688b30 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 0000559d410d2c40 RCX: 00007faed8525697 RDX: 0000000000000000 RSI: 00007fff2e689f1e RDI: 00000000ffffff9c RBP: 00007fff2e689f1e R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 5586: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x70 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:580 [inline] kzalloc include/linux/slab.h:720 [inline] em28xx_v4l2_init+0x107/0x2dc0 drivers/media/usb/em28xx/em28xx-video.c:2532 em28xx_init_extension+0x11f/0x1c0 drivers/media/usb/em28xx/em28xx-core.c:1116 process_one_work+0x8a0/0x10e0 kernel/workqueue.c:2390 process_scheduled_works kernel/workqueue.c:2453 [inline] worker_thread+0xcce/0x1210 kernel/workqueue.c:2542 kthread+0x270/0x300 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 Freed by task 5586: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4f/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:521 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236 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:3787 [inline] __kmem_cache_free+0x264/0x3c0 mm/slub.c:3800 em28xx_free_v4l2 drivers/media/usb/em28xx/em28xx-video.c:2118 [inline] kref_put include/linux/kref.h:65 [inline] em28xx_v4l2_init+0x1608/0x2dc0 drivers/media/usb/em28xx/em28xx-video.c:2901 em28xx_init_extension+0x11f/0x1c0 drivers/media/usb/em28xx/em28xx-core.c:1116 process_one_work+0x8a0/0x10e0 kernel/workqueue.c:2390 process_scheduled_works kernel/workqueue.c:2453 [inline] worker_thread+0xcce/0x1210 kernel/workqueue.c:2542 kthread+0x270/0x300 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 The buggy address belongs to the object at ffff888017fbc000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 1848 bytes inside of freed 8192-byte region [ffff888017fbc000, ffff888017fbe000) The buggy address belongs to the physical page: page:ffffea00005fee00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x17fb8 head:ffffea00005fee00 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0 ksm flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffff888012442280 ffffea0001e37a00 dead000000000003 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1, tgid 1 (swapper/0), ts 3242035204, free_ts 0 prep_new_page mm/page_alloc.c:2553 [inline] get_page_from_freelist+0x3246/0x33c0 mm/page_alloc.c:4326 __alloc_pages+0x255/0x670 mm/page_alloc.c:5592 alloc_page_interleave+0x22/0x1d0 mm/mempolicy.c:2116 alloc_slab_page+0x6a/0x160 mm/slub.c:1851 allocate_slab mm/slub.c:1998 [inline] new_slab+0x84/0x2f0 mm/slub.c:2051 ___slab_alloc+0xa85/0x10a0 mm/slub.c:3193 __slab_alloc mm/slub.c:3292 [inline] __slab_alloc_node mm/slub.c:3345 [inline] slab_alloc_node mm/slub.c:3442 [inline] __kmem_cache_alloc_node+0x1b8/0x290 mm/slub.c:3491 kmalloc_trace+0x2a/0xe0 mm/slab_common.c:1061 kmalloc include/linux/slab.h:580 [inline] kzalloc include/linux/slab.h:720 [inline] mr_table_alloc+0x65/0x250 net/ipv4/ipmr_base.c:41 ipmr_new_table net/ipv4/ipmr.c:409 [inline] ipmr_rules_init net/ipv4/ipmr.c:250 [inline] ipmr_net_init+0x24b/0x3c0 net/ipv4/ipmr.c:3071 ops_init+0x351/0x600 net/core/net_namespace.c:135 __register_pernet_operations net/core/net_namespace.c:1166 [inline] register_pernet_operations+0x2cb/0x660 net/core/net_namespace.c:1235 register_pernet_subsys+0x28/0x40 net/core/net_namespace.c:1276 ip_mr_init+0x39/0x160 net/ipv4/ipmr.c:3134 inet_init+0x307/0x3d0 net/ipv4/af_inet.c:2028 do_one_initcall+0x23d/0x7d0 init/main.c:1310 page_owner free stack trace missing Memory state around the buggy address: ffff888017fbc600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888017fbc680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888017fbc700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888017fbc780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888017fbc800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================