================================================================== 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 ffff888065f94a78 by task syz-executor.2/5170 CPU: 3 PID: 5170 Comm: syz-executor.2 Not tainted 6.6.0-rc7-syzkaller-00195-g2af9b20dbb39 #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 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:rcu_dynticks_curr_cpu_in_eqs include/linux/context_tracking.h:122 [inline] RIP: 0010:rcu_is_watching+0x39/0xb0 kernel/rcu/tree.c:699 Code: 74 cd 08 48 c7 c3 e8 6d 03 00 83 f8 07 89 c5 77 7a 48 8d 3c ed 40 0a 5c 8c 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 75 54 48 03 1c ed 40 0a 5c 8c 48 b8 00 00 00 00 00 fc RSP: 0018:ffffc900038b74d0 EFLAGS: 00000a06 RAX: dffffc0000000000 RBX: 0000000000036de8 RCX: ffffffff8167a347 RDX: 1ffffffff18b814b RSI: ffffffff8ae91320 RDI: ffffffff8c5c0a58 RBP: 0000000000000003 R08: 0000000000000000 R09: fffffbfff1d96cfa R10: ffffffff8ecb67d7 R11: dffffc0000000000 R12: 0000000000000000 R13: 0000000000000000 R14: ffffffff8cba7a60 R15: 0000000000000000 trace_lock_acquire include/trace/events/lock.h:24 [inline] lock_acquire+0x464/0x510 kernel/locking/lockdep.c:5724 rcu_lock_acquire include/linux/rcupdate.h:303 [inline] rcu_read_lock include/linux/rcupdate.h:749 [inline] page_ext_get+0x3a/0x310 mm/page_ext.c:508 page_table_check_set mm/page_table_check.c:109 [inline] page_table_check_set+0x1b5/0x9a0 mm/page_table_check.c:97 __page_table_check_ptes_set+0x1cc/0x220 mm/page_table_check.c:196 page_table_check_ptes_set include/linux/page_table_check.h:74 [inline] set_ptes include/linux/pgtable.h:234 [inline] copy_present_pte mm/memory.c:978 [inline] copy_pte_range mm/memory.c:1082 [inline] copy_pmd_range mm/memory.c:1167 [inline] copy_pud_range mm/memory.c:1204 [inline] copy_p4d_range mm/memory.c:1228 [inline] copy_page_range+0x1512/0x3d50 mm/memory.c:1326 dup_mmap+0x13f3/0x1d80 kernel/fork.c:758 dup_mm kernel/fork.c:1686 [inline] copy_mm kernel/fork.c:1735 [inline] copy_process+0x6bff/0x73f0 kernel/fork.c:2501 kernel_clone+0xfd/0x920 kernel/fork.c:2909 __do_sys_clone+0xba/0x100 kernel/fork.c:3052 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 RIP: 0033:0x7f0b3a279b13 Code: 1f 84 00 00 00 00 00 64 48 8b 04 25 10 00 00 00 45 31 c0 31 d2 31 f6 bf 11 00 20 01 4c 8d 90 d0 02 00 00 b8 38 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 89 c2 85 c0 75 2c 64 48 8b 04 25 10 00 00 RSP: 002b:00007ffd43c5f3b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000038 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f0b3a279b13 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000001200011 RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000 R10: 0000555555f39750 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000001 R15: 0000000000000001 Allocated by task 12072: 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+0xa3/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 5174: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x138/0x190 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:164 [inline] __cache_free mm/slab.c:3370 [inline] __do_kmem_cache_free mm/slab.c:3557 [inline] __kmem_cache_free+0xcc/0x2d0 mm/slab.c:3564 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+0x78/0x80 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 kref_put include/linux/kref.h:65 [inline] sg_release+0x244/0x320 drivers/scsi/sg.c:393 __fput+0x3f7/0xa70 fs/file_table.c:384 __fput_sync+0x47/0x50 fs/file_table.c:465 __do_sys_close fs/open.c:1572 [inline] __se_sys_close fs/open.c:1557 [inline] __x64_sys_close+0x87/0xf0 fs/open.c:1557 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 Second to last potentially related work creation: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 __kasan_record_aux_stack+0x78/0x80 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 kref_put include/linux/kref.h:65 [inline] sg_release+0x244/0x320 drivers/scsi/sg.c:393 __fput+0x3f7/0xa70 fs/file_table.c:384 __fput_sync+0x47/0x50 fs/file_table.c:465 __do_sys_close fs/open.c:1572 [inline] __se_sys_close fs/open.c:1557 [inline] __x64_sys_close+0x87/0xf0 fs/open.c:1557 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 The buggy address belongs to the object at ffff888065f94000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 2680 bytes inside of freed 8192-byte region [ffff888065f94000, ffff888065f96000) The buggy address belongs to the physical page: page:ffffea000197e500 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x65f94 head:ffffea000197e500 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0 flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff) page_type: 0x1() raw: 00fff00000000840 ffff888012c40a00 ffffea000197be10 ffffea0001944d10 raw: 0000000000000000 ffff888065f94000 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 0x342020(__GFP_HIGH|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 10794, tgid 10793 (syz-executor.3), ts 301884193776, free_ts 300693829845 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_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1356 [inline] cache_grow_begin+0x99/0x3a0 mm/slab.c:2550 cache_alloc_refill+0x294/0x3a0 mm/slab.c:2923 ____cache_alloc mm/slab.c:2999 [inline] ____cache_alloc mm/slab.c:2982 [inline] __do_cache_alloc mm/slab.c:3182 [inline] slab_alloc_node mm/slab.c:3230 [inline] __kmem_cache_alloc_node+0x3c5/0x470 mm/slab.c:3521 kmalloc_trace+0x25/0xe0 mm/slab_common.c:1117 kmalloc include/linux/slab.h:599 [inline] kzalloc include/linux/slab.h:720 [inline] sg_add_sfp drivers/scsi/sg.c:2165 [inline] sg_open+0x930/0x1940 drivers/scsi/sg.c:350 chrdev_open+0x277/0x700 fs/char_dev.c:414 do_dentry_open+0x88b/0x1730 fs/open.c:929 do_open fs/namei.c:3640 [inline] path_openat+0x19af/0x29c0 fs/namei.c:3797 do_filp_open+0x1de/0x430 fs/namei.c:3824 do_sys_openat2+0x176/0x1e0 fs/open.c:1422 do_sys_open fs/open.c:1437 [inline] __do_sys_openat fs/open.c:1453 [inline] __se_sys_openat fs/open.c:1448 [inline] __x64_sys_openat+0x175/0x210 fs/open.c:1448 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 page last free stack trace: 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+0x33/0x3b0 mm/page_alloc.c:2405 slab_destroy mm/slab.c:1608 [inline] drain_freelist.isra.0+0xdc/0x130 mm/slab.c:2197 cache_reap+0x1da/0x330 mm/slab.c:3851 process_one_work+0x884/0x15c0 kernel/workqueue.c:2630 process_scheduled_works kernel/workqueue.c:2703 [inline] worker_thread+0x8b9/0x1290 kernel/workqueue.c:2784 kthread+0x33c/0x440 kernel/kthread.c:388 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304 Memory state around the buggy address: ffff888065f94900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888065f94980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888065f94a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888065f94a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888065f94b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ---------------- Code disassembly (best guess), 1 bytes skipped: 0: cd 08 int $0x8 2: 48 c7 c3 e8 6d 03 00 mov $0x36de8,%rbx 9: 83 f8 07 cmp $0x7,%eax c: 89 c5 mov %eax,%ebp e: 77 7a ja 0x8a 10: 48 8d 3c ed 40 0a 5c lea -0x73a3f5c0(,%rbp,8),%rdi 17: 8c 18: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax 1f: fc ff df 22: 48 89 fa mov %rdi,%rdx 25: 48 c1 ea 03 shr $0x3,%rdx * 29: 80 3c 02 00 cmpb $0x0,(%rdx,%rax,1) <-- trapping instruction 2d: 75 54 jne 0x83 2f: 48 03 1c ed 40 0a 5c add -0x73a3f5c0(,%rbp,8),%rbx 36: 8c 37: 48 rex.W 38: b8 00 00 00 00 mov $0x0,%eax 3d: 00 fc add %bh,%ah