syzbot


KASAN: use-after-free Read in __kernfs_remove

Status: closed as invalid on 2020/03/24 18:50
Fix commit: f2fs/fscrypt: updates on 4.18-rc1
First crash: 2194d, last: 2194d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in __kernfs_remove C done 3985 562d 606d 22/26 fixed on 2023/02/24 13:50

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in kernfs_leftmost_descendant fs/kernfs/dir.c:1099 [inline]
BUG: KASAN: use-after-free in __kernfs_remove+0x742/0x830 fs/kernfs/dir.c:1203
Read of size 2 at addr ffff8801d42908f8 by task syzkaller241258/4394

CPU: 0 PID: 4394 Comm: syzkaller241258 Not tainted 4.9.95-g13cc540 #2
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
 ffff8801cf2e7628 ffffffff81eb0ba9 ffffea000750a400 ffff8801d42908f8
 0000000000000000 ffff8801d42908f8 ffff8801d4290870 ffff8801cf2e7660
 ffffffff815653cb ffff8801d42908f8 0000000000000002 0000000000000000
Call Trace:
 [<ffffffff81eb0ba9>] __dump_stack lib/dump_stack.c:15 [inline]
 [<ffffffff81eb0ba9>] dump_stack+0xc1/0x128 lib/dump_stack.c:51
 [<ffffffff815653cb>] print_address_description+0x6c/0x234 mm/kasan/report.c:256
 [<ffffffff815657d5>] kasan_report_error mm/kasan/report.c:355 [inline]
 [<ffffffff815657d5>] kasan_report.cold.6+0x242/0x2fe mm/kasan/report.c:412
 [<ffffffff81539414>] __asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:431
 [<ffffffff817036e2>] kernfs_leftmost_descendant fs/kernfs/dir.c:1099 [inline]
 [<ffffffff817036e2>] __kernfs_remove+0x742/0x830 fs/kernfs/dir.c:1203
 [<ffffffff81705c94>] kernfs_remove_by_name_ns+0x54/0xb0 fs/kernfs/dir.c:1414
 [<ffffffff8170c3dd>] kernfs_remove_by_name include/linux/kernfs.h:494 [inline]
 [<ffffffff8170c3dd>] sysfs_remove_link+0x4d/0x90 fs/sysfs/symlink.c:151
 [<ffffffff81536766>] sysfs_slab_add+0x36/0x1d0 mm/slub.c:5583
 [<ffffffff815376a1>] __kmem_cache_create+0x1d1/0x3d0 mm/slub.c:4212
 [<ffffffff814a448c>] create_cache mm/slab_common.c:350 [inline]
 [<ffffffff814a448c>] kmem_cache_create+0x1bc/0x2c0 mm/slab_common.c:428
 [<ffffffff81c9771b>] f2fs_kmem_cache_create fs/f2fs/f2fs.h:2012 [inline]
 [<ffffffff81c9771b>] recover_fsync_data+0x15b/0x1b70 fs/f2fs/recovery.c:643
 [<ffffffff81bfee86>] f2fs_fill_super+0x22b6/0x5d00 fs/f2fs/super.c:2905
 [<ffffffff81579d17>] mount_bdev+0x2c7/0x390 fs/super.c:1100
 [<ffffffff81beaa94>] f2fs_mount+0x34/0x40 fs/f2fs/super.c:3024
 [<ffffffff8157ba9c>] mount_fs+0x28c/0x370 fs/super.c:1206
 [<ffffffff815db041>] vfs_kern_mount.part.29+0xd1/0x3d0 fs/namespace.c:991
 [<ffffffff815e2969>] vfs_kern_mount fs/namespace.c:973 [inline]
 [<ffffffff815e2969>] do_new_mount fs/namespace.c:2512 [inline]
 [<ffffffff815e2969>] do_mount+0x3c9/0x2740 fs/namespace.c:2834
 [<ffffffff815e56be>] SYSC_mount fs/namespace.c:3050 [inline]
 [<ffffffff815e56be>] SyS_mount+0xfe/0x110 fs/namespace.c:3027
 [<ffffffff81006316>] do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
 [<ffffffff839f2313>] entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Allocated by task 4402:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack+0x43/0xd0 mm/kasan/kasan.c:505
 set_track mm/kasan/kasan.c:517 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:609
 kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:547
 slab_post_alloc_hook mm/slab.h:417 [inline]
 slab_alloc_node mm/slub.c:2715 [inline]
 slab_alloc mm/slub.c:2723 [inline]
 kmem_cache_alloc+0xbe/0x290 mm/slub.c:2728
 kmem_cache_zalloc include/linux/slab.h:626 [inline]
 __kernfs_new_node+0x6c/0x2b0 fs/kernfs/dir.c:619
 kernfs_new_node+0x80/0xe0 fs/kernfs/dir.c:651
 kernfs_create_dir_ns+0x3d/0x130 fs/kernfs/dir.c:923
 sysfs_create_dir_ns+0xbe/0x1c0 fs/sysfs/dir.c:55
 create_dir lib/kobject.c:71 [inline]
 kobject_add_internal+0x1df/0x8a0 lib/kobject.c:229
 kobject_add_varg lib/kobject.c:366 [inline]
 kobject_init_and_add+0xe7/0x140 lib/kobject.c:438
 sysfs_slab_add+0x60/0x1d0 mm/slub.c:5594
 __kmem_cache_create+0x1d1/0x3d0 mm/slub.c:4212
 create_cache mm/slab_common.c:350 [inline]
 kmem_cache_create+0x1bc/0x2c0 mm/slab_common.c:428
 f2fs_kmem_cache_create fs/f2fs/f2fs.h:2012 [inline]
 recover_fsync_data+0x15b/0x1b70 fs/f2fs/recovery.c:643
 f2fs_fill_super+0x22b6/0x5d00 fs/f2fs/super.c:2905
 mount_bdev+0x2c7/0x390 fs/super.c:1100
 f2fs_mount+0x34/0x40 fs/f2fs/super.c:3024
 mount_fs+0x28c/0x370 fs/super.c:1206
 vfs_kern_mount.part.29+0xd1/0x3d0 fs/namespace.c:991
 vfs_kern_mount fs/namespace.c:973 [inline]
 do_new_mount fs/namespace.c:2512 [inline]
 do_mount+0x3c9/0x2740 fs/namespace.c:2834
 SYSC_mount fs/namespace.c:3050 [inline]
 SyS_mount+0xfe/0x110 fs/namespace.c:3027
 do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
 entry_SYSCALL_64_after_swapgs+0x5d/0xdb

