================================================================== BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:96 [inline] BUG: KASAN: slab-use-after-free in atomic_dec_and_test include/linux/atomic/atomic-instrumented.h:1375 [inline] BUG: KASAN: slab-use-after-free in gfs2_qd_dealloc+0x7a/0xf0 fs/gfs2/quota.c:115 Write of size 4 at addr ffff88803e640a78 by task syz-executor.4/5886 CPU: 1 PID: 5886 Comm: syz-executor.4 Not tainted 6.6.0-rc7-syzkaller-00195-g2af9b20dbb39 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:364 [inline] print_report+0xc4/0x620 mm/kasan/report.c:475 kasan_report+0xda/0x110 mm/kasan/report.c:588 check_region_inline mm/kasan/generic.c:181 [inline] kasan_check_range+0xef/0x190 mm/kasan/generic.c:187 instrument_atomic_read_write include/linux/instrumented.h:96 [inline] atomic_dec_and_test include/linux/atomic/atomic-instrumented.h:1375 [inline] gfs2_qd_dealloc+0x7a/0xf0 fs/gfs2/quota.c:115 rcu_do_batch kernel/rcu/tree.c:2139 [inline] rcu_core+0x805/0x1bb0 kernel/rcu/tree.c:2403 __do_softirq+0x218/0x965 kernel/softirq.c:553 invoke_softirq kernel/softirq.c:427 [inline] __irq_exit_rcu kernel/softirq.c:632 [inline] irq_exit_rcu+0xb7/0x120 kernel/softirq.c:644 sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1074 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:645 RIP: 0010:stack_access_ok+0x9/0x270 arch/x86/kernel/unwind_orc.c:389 Code: bd 5b a3 00 48 8b 95 18 ff ff ff 48 8b 8d 28 ff ff ff 44 8b 85 30 ff ff ff e9 6f fe ff ff 0f 1f 00 41 57 41 56 41 55 41 54 55 <48> 89 f5 53 48 89 fb 4c 8d 63 08 48 83 ec 10 48 89 54 24 08 e8 4e RSP: 0018:ffffc9000322f380 EFLAGS: 00000293 RAX: ffffc9000322f8c8 RBX: ffffc9000322f430 RCX: 0000000000000000 RDX: 0000000000000008 RSI: ffffc9000322f8c8 RDI: ffffc9000322f430 RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000004 R10: 0000000000000002 R11: 0000000000000000 R12: ffffffff8f5dfebe R13: ffffc9000322f8d0 R14: ffffffff8f5dfec2 R15: 0000000000000002 deref_stack_reg arch/x86/kernel/unwind_orc.c:403 [inline] unwind_next_frame+0xd87/0x2390 arch/x86/kernel/unwind_orc.c:585 arch_stack_walk+0xfa/0x170 arch/x86/kernel/stacktrace.c:25 stack_trace_save+0x96/0xd0 kernel/stacktrace.c:122 save_stack+0x160/0x1f0 mm/page_owner.c:128 __reset_page_owner+0x5a/0x190 mm/page_owner.c:149 reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1136 [inline] free_unref_page_prepare+0x476/0xa40 mm/page_alloc.c:2312 free_unref_page_list+0xe6/0xb30 mm/page_alloc.c:2451 release_pages+0x32a/0x14e0 mm/swap.c:1042 __folio_batch_release+0x77/0xe0 mm/swap.c:1062 folio_batch_release include/linux/pagevec.h:83 [inline] shmem_undo_range+0x582/0x1040 mm/shmem.c:1022 shmem_truncate_range mm/shmem.c:1114 [inline] shmem_evict_inode+0x3a2/0xb70 mm/shmem.c:1243 evict+0x2ed/0x6b0 fs/inode.c:664 iput_final fs/inode.c:1775 [inline] iput.part.0+0x55e/0x7a0 fs/inode.c:1801 iput+0x5c/0x80 fs/inode.c:1791 dentry_unlink_inode+0x292/0x430 fs/dcache.c:401 __dentry_kill+0x3b8/0x640 fs/dcache.c:607 dentry_kill fs/dcache.c:733 [inline] dput+0x8b7/0xf80 fs/dcache.c:913 __fput+0x536/0xa70 fs/file_table.c:392 task_work_run+0x14d/0x240 kernel/task_work.c:180 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x215/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x60 kernel/entry/common.c:296 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f2dd847de17 Code: b0 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 0f 1f 44 00 00 31 f6 e9 09 00 00 00 66 0f 1f 84 00 00 00 00 00 b8 a6 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 c7 c2 b0 ff ff ff f7 d8 64 89 02 b8 RSP: 002b:00007ffc76554088 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007f2dd847de17 RDX: 0000000000000000 RSI: 000000000000000a RDI: 00007ffc76554140 RBP: 00007ffc76554140 R08: 0000000000000000 R09: 0000000000000000 R10: 00000000ffffffff R11: 0000000000000246 R12: 00007ffc76555200 R13: 00007f2dd84c73b9 R14: 00000000000e5e8c R15: 0000000000000002 Allocated by task 24528: kasan_save_stack+0x33/0x50 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+0xa2/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:599 [inline] kzalloc include/linux/slab.h:720 [inline] init_sbd fs/gfs2/ops_fstype.c:77 [inline] gfs2_fill_super+0x149/0x2e50 fs/gfs2/ops_fstype.c:1164 get_tree_bdev+0x3b5/0x650 fs/super.c:1577 gfs2_get_tree+0x4e/0x280 fs/gfs2/ops_fstype.c:1348 vfs_get_tree+0x8c/0x370 fs/super.c:1750 do_new_mount fs/namespace.c:3335 [inline] path_mount+0x1492/0x1ed0 fs/namespace.c:3662 do_mount fs/namespace.c:3675 [inline] __do_sys_mount fs/namespace.c:3884 [inline] __se_sys_mount fs/namespace.c:3861 [inline] __x64_sys_mount+0x293/0x310 fs/namespace.c:3861 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 5886: kasan_save_stack+0x33/0x50 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:522 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x15b/0x1b0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:164 [inline] slab_free_hook mm/slub.c:1800 [inline] slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826 slab_free mm/slub.c:3809 [inline] __kmem_cache_free+0xb8/0x2f0 mm/slub.c:3822 generic_shutdown_super+0x161/0x3c0 fs/super.c:693 kill_block_super+0x3b/0x70 fs/super.c:1646 gfs2_kill_sb+0x361/0x410 fs/gfs2/ops_fstype.c:1811 deactivate_locked_super+0x9a/0x170 fs/super.c:481 deactivate_super+0xde/0x100 fs/super.c:514 cleanup_mnt+0x222/0x3d0 fs/namespace.c:1254 task_work_run+0x14d/0x240 kernel/task_work.c:180 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x215/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x60 kernel/entry/common.c:296 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd Last potentially related work creation: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492 insert_work+0x38/0x230 kernel/workqueue.c:1647 __queue_work+0x5d0/0x1050 kernel/workqueue.c:1799 queue_work_on+0xed/0x110 kernel/workqueue.c:1834 queue_work include/linux/workqueue.h:554 [inline] schedule_work include/linux/workqueue.h:615 [inline] f2fs_handle_critical_error+0x841/0xa00 fs/f2fs/super.c:4130 f2fs_write_end_io+0xddf/0x11a0 fs/f2fs/data.c:366 bio_endio+0x593/0x6a0 block/bio.c:1603 submit_bio_noacct+0x3f2/0x1b10 block/blk-core.c:808 __submit_merged_bio+0x301/0x6a0 fs/f2fs/data.c:589 __f2fs_submit_merged_write fs/f2fs/data.c:682 [inline] __submit_merged_write_cond+0x319/0x3f0 fs/f2fs/data.c:704 f2fs_submit_merged_write_cond fs/f2fs/data.c:721 [inline] f2fs_write_cache_pages+0x1b46/0x2030 fs/f2fs/data.c:3280 __f2fs_write_data_pages fs/f2fs/data.c:3360 [inline] f2fs_write_data_pages+0x4d3/0xe20 fs/f2fs/data.c:3387 do_writepages+0x1b4/0x690 mm/page-writeback.c:2553 filemap_fdatawrite_wbc mm/filemap.c:390 [inline] filemap_fdatawrite_wbc+0x144/0x1b0 mm/filemap.c:380 __filemap_fdatawrite_range+0xba/0x100 mm/filemap.c:423 f2fs_sync_dirty_inodes+0x47d/0x940 fs/f2fs/checkpoint.c:1107 block_operations+0x297/0xf20 fs/f2fs/checkpoint.c:1240 f2fs_write_checkpoint+0x4e3/0x4b60 fs/f2fs/checkpoint.c:1648 kill_f2fs_super+0x347/0x3e0 fs/f2fs/super.c:4877 deactivate_locked_super+0x9a/0x170 fs/super.c:481 deactivate_super+0xde/0x100 fs/super.c:514 cleanup_mnt+0x222/0x3d0 fs/namespace.c:1254 task_work_run+0x14d/0x240 kernel/task_work.c:180 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x215/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x60 kernel/entry/common.c:296 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd Second to last potentially related work creation: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492 insert_work+0x38/0x230 kernel/workqueue.c:1647 __queue_work+0x5d0/0x1050 kernel/workqueue.c:1799 queue_work_on+0xed/0x110 kernel/workqueue.c:1834 queue_work include/linux/workqueue.h:554 [inline] schedule_work include/linux/workqueue.h:615 [inline] f2fs_handle_critical_error+0x841/0xa00 fs/f2fs/super.c:4130 f2fs_write_end_io+0xddf/0x11a0 fs/f2fs/data.c:366 bio_endio+0x593/0x6a0 block/bio.c:1603 submit_bio_noacct+0x3f2/0x1b10 block/blk-core.c:808 __submit_merged_bio+0x301/0x6a0 fs/f2fs/data.c:589 __f2fs_submit_merged_write fs/f2fs/data.c:682 [inline] __submit_merged_write_cond+0x319/0x3f0 fs/f2fs/data.c:704 f2fs_submit_merged_write_cond fs/f2fs/data.c:721 [inline] f2fs_write_cache_pages+0x1b46/0x2030 fs/f2fs/data.c:3280 __f2fs_write_data_pages fs/f2fs/data.c:3360 [inline] f2fs_write_data_pages+0x4d3/0xe20 fs/f2fs/data.c:3387 do_writepages+0x1b4/0x690 mm/page-writeback.c:2553 filemap_fdatawrite_wbc mm/filemap.c:390 [inline] filemap_fdatawrite_wbc+0x144/0x1b0 mm/filemap.c:380 __filemap_fdatawrite_range+0xba/0x100 mm/filemap.c:423 f2fs_sync_dirty_inodes+0x47d/0x940 fs/f2fs/checkpoint.c:1107 block_operations+0x297/0xf20 fs/f2fs/checkpoint.c:1240 f2fs_write_checkpoint+0x4e3/0x4b60 fs/f2fs/checkpoint.c:1648 kill_f2fs_super+0x347/0x3e0 fs/f2fs/super.c:4877 deactivate_locked_super+0x9a/0x170 fs/super.c:481 deactivate_super+0xde/0x100 fs/super.c:514 cleanup_mnt+0x222/0x3d0 fs/namespace.c:1254 task_work_run+0x14d/0x240 kernel/task_work.c:180 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x215/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x60 kernel/entry/common.c:296 do_syscall_64+0x44/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff88803e640000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 2680 bytes inside of freed 8192-byte region [ffff88803e640000, ffff88803e642000) The buggy address belongs to the physical page: page:ffffea0000f99000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x3e640 head:ffffea0000f99000 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0 anon flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000000840 ffff888012c42280 ffffea00021bce00 dead000000000005 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 5077, tgid 5077 (syz-executor.1), ts 203848984065, free_ts 0 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2cf/0x340 mm/page_alloc.c:1536 prep_new_page mm/page_alloc.c:1543 [inline] get_page_from_freelist+0xee0/0x2f20 mm/page_alloc.c:3170 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4426 alloc_pages+0x1a9/0x270 mm/mempolicy.c:2299 alloc_slab_page mm/slub.c:1870 [inline] allocate_slab+0x251/0x380 mm/slub.c:2017 new_slab mm/slub.c:2070 [inline] ___slab_alloc+0x8c7/0x1580 mm/slub.c:3223 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322 __slab_alloc_node mm/slub.c:3375 [inline] slab_alloc_node mm/slub.c:3468 [inline] __kmem_cache_alloc_node+0x131/0x340 mm/slub.c:3517 __do_kmalloc_node mm/slab_common.c:1025 [inline] __kmalloc_node+0x52/0x110 mm/slab_common.c:1033 kmalloc_node include/linux/slab.h:619 [inline] kvmalloc_node+0x6f/0x1a0 mm/util.c:607 kvmalloc include/linux/slab.h:737 [inline] kvmalloc_array include/linux/slab.h:755 [inline] __ptr_ring_init_queue_alloc include/linux/ptr_ring.h:471 [inline] ptr_ring_resize include/linux/ptr_ring.h:594 [inline] tun_attach.isra.0+0x8dd/0x1790 drivers/net/tun.c:790 tun_net_init+0x4d9/0x6d0 drivers/net/tun.c:1006 register_netdevice+0x564/0x1490 net/core/dev.c:10096 tun_set_iff drivers/net/tun.c:2850 [inline] __tun_chr_ioctl+0x30a7/0x4730 drivers/net/tun.c:3119 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:871 [inline] __se_sys_ioctl fs/ioctl.c:857 [inline] __x64_sys_ioctl+0x18f/0x210 fs/ioctl.c:857 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 page_owner free stack trace missing Memory state around the buggy address: ffff88803e640900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88803e640980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88803e640a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88803e640a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88803e640b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ---------------- Code disassembly (best guess): 0: bd 5b a3 00 48 mov $0x4800a35b,%ebp 5: 8b 95 18 ff ff ff mov -0xe8(%rbp),%edx b: 48 8b 8d 28 ff ff ff mov -0xd8(%rbp),%rcx 12: 44 8b 85 30 ff ff ff mov -0xd0(%rbp),%r8d 19: e9 6f fe ff ff jmp 0xfffffe8d 1e: 0f 1f 00 nopl (%rax) 21: 41 57 push %r15 23: 41 56 push %r14 25: 41 55 push %r13 27: 41 54 push %r12 29: 55 push %rbp * 2a: 48 89 f5 mov %rsi,%rbp <-- trapping instruction 2d: 53 push %rbx 2e: 48 89 fb mov %rdi,%rbx 31: 4c 8d 63 08 lea 0x8(%rbx),%r12 35: 48 83 ec 10 sub $0x10,%rsp 39: 48 89 54 24 08 mov %rdx,0x8(%rsp) 3e: e8 .byte 0xe8 3f: 4e rex.WRX