================================================================== BUG: KASAN: slab-use-after-free in sysfs_remove_file_ns+0x63/0x70 fs/sysfs/file.c:522 Read of size 8 at addr ffff88805083c630 by task syz.8.4847/21974 CPU: 1 UID: 0 PID: 21974 Comm: syz.8.4847 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xcd/0x630 mm/kasan/report.c:482 kasan_report+0xe0/0x110 mm/kasan/report.c:595 sysfs_remove_file_ns+0x63/0x70 fs/sysfs/file.c:522 sysfs_remove_file include/linux/sysfs.h:777 [inline] driver_remove_file drivers/base/driver.c:201 [inline] driver_remove_file+0x4a/0x60 drivers/base/driver.c:197 remove_bind_files drivers/base/bus.c:605 [inline] bus_remove_driver+0x224/0x2c0 drivers/base/bus.c:743 driver_unregister+0x76/0xb0 drivers/base/driver.c:277 comedi_device_detach_locked+0x12f/0xa50 drivers/comedi/drivers.c:207 do_devconfig_ioctl+0x555/0x710 drivers/comedi/comedi_fops.c:848 comedi_unlocked_ioctl+0x165d/0x2f00 drivers/comedi/comedi_fops.c:2178 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:598 [inline] __se_sys_ioctl fs/ioctl.c:584 [inline] __x64_sys_ioctl+0x18b/0x210 fs/ioctl.c:584 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7efd89d8ebe9 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007efd8acf3038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007efd89fc5fa0 RCX: 00007efd89d8ebe9 RDX: 0000000000000000 RSI: 0000000040946400 RDI: 0000000000000003 RBP: 00007efd89e11e19 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007efd89fc6038 R14: 00007efd89fc5fa0 R15: 00007ffe3c7c0898 Allocated by task 21798: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 kasan_mempool_unpoison_object include/linux/kasan.h:388 [inline] kasan_unpoison_element mm/mempool.c:128 [inline] remove_element+0x133/0x1e0 mm/mempool.c:150 mempool_exit+0xa5/0x1c0 mm/mempool.c:169 fanotify_free_group_priv+0x148/0x1b0 fs/notify/fanotify/fanotify.c:1025 fsnotify_final_destroy_group fs/notify/group.c:25 [inline] fsnotify_put_group+0xb8/0x450 fs/notify/group.c:110 fsnotify_destroy_group+0x1db/0x390 fs/notify/group.c:93 fanotify_release+0x261/0x330 fs/notify/fanotify/fanotify_user.c:1053 __fput+0x402/0xb70 fs/file_table.c:468 task_work_run+0x14d/0x240 kernel/task_work.c:227 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] exit_to_user_mode_loop+0xeb/0x110 kernel/entry/common.c:43 exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline] syscall_exit_to_user_mode_work include/linux/entry-common.h:175 [inline] syscall_exit_to_user_mode include/linux/entry-common.h:210 [inline] do_syscall_64+0x3f6/0x4c0 arch/x86/entry/syscall_64.c:100 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 21798: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:576 poison_slab_object mm/kasan/common.c:243 [inline] __kasan_slab_free+0x60/0x70 mm/kasan/common.c:275 kasan_slab_free include/linux/kasan.h:233 [inline] slab_free_hook mm/slub.c:2417 [inline] slab_free mm/slub.c:4680 [inline] kfree+0x2b4/0x4d0 mm/slub.c:4879 mempool_exit+0xcb/0x1c0 mm/mempool.c:170 fanotify_free_group_priv+0x148/0x1b0 fs/notify/fanotify/fanotify.c:1025 fsnotify_final_destroy_group fs/notify/group.c:25 [inline] fsnotify_put_group+0xb8/0x450 fs/notify/group.c:110 fsnotify_destroy_group+0x1db/0x390 fs/notify/group.c:93 fanotify_release+0x261/0x330 fs/notify/fanotify/fanotify_user.c:1053 __fput+0x402/0xb70 fs/file_table.c:468 task_work_run+0x14d/0x240 kernel/task_work.c:227 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] exit_to_user_mode_loop+0xeb/0x110 kernel/entry/common.c:43 exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline] syscall_exit_to_user_mode_work include/linux/entry-common.h:175 [inline] syscall_exit_to_user_mode include/linux/entry-common.h:210 [inline] do_syscall_64+0x3f6/0x4c0 arch/x86/entry/syscall_64.c:100 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff88805083c600 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 48 bytes inside of freed 256-byte region [ffff88805083c600, ffff88805083c700) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff88805083d000 pfn:0x5083c head: order:1 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000040 ffff88801b842b40 ffffea0000dd0c00 dead000000000002 raw: ffff88805083d000 000000000010000a 00000000f5000000 0000000000000000 head: 00fff00000000040 ffff88801b842b40 ffffea0000dd0c00 dead000000000002 head: ffff88805083d000 000000000010000a 00000000f5000000 0000000000000000 head: 00fff00000000001 ffffea0001420f01 00000000ffffffff 00000000ffffffff head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000002 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 15054, tgid 15053 (syz.6.2698), ts 272451571992, free_ts 257072648067 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1c0/0x230 mm/page_alloc.c:1851 prep_new_page mm/page_alloc.c:1859 [inline] get_page_from_freelist+0x132b/0x38e0 mm/page_alloc.c:3858 __alloc_frozen_pages_noprof+0x261/0x23f0 mm/page_alloc.c:5148 alloc_pages_mpol+0x1fb/0x550 mm/mempolicy.c:2416 alloc_slab_page mm/slub.c:2487 [inline] allocate_slab mm/slub.c:2655 [inline] new_slab+0x247/0x330 mm/slub.c:2709 ___slab_alloc+0xcf2/0x1740 mm/slub.c:3891 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3981 __slab_alloc_node mm/slub.c:4056 [inline] slab_alloc_node mm/slub.c:4217 [inline] __do_kmalloc_node mm/slub.c:4364 [inline] __kmalloc_noprof+0x2f2/0x510 mm/slub.c:4377 kmalloc_noprof include/linux/slab.h:909 [inline] kmalloc_array_noprof include/linux/slab.h:948 [inline] __list_lru_init+0xe8/0x4c0 mm/list_lru.c:588 alloc_super+0x904/0xbd0 fs/super.c:391 sget_fc+0x116/0xc20 fs/super.c:761 vfs_get_super fs/super.c:1320 [inline] get_tree_nodev+0x28/0x190 fs/super.c:1344 vfs_get_tree+0x8b/0x340 fs/super.c:1815 do_new_mount fs/namespace.c:3808 [inline] path_mount+0x1513/0x2000 fs/namespace.c:4123 do_mount fs/namespace.c:4136 [inline] __do_sys_mount fs/namespace.c:4347 [inline] __se_sys_mount fs/namespace.c:4324 [inline] __x64_sys_mount+0x28d/0x310 fs/namespace.c:4324 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94 page last free pid 14747 tgid 14747 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1395 [inline] __free_frozen_pages+0x7d5/0x10f0 mm/page_alloc.c:2895 vfree+0x1fd/0xb50 mm/vmalloc.c:3434 vb2_vmalloc_put drivers/media/common/videobuf2/videobuf2-vmalloc.c:68 [inline] vb2_vmalloc_put+0x7b/0xc0 drivers/media/common/videobuf2/videobuf2-vmalloc.c:63 __vb2_buf_mem_free+0x15a/0x2d0 drivers/media/common/videobuf2/videobuf2-core.c:275 __vb2_free_mem drivers/media/common/videobuf2/videobuf2-core.c:571 [inline] __vb2_queue_free+0x7ee/0xa30 drivers/media/common/videobuf2/videobuf2-core.c:599 vb2_core_queue_release+0x70/0x190 drivers/media/common/videobuf2/videobuf2-core.c:2695 v4l2_m2m_ctx_release+0x2a/0x40 drivers/media/v4l2-core/v4l2-mem2mem.c:1277 vicodec_release+0x9c/0x150 drivers/media/test-drivers/vicodec/vicodec-core.c:1948 v4l2_release+0x235/0x460 drivers/media/v4l2-core/v4l2-dev.c:458 __fput+0x402/0xb70 fs/file_table.c:468 task_work_run+0x14d/0x240 kernel/task_work.c:227 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline] exit_to_user_mode_loop+0xeb/0x110 kernel/entry/common.c:43 exit_to_user_mode_prepare include/linux/irq-entry-common.h:225 [inline] syscall_exit_to_user_mode_work include/linux/entry-common.h:175 [inline] syscall_exit_to_user_mode include/linux/entry-common.h:210 [inline] do_syscall_64+0x3f6/0x4c0 arch/x86/entry/syscall_64.c:100 entry_SYSCALL_64_after_hwframe+0x77/0x7f Memory state around the buggy address: ffff88805083c500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88805083c580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88805083c600: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88805083c680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88805083c700: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================