Freed by task 4394:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
 save_stack+0x43/0xd0 mm/kasan/kasan.c:505
 set_track mm/kasan/kasan.c:517 [inline]
 kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:582
 slab_free_hook mm/slub.c:1355 [inline]
 slab_free_freelist_hook mm/slub.c:1377 [inline]
 slab_free mm/slub.c:2958 [inline]
 kmem_cache_free+0xbe/0x310 mm/slub.c:2980
 kernfs_put+0x2f6/0x540 fs/kernfs/dir.c:527
 __kernfs_remove+0x365/0x830 fs/kernfs/dir.c:1242
 kernfs_remove_by_name_ns+0x54/0xb0 fs/kernfs/dir.c:1414
 kernfs_remove_by_name include/linux/kernfs.h:494 [inline]
 sysfs_remove_link+0x4d/0x90 fs/sysfs/symlink.c:151
 sysfs_slab_add+0x36/0x1d0 mm/slub.c:5583
 __kmem_cache_create+0x1d1/0x3d0 mm/slub.c:4212
 create_cache mm/slab_common.c:350 [inline]
 kmem_cache_create+0x1bc/0x2c0 mm/slab_common.c:428
 f2fs_kmem_cache_create fs/f2fs/f2fs.h:2012 [inline]
 recover_fsync_data+0x15b/0x1b70 fs/f2fs/recovery.c:643
 f2fs_fill_super+0x22b6/0x5d00 fs/f2fs/super.c:2905
 mount_bdev+0x2c7/0x390 fs/super.c:1100
 f2fs_mount+0x34/0x40 fs/f2fs/super.c:3024
 mount_fs+0x28c/0x370 fs/super.c:1206
 vfs_kern_mount.part.29+0xd1/0x3d0 fs/namespace.c:991
 vfs_kern_mount fs/namespace.c:973 [inline]
 do_new_mount fs/namespace.c:2512 [inline]
 do_mount+0x3c9/0x2740 fs/namespace.c:2834
 SYSC_mount fs/namespace.c:3050 [inline]
 SyS_mount+0xfe/0x110 fs/namespace.c:3027
 do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
 entry_SYSCALL_64_after_swapgs+0x5d/0xdb

The buggy address belongs to the object at ffff8801d4290870
 which belongs to the cache kernfs_node_cache of size 152
The buggy address is located 136 bytes inside of
 152-byte region [ffff8801d4290870, ffff8801d4290908)
The buggy address belongs to the page:
page:ffffea000750a400 count:1 mapcount:0 mapping:          (null) index:0x0
flags: 0x8000000000000080(slab)
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8801d4290780: fc fc fc 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8801d4290800: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fb fb
>ffff8801d4290880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                ^
 ffff8801d4290900: fb fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb
 ffff8801d4290980: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/04/21 01:19 https://android.googlesource.com/kernel/common android-4.9 13cc54013b24 ca03d688 .config console log report syz C ci-android-49-kasan-gce-root
* Struck through repros no longer work on HEAD.