Hi, We would like to report the following bug which has been found by our modified version of syzkaller. ====================================================== description: KASAN: use-after-free Read in run_unpack affected file: fs/ntfs3/run.c kernel version: 5.19-rc6 kernel commit: 32346491ddf24599decca06190ebca03ff9de7f8 git tree: upstream kernel config: attached crash reproducer: none ====================================================== Crash log: ====================================================== BUG: KASAN: use-after-free in run_unpack+0x89a/0x940 fs/ntfs3/run.c:897 Read of size 1 at addr ffff88817deb7178 by task syz-executor.7/24027 CPU: 1 PID: 24027 Comm: syz-executor.7 Tainted: G OE 5.19.0-rc6-g2eae0556bb9d #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:313 [inline] print_report.cold+0xe5/0x659 mm/kasan/report.c:429 kasan_report+0x8a/0x1b0 mm/kasan/report.c:491 run_unpack+0x89a/0x940 fs/ntfs3/run.c:897 run_unpack_ex+0xb8/0x680 fs/ntfs3/run.c:1010 ntfs_read_mft fs/ntfs3/inode.c:368 [inline] ntfs_iget5+0xc11/0x3230 fs/ntfs3/inode.c:500 ntfs_fill_super+0x2815/0x4b30 fs/ntfs3/super.c:1122 get_tree_bdev+0x440/0x760 fs/super.c:1292 vfs_get_tree+0x89/0x2f0 fs/super.c:1497 do_new_mount fs/namespace.c:3040 [inline] path_mount+0x1228/0x1cb0 fs/namespace.c:3370 do_mount+0xf3/0x110 fs/namespace.c:3383 __do_sys_mount fs/namespace.c:3591 [inline] __se_sys_mount fs/namespace.c:3568 [inline] __x64_sys_mount+0x18f/0x230 fs/namespace.c:3568 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 RIP: 0033:0x7f157008fe8e Code: 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f157111b9f8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 0000000020000200 RCX: 00007f157008fe8e RDX: 0000000020000000 RSI: 0000000020000100 RDI: 00007f157111ba50 RBP: 00007f157111ba90 R08: 00007f157111ba90 R09: 0000000020000000 R10: 0000000000000000 R11: 0000000000000202 R12: 0000000020000000 R13: 0000000020000100 R14: 00007f157111ba50 R15: 000000002007aa80 Allocated by task 24027: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:39 kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:441 [inline] ____kasan_kmalloc mm/kasan/common.c:526 [inline] ____kasan_kmalloc mm/kasan/common.c:479 [inline] __kasan_kmalloc+0xb5/0xe0 mm/kasan/common.c:535 kasan_kmalloc include/linux/kasan.h:234 [inline] __kmalloc+0x1c9/0x4c0 mm/slub.c:4446 kmalloc include/linux/slab.h:605 [inline] mi_init+0x8c/0xf0 fs/ntfs3/record.c:105 ntfs_read_mft fs/ntfs3/inode.c:53 [inline] ntfs_iget5+0x3ca/0x3230 fs/ntfs3/inode.c:500 ntfs_fill_super+0x26a1/0x4b30 fs/ntfs3/super.c:1085 get_tree_bdev+0x440/0x760 fs/super.c:1292 vfs_get_tree+0x89/0x2f0 fs/super.c:1497 do_new_mount fs/namespace.c:3040 [inline] path_mount+0x1228/0x1cb0 fs/namespace.c:3370 do_mount+0xf3/0x110 fs/namespace.c:3383 __do_sys_mount fs/namespace.c:3591 [inline] __se_sys_mount fs/namespace.c:3568 [inline] __x64_sys_mount+0x18f/0x230 fs/namespace.c:3568 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Freed by task 24027: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:39 kasan_set_track+0x21/0x30 mm/kasan/common.c:46 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:378 ____kasan_slab_free mm/kasan/common.c:371 [inline] ____kasan_slab_free mm/kasan/common.c:329 [inline] __kasan_slab_free+0x12b/0x1a0 mm/kasan/common.c:379 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1754 [inline] slab_free_freelist_hook mm/slub.c:1780 [inline] slab_free mm/slub.c:3536 [inline] kfree+0xec/0x4b0 mm/slub.c:4584 mi_clear fs/ntfs3/ntfs_fs.h:1105 [inline] ni_clear+0x287/0x690 fs/ntfs3/frecord.c:132 evict+0x2ed/0x5a0 fs/inode.c:664 iput_final fs/inode.c:1744 [inline] iput.part.0+0x5d2/0x800 fs/inode.c:1770 iput+0x58/0x70 fs/inode.c:1760 ntfs_fill_super+0x27ca/0x4b30 fs/ntfs3/super.c:1112 get_tree_bdev+0x440/0x760 fs/super.c:1292 vfs_get_tree+0x89/0x2f0 fs/super.c:1497 do_new_mount fs/namespace.c:3040 [inline] path_mount+0x1228/0x1cb0 fs/namespace.c:3370 do_mount+0xf3/0x110 fs/namespace.c:3383 __do_sys_mount fs/namespace.c:3591 [inline] __se_sys_mount fs/namespace.c:3568 [inline] __x64_sys_mount+0x18f/0x230 fs/namespace.c:3568 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:39 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:356 call_rcu kernel/rcu/tree.c:3126 [inline] call_rcu+0x99/0x740 kernel/rcu/tree.c:3101 netlink_release+0xe42/0x1cb0 net/netlink/af_netlink.c:815 __sock_release+0xcd/0x280 net/socket.c:650 sock_close+0x18/0x20 net/socket.c:1365 __fput+0x277/0x9d0 fs/file_table.c:317 task_work_run+0xe0/0x1a0 kernel/task_work.c:177 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:169 [inline] exit_to_user_mode_prepare+0x253/0x260 kernel/entry/common.c:201 __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline] syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:294 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x46/0xb0 The buggy address belongs to the object at ffff88817deb7000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 376 bytes inside of 2048-byte region [ffff88817deb7000, ffff88817deb7800) The buggy address belongs to the physical page: page:ffffea0005f7ac00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x17deb0 head:ffffea0005f7ac00 order:3 compound_mapcount:0 compound_pincount:0 flags: 0x17ff00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff) raw: 017ff00000010200 ffffea0005a5d200 dead000000000002 ffff888100042000 raw: 0000000000000000 0000000080080008 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 6709, tgid 6709 (syz-executor.6), ts 103552445322, free_ts 103518093507 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook mm/page_alloc.c:2449 [inline] prep_new_page+0x297/0x330 mm/page_alloc.c:2456 get_page_from_freelist+0x2142/0x3c80 mm/page_alloc.c:4198 __alloc_pages+0x321/0x710 mm/page_alloc.c:5426 alloc_pages+0x119/0x250 mm/mempolicy.c:2272 alloc_slab_page mm/slub.c:1824 [inline] allocate_slab mm/slub.c:1969 [inline] new_slab+0x2a9/0x3f0 mm/slub.c:2029 ___slab_alloc+0xd5a/0x1140 mm/slub.c:3031 __slab_alloc.isra.0+0x4d/0xa0 mm/slub.c:3118 slab_alloc_node mm/slub.c:3209 [inline] slab_alloc mm/slub.c:3251 [inline] __kmalloc+0x3a9/0x4c0 mm/slub.c:4442 kmalloc include/linux/slab.h:605 [inline] kzalloc include/linux/slab.h:733 [inline] ops_init+0xfb/0x420 net/core/net_namespace.c:124 setup_net+0x5d7/0xc60 net/core/net_namespace.c:325 copy_net_ns+0x2d9/0x660 net/core/net_namespace.c:471 create_new_namespaces.isra.0+0x3cb/0xae0 kernel/nsproxy.c:110 unshare_nsproxy_namespaces+0xc8/0x1f0 kernel/nsproxy.c:226 ksys_unshare+0x450/0x920 kernel/fork.c:3174 __do_sys_unshare kernel/fork.c:3245 [inline] __se_sys_unshare kernel/fork.c:3243 [inline] __x64_sys_unshare+0x2d/0x40 kernel/fork.c:3243 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1371 [inline] free_pcp_prepare+0x51f/0xd00 mm/page_alloc.c:1421 free_unref_page_prepare mm/page_alloc.c:3343 [inline] free_unref_page+0x19/0x5b0 mm/page_alloc.c:3438 do_slab_free mm/slub.c:3524 [inline] ___cache_free+0x12c/0x140 mm/slub.c:3543 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x13d/0x180 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:451 kasan_slab_alloc include/linux/kasan.h:224 [inline] slab_post_alloc_hook+0x4d/0x4f0 mm/slab.h:750 slab_alloc_node mm/slub.c:3243 [inline] slab_alloc mm/slub.c:3251 [inline] __kmem_cache_alloc_lru mm/slub.c:3258 [inline] kmem_cache_alloc+0x1be/0x460 mm/slub.c:3268 kmem_cache_zalloc include/linux/slab.h:723 [inline] __kernfs_new_node+0xd4/0x8b0 fs/kernfs/dir.c:593 kernfs_new_node+0x93/0x120 fs/kernfs/dir.c:655 __kernfs_create_file+0x51/0x350 fs/kernfs/file.c:987 sysfs_add_file_mode_ns+0x20f/0x3f0 fs/sysfs/file.c:294 create_files fs/sysfs/group.c:64 [inline] internal_create_group+0x314/0xba0 fs/sysfs/group.c:148 internal_create_groups.part.0+0x90/0x140 fs/sysfs/group.c:188 internal_create_groups fs/sysfs/group.c:184 [inline] sysfs_create_groups+0x25/0x50 fs/sysfs/group.c:214 device_add_groups drivers/base/core.c:2483 [inline] device_add_attrs drivers/base/core.c:2642 [inline] device_add+0x1545/0x1da0 drivers/base/core.c:3379 Memory state around the buggy address: ffff88817deb7000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88817deb7080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88817deb7100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88817deb7180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88817deb7200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== -- Thanks & Regards, Dipanjan