syzbot


KASAN: use-after-free Read in nilfs_mdt_destroy

Status: fixed on 2023/02/24 13:50
Subsystems: nilfs
[Documentation on labels]
Reported-by: syzbot+3974efaf68c77533b42d@syzkaller.appspotmail.com
Fix commit: 2e488f13755f fs: fix UAF/GPF bug in nilfs_mdt_destroy
First crash: 585d, last: 565d
Cause bisection: failed (error log, bisect log)
  
Duplicate bugs (1)
duplicates (1):
Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
WARNING: ODEBUG bug in nilfs_mdt_destroy nilfs 4 551d 559d 0/26 closed as dup on 2022/10/13 09:28
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] KASAN: use-after-free Read in nilfs_mdt_destroy 2 (3) 2022/09/24 08:17
Last patch testing requests (1)
Created Duration User Patch Repo Result
2022/09/23 09:54 17m konishi.ryusuke@gmail.com git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git 2e488f13755ffbb60f307e991b27024716a33b29 error OK

Sample crash report:
loop0: detected capacity change from 0 to 2048
==================================================================
BUG: KASAN: use-after-free in nilfs_mdt_destroy+0x4f/0x70 fs/nilfs2/mdt.c:497
Read of size 8 at addr ffff88807b3dfc98 by task syz-executor328/3724

CPU: 0 PID: 3724 Comm: syz-executor328 Not tainted 6.0.0-rc7-syzkaller-00250-ga962b54e162c #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/22/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
 print_address_description+0x65/0x4b0 mm/kasan/report.c:317
 print_report+0x108/0x1f0 mm/kasan/report.c:433
 kasan_report+0xc3/0xf0 mm/kasan/report.c:495
 nilfs_mdt_destroy+0x4f/0x70 fs/nilfs2/mdt.c:497
 nilfs_free_inode+0x44/0x70 fs/nilfs2/super.c:168
 i_callback fs/inode.c:249 [inline]
 alloc_inode fs/inode.c:274 [inline]
 new_inode_pseudo+0x19a/0x1d0 fs/inode.c:1019
 new_inode+0x25/0x1d0 fs/inode.c:1047
 nilfs_new_inode+0xca/0x8a0 fs/nilfs2/inode.c:334
 nilfs_create+0xdc/0x2d0 fs/nilfs2/namei.c:85
 vfs_create+0x302/0x490 fs/namei.c:3115
 do_mknodat+0x412/0x6b0 fs/namei.c:3942
 __do_sys_mknod fs/namei.c:3975 [inline]
 __se_sys_mknod fs/namei.c:3973 [inline]
 __x64_sys_mknod+0x8a/0xa0 fs/namei.c:3973
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f293acceb49
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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd5c6bd748 EFLAGS: 00000246 ORIG_RAX: 0000000000000085
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f293acceb49
RDX: 0000000000000701 RSI: 0000000000000000 RDI: 00000000200000c0
RBP: 00007ffd5c6bd770 R08: 0000000000000001 R09: 00007ffd5c6bd780
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000003
R13: 00007ffd5c6bd7b0 R14: 00007ffd5c6bd790 R15: 0000000000000036
 </TASK>

Allocated by task 3615:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:437 [inline]
 ____kasan_kmalloc+0xcd/0x100 mm/kasan/common.c:516
 kasan_kmalloc include/linux/kasan.h:234 [inline]
 __kmalloc+0x226/0x370 mm/slub.c:4429
 kmalloc include/linux/slab.h:605 [inline]
 kzalloc include/linux/slab.h:733 [inline]
 nilfs_mdt_init+0x42/0x1c0 fs/nilfs2/mdt.c:451
 nilfs_dat_read+0x136/0x300 fs/nilfs2/dat.c:489
 nilfs_load_super_root fs/nilfs2/the_nilfs.c:120 [inline]
 load_nilfs+0x4c8/0xfc0 fs/nilfs2/the_nilfs.c:269
 nilfs_fill_super+0x27e/0x5d0 fs/nilfs2/super.c:1059
 nilfs_mount+0x613/0x9b0 fs/nilfs2/super.c:1317
 legacy_get_tree+0xea/0x180 fs/fs_context.c:610
 vfs_get_tree+0x88/0x270 fs/super.c:1530
 do_new_mount+0x289/0xad0 fs/namespace.c:3040
 do_mount fs/namespace.c:3383 [inline]
 __do_sys_mount fs/namespace.c:3591 [inline]
 __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3568
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88807b3dfc00
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 152 bytes inside of
 512-byte region [ffff88807b3dfc00, ffff88807b3dfe00)

