================================================================== BUG: KASAN: use-after-free in btrfs_sb fs/btrfs/super.h:14 [inline] BUG: KASAN: use-after-free in wait_subpage_spinlock+0x1be/0x210 fs/btrfs/inode.c:8232 Read of size 8 at addr ffff888020470678 by task syz-executor.1/27513 CPU: 2 PID: 27513 Comm: syz-executor.1 Not tainted 6.2.0-rc3-syzkaller-00021-g7dd4b804e080 #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/0x45d mm/kasan/report.c:417 kasan_report+0xbf/0x1f0 mm/kasan/report.c:517 btrfs_sb fs/btrfs/super.h:14 [inline] wait_subpage_spinlock+0x1be/0x210 fs/btrfs/inode.c:8232 __btrfs_release_folio fs/btrfs/inode.c:8261 [inline] btrfs_release_folio+0x109/0x130 fs/btrfs/inode.c:8271 filemap_release_folio+0x13f/0x1b0 mm/filemap.c:3967 shrink_folio_list+0x1ea9/0x3a60 mm/vmscan.c:2000 shrink_inactive_list mm/vmscan.c:2526 [inline] shrink_list mm/vmscan.c:2767 [inline] shrink_lruvec+0xd0e/0x27a0 mm/vmscan.c:5951 shrink_node_memcgs mm/vmscan.c:6138 [inline] shrink_node+0x8f2/0x1f40 mm/vmscan.c:6169 shrink_zones mm/vmscan.c:6407 [inline] do_try_to_free_pages+0x3b4/0x17a0 mm/vmscan.c:6469 try_to_free_mem_cgroup_pages+0x3ae/0xa80 mm/vmscan.c:6786 memory_high_write+0x25e/0x300 mm/memcontrol.c:6431 cgroup_file_write+0x1e2/0x770 kernel/cgroup/cgroup.c:4061 kernfs_fop_write_iter+0x3f1/0x600 fs/kernfs/file.c:334 call_write_iter include/linux/fs.h:2189 [inline] do_iter_readv_writev+0x20b/0x3b0 fs/read_write.c:735 do_iter_write+0x182/0x700 fs/read_write.c:861 vfs_iter_write+0x74/0xa0 fs/read_write.c:902 iter_file_splice_write+0x745/0xc90 fs/splice.c:686 do_splice_from fs/splice.c:764 [inline] direct_splice_actor+0x114/0x180 fs/splice.c:931 splice_direct_to_actor+0x335/0x8a0 fs/splice.c:886 do_splice_direct+0x1ab/0x280 fs/splice.c:974 do_sendfile+0xb19/0x1270 fs/read_write.c:1255 __do_compat_sys_sendfile fs/read_write.c:1344 [inline] __se_compat_sys_sendfile fs/read_write.c:1327 [inline] __ia32_compat_sys_sendfile+0x1e1/0x220 fs/read_write.c:1327 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline] __do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203 entry_SYSENTER_compat_after_hwframe+0x70/0x82 RIP: 0023:0xf7f22549 Code: 03 74 c0 01 10 05 03 74 b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00 RSP: 002b:00000000f7f1d5cc EFLAGS: 00000296 ORIG_RAX: 00000000000000bb RAX: ffffffffffffffda RBX: 0000000000000009 RCX: 0000000000000009 RDX: 0000000000000000 RSI: 0000000000000003 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000296 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 6287: 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+0xa5/0xb0 mm/kasan/common.c:380 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slab_common.c:968 [inline] __kmalloc+0x5a/0xd0 mm/slab_common.c:981 kmalloc include/linux/slab.h:584 [inline] tomoyo_realpath_from_path+0xc3/0x600 security/tomoyo/realpath.c:251 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x22d/0x430 security/tomoyo/file.c:822 tomoyo_path_unlink+0x92/0xd0 security/tomoyo/tomoyo.c:161 security_path_unlink+0xdb/0x150 security/security.c:1203 do_unlinkat+0x363/0x640 fs/namei.c:4316 __do_sys_unlink fs/namei.c:4368 [inline] __se_sys_unlink fs/namei.c:4366 [inline] __ia32_sys_unlink+0xca/0x110 fs/namei.c:4366 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline] __do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203 entry_SYSENTER_compat_after_hwframe+0x70/0x82 Freed by task 6287: 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:518 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:177 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1807 slab_free mm/slub.c:3787 [inline] __kmem_cache_free+0xaf/0x3b0 mm/slub.c:3800 tomoyo_realpath_from_path+0x190/0x600 security/tomoyo/realpath.c:286 tomoyo_get_realpath security/tomoyo/file.c:151 [inline] tomoyo_path_perm+0x22d/0x430 security/tomoyo/file.c:822 tomoyo_path_unlink+0x92/0xd0 security/tomoyo/tomoyo.c:161 security_path_unlink+0xdb/0x150 security/security.c:1203 do_unlinkat+0x363/0x640 fs/namei.c:4316 __do_sys_unlink fs/namei.c:4368 [inline] __se_sys_unlink fs/namei.c:4366 [inline] __ia32_sys_unlink+0xca/0x110 fs/namei.c:4366 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline] __do_fast_syscall_32+0x65/0xf0 arch/x86/entry/common.c:178 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203 entry_SYSENTER_compat_after_hwframe+0x70/0x82 Last potentially related work creation: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:488 insert_work+0x48/0x350 kernel/workqueue.c:1358 __queue_work+0x693/0x13b0 kernel/workqueue.c:1517 queue_work_on+0xf2/0x110 kernel/workqueue.c:1545 queue_work include/linux/workqueue.h:503 [inline] io_ring_ctx_wait_and_kill+0x30a/0x33f io_uring/io_uring.c:2951 io_uring_release+0x46/0x4a io_uring/io_uring.c:2959 __fput+0x27c/0xa90 fs/file_table.c:320 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xaa8/0x2950 kernel/exit.c:867 do_group_exit+0xd4/0x2a0 kernel/exit.c:1012 get_signal+0x21c3/0x2450 kernel/signal.c:2859 arch_do_signal_or_restart+0x79/0x5c0 arch/x86/kernel/signal.c:306 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x15f/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296 __do_fast_syscall_32+0x72/0xf0 arch/x86/entry/common.c:181 do_fast_syscall_32+0x33/0x70 arch/x86/entry/common.c:203 entry_SYSENTER_compat_after_hwframe+0x70/0x82 Second to last potentially related work creation: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:488 insert_work+0x48/0x350 kernel/workqueue.c:1358 __queue_work+0x693/0x13b0 kernel/workqueue.c:1517 queue_work_on+0xf2/0x110 kernel/workqueue.c:1545 rcu_do_batch kernel/rcu/tree.c:2246 [inline] rcu_core+0x81f/0x1980 kernel/rcu/tree.c:2506 __do_softirq+0x1fb/0xadc kernel/softirq.c:571 The buggy address belongs to the object at ffff888020470000 which belongs to the cache kmalloc-4k of size 4096 The buggy address is located 1656 bytes inside of 4096-byte region [ffff888020470000, ffff888020471000) The buggy address belongs to the physical page: page:ffffea0000811c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x20470 head:ffffea0000811c00 order:3 compound_mapcount:0 subpages_mapcount:0 compound_pincount:0 anon flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffff888012443040 0000000000000000 dead000000000001 raw: 0000000000000000 0000000000040004 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 25528172690, free_ts 0 prep_new_page mm/page_alloc.c:2531 [inline] get_page_from_freelist+0x119c/0x2ce0 mm/page_alloc.c:4283 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5549 alloc_page_interleave+0x1e/0x200 mm/mempolicy.c:2119 alloc_pages+0x233/0x270 mm/mempolicy.c:2281 alloc_slab_page mm/slub.c:1851 [inline] allocate_slab+0x25f/0x350 mm/slub.c:1998 new_slab mm/slub.c:2051 [inline] ___slab_alloc+0xa91/0x1400 mm/slub.c:3193 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3292 __slab_alloc_node mm/slub.c:3345 [inline] slab_alloc_node mm/slub.c:3442 [inline] __kmem_cache_alloc_node+0x1a4/0x430 mm/slub.c:3491 kmalloc_trace+0x26/0x60 mm/slab_common.c:1062 kmalloc include/linux/slab.h:580 [inline] kzalloc include/linux/slab.h:720 [inline] kobject_uevent_env+0x234/0x1620 lib/kobject_uevent.c:524 device_add+0xb76/0x1e90 drivers/base/core.c:3460 __video_register_device+0x1da0/0x50c0 drivers/media/v4l2-core/v4l2-dev.c:1036 video_register_device include/media/v4l2-dev.h:383 [inline] vivid_create_devnodes drivers/media/test-drivers/vivid/vivid-core.c:1702 [inline] vivid_create_instance drivers/media/test-drivers/vivid/vivid-core.c:1988 [inline] vivid_probe.cold+0x7aa2/0x85d0 drivers/media/test-drivers/vivid/vivid-core.c:2041 platform_probe+0x100/0x1f0 drivers/base/platform.c:1400 call_driver_probe drivers/base/dd.c:560 [inline] really_probe+0x249/0xb90 drivers/base/dd.c:639 __driver_probe_device+0x1df/0x4d0 drivers/base/dd.c:778 page_owner free stack trace missing Memory state around the buggy address: ffff888020470500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888020470580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888020470600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888020470680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888020470700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ---------------- Code disassembly (best guess): 0: 03 74 c0 01 add 0x1(%rax,%rax,8),%esi 4: 10 05 03 74 b8 01 adc %al,0x1b87403(%rip) # 0x1b8740d a: 10 06 adc %al,(%rsi) c: 03 74 b4 01 add 0x1(%rsp,%rsi,4),%esi 10: 10 07 adc %al,(%rdi) 12: 03 74 b0 01 add 0x1(%rax,%rsi,4),%esi 16: 10 08 adc %cl,(%rax) 18: 03 74 d8 01 add 0x1(%rax,%rbx,8),%esi 1c: 00 00 add %al,(%rax) 1e: 00 00 add %al,(%rax) 20: 00 51 52 add %dl,0x52(%rcx) 23: 55 push %rbp 24: 89 e5 mov %esp,%ebp 26: 0f 34 sysenter 28: cd 80 int $0x80 * 2a: 5d pop %rbp <-- trapping instruction 2b: 5a pop %rdx 2c: 59 pop %rcx 2d: c3 retq 2e: 90 nop 2f: 90 nop 30: 90 nop 31: 90 nop 32: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi 39: 8d b4 26 00 00 00 00 lea 0x0(%rsi,%riz,1),%esi