================================================================== BUG: KASAN: use-after-free in v4l2_fh_init+0x27d/0x2c0 drivers/media/v4l2-core/v4l2-fh.c:25 Read of size 8 at addr ffff888000340738 by task v4l_id/5498 CPU: 3 PID: 5498 Comm: v4l_id Not tainted 6.2.0-rc6-syzkaller-33480-g9f266ccaa2f5 #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+0xd1/0x138 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:306 [inline] print_report+0x15e/0x461 mm/kasan/report.c:417 kasan_report+0xbf/0x1f0 mm/kasan/report.c:517 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+0x120/0x570 drivers/media/usb/em28xx/em28xx-video.c:2153 v4l2_open+0x220/0x3f0 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:882 do_open fs/namei.c:3557 [inline] path_openat+0x1bbc/0x2a50 fs/namei.c:3714 do_filp_open+0x1ba/0x410 fs/namei.c:3741 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+0x143/0x1f0 fs/open.c:1337 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:0x7fe7f73a6697 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:00007ffda631c400 EFLAGS: 00000246 ORIG_RAX: 0000000000000101 RAX: ffffffffffffffda RBX: 00005639b55bac40 RCX: 00007fe7f73a6697 RDX: 0000000000000000 RSI: 00007ffda631cf20 RDI: 00000000ffffff9c RBP: 00007ffda631cf20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 801: 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:371 [inline] ____kasan_kmalloc mm/kasan/common.c:330 [inline] __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:380 kmalloc include/linux/slab.h:580 [inline] kzalloc include/linux/slab.h:720 [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+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+0x9bf/0x1710 kernel/workqueue.c:2289 process_scheduled_works kernel/workqueue.c:2352 [inline] worker_thread+0x807/0x1090 kernel/workqueue.c:2441 kthread+0x2e8/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 Freed by task 801: 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:518 ____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:3396 [inline] __do_kmem_cache_free mm/slab.c:3582 [inline] __kmem_cache_free+0xcd/0x3b0 mm/slab.c:3589 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+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+0x9bf/0x1710 kernel/workqueue.c:2289 process_scheduled_works kernel/workqueue.c:2352 [inline] worker_thread+0x807/0x1090 kernel/workqueue.c:2441 kthread+0x2e8/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 The buggy address belongs to the object at ffff888000340000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 1848 bytes inside of 8192-byte region [ffff888000340000, ffff888000342000) The buggy address belongs to the physical page: page:ffffea000000d000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x340 head:ffffea000000d000 order:2 compound_mapcount:0 subpages_mapcount:0 compound_pincount:0 flags: 0x7ff00000010200(slab|head|node=0|zone=0|lastcpupid=0x7ff) raw: 007ff00000010200 ffff888012440a00 ffffea0000007210 ffffea000000e910 raw: 0000000000000000 ffff888000340000 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 0x2d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_THISNODE), pid 4808, tgid 4808 (dhcpcd), ts 118059386220, free_ts 113720974051 prep_new_page mm/page_alloc.c:2531 [inline] get_page_from_freelist+0x119c/0x2ce0 mm/page_alloc.c:4283 __alloc_pages_slowpath.constprop.0+0x36b/0x23d0 mm/page_alloc.c:5084 __alloc_pages+0x4aa/0x5b0 mm/page_alloc.c:5562 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1363 [inline] cache_grow_begin+0x94/0x390 mm/slab.c:2576 cache_alloc_refill+0x27f/0x380 mm/slab.c:2949 ____cache_alloc mm/slab.c:3025 [inline] ____cache_alloc mm/slab.c:3008 [inline] __do_cache_alloc mm/slab.c:3208 [inline] slab_alloc_node mm/slab.c:3256 [inline] __kmem_cache_alloc_node+0x44f/0x510 mm/slab.c:3546 __do_kmalloc_node mm/slab_common.c:967 [inline] __kmalloc_node_track_caller+0x4b/0xc0 mm/slab_common.c:988 kmalloc_reserve net/core/skbuff.c:492 [inline] __alloc_skb+0xe9/0x310 net/core/skbuff.c:565 alloc_skb include/linux/skbuff.h:1270 [inline] netlink_dump+0x2db/0xc50 net/netlink/af_netlink.c:2263 netlink_recvmsg+0xbe1/0xe50 net/netlink/af_netlink.c:2023 sock_recvmsg_nosec net/socket.c:995 [inline] sock_recvmsg net/socket.c:1013 [inline] sock_recvmsg net/socket.c:1009 [inline] ____sys_recvmsg+0x2c7/0x610 net/socket.c:2695 ___sys_recvmsg+0xf2/0x180 net/socket.c:2737 __sys_recvmsg+0xf4/0x1c0 net/socket.c:2767 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 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1446 [inline] free_pcp_prepare+0x65c/0xc00 mm/page_alloc.c:1496 free_unref_page_prepare mm/page_alloc.c:3369 [inline] free_unref_page+0x1d/0x490 mm/page_alloc.c:3464 __folio_put_small mm/swap.c:106 [inline] __folio_put+0xc5/0x140 mm/swap.c:129 folio_put include/linux/mm.h:1250 [inline] put_page include/linux/mm.h:1319 [inline] anon_pipe_buf_release+0x3fb/0x4c0 fs/pipe.c:138 pipe_buf_release include/linux/pipe_fs_i.h:183 [inline] pipe_read+0x614/0x1110 fs/pipe.c:324 call_read_iter include/linux/fs.h:2183 [inline] new_sync_read fs/read_write.c:389 [inline] vfs_read+0x7fa/0x930 fs/read_write.c:470 ksys_read+0x1ec/0x250 fs/read_write.c:613 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: ffff888000340600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888000340680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888000340700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888000340780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888000340800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================