The buggy address belongs to the physical page:
page:ffffea0001ecf700 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807b3dfc00 pfn:0x7b3dc
head:ffffea0001ecf700 order:2 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0001f5a508 ffffea00009d9a08 ffff888012041c80
raw: ffff88807b3dfc00 0000000000100004 00000001ffffffff 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 2974, tgid 2974 (udevadm), ts 13450139530, free_ts 11071765552
 prep_new_page mm/page_alloc.c:2532 [inline]
 get_page_from_freelist+0x742/0x7c0 mm/page_alloc.c:4283
 __alloc_pages+0x259/0x560 mm/page_alloc.c:5549
 alloc_slab_page+0x70/0xf0 mm/slub.c:1829
 allocate_slab+0x5e/0x520 mm/slub.c:1974
 new_slab mm/slub.c:2034 [inline]
 ___slab_alloc+0x3ee/0xc40 mm/slub.c:3036
 __slab_alloc mm/slub.c:3123 [inline]
 slab_alloc_node mm/slub.c:3214 [inline]
 slab_alloc mm/slub.c:3256 [inline]
 kmem_cache_alloc_trace+0x25f/0x310 mm/slub.c:3287
 kmalloc include/linux/slab.h:600 [inline]
 kzalloc include/linux/slab.h:733 [inline]
 kernfs_fop_open+0x3c4/0xc70 fs/kernfs/file.c:680
 do_dentry_open+0x777/0x1180 fs/open.c:880
 do_open fs/namei.c:3557 [inline]
 path_openat+0x25fc/0x2df0 fs/namei.c:3691
 do_filp_open+0x264/0x4f0 fs/namei.c:3718
 do_sys_openat2+0x124/0x4e0 fs/open.c:1313
 do_sys_open fs/open.c:1329 [inline]
 __do_sys_openat fs/open.c:1345 [inline]
 __se_sys_openat fs/open.c:1340 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1340
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/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:1449 [inline]
 free_pcp_prepare+0x812/0x900 mm/page_alloc.c:1499
 free_unref_page_prepare mm/page_alloc.c:3380 [inline]
 free_unref_page+0x7d/0x5f0 mm/page_alloc.c:3476
 free_contig_range+0xa3/0x160 mm/page_alloc.c:9453
 destroy_args+0xfe/0x91d mm/debug_vm_pgtable.c:1031
 debug_vm_pgtable+0x43e/0x497 mm/debug_vm_pgtable.c:1354
 do_one_initcall+0x1b9/0x3e0 init/main.c:1296
 do_initcall_level+0x168/0x218 init/main.c:1369
 do_initcalls+0x4b/0x8c init/main.c:1385
 kernel_init_freeable+0x3f1/0x57b init/main.c:1623
 kernel_init+0x19/0x2b0 init/main.c:1512
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

Memory state around the buggy address:
 ffff88807b3dfb80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88807b3dfc00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807b3dfc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff88807b3dfd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807b3dfd80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (20):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/10/03 12:05 upstream a962b54e162c feb56351 .config strace log report syz C [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/09/28 10:43 upstream 46452d3786a8 75c78242 .config strace log report syz C ci-upstream-kasan-gce-root KASAN: use-after-free Read in nilfs_mdt_destroy
2022/09/25 08:47 upstream 3db61221f4e8 0042f2b4 .config strace log report syz C ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/09/24 23:00 upstream 3db61221f4e8 0042f2b4 .config strace log report syz C ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/09/24 19:34 upstream a63f2e7cb110 0042f2b4 .config strace log report syz C ci-upstream-kasan-gce-root KASAN: use-after-free Read in nilfs_mdt_destroy
2022/09/24 00:42 upstream 1707c39ae309 0042f2b4 .config strace log report syz C ci-upstream-kasan-gce-root KASAN: use-after-free Read in nilfs_mdt_destroy
2022/09/23 19:04 upstream bf682942cd26 0042f2b4 .config strace log report syz C [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/09/17 15:55 upstream a335366bad13 dd9a85ff .config strace log report syz C ci-upstream-kasan-gce-root KASAN: use-after-free Read in nilfs_mdt_destroy
2022/10/07 03:08 upstream 833477fce7a1 80b58a42 .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/10/07 00:28 upstream 833477fce7a1 80b58a42 .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/10/06 04:37 upstream 2bca25eaeba6 2c6543ad .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/10/06 04:11 upstream 2bca25eaeba6 2c6543ad .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/10/05 18:06 upstream 0326074ff465 267e3bb1 .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/10/05 12:54 upstream 0326074ff465 267e3bb1 .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/10/03 19:03 upstream 4fe89d07dcc2 feb56351 .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/10/03 10:49 upstream a962b54e162c feb56351 .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/10/03 01:08 upstream a962b54e162c feb56351 .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/10/01 16:12 upstream ffb4d94b4314 feb56351 .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/09/30 22:19 upstream 70575e77839f feb56351 .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
2022/09/29 03:47 upstream 49c13ed0316d a41a2080 .config console log report info [disk image] [vmlinux] ci2-upstream-fs KASAN: use-after-free Read in nilfs_mdt_destroy
* Struck through repros no longer work on HEAD.