syzbot


KASAN: use-after-free Read in mas_next_nentry
Status: upstream: reported C repro on 2022/04/27 12:43
Reported-by: syzbot+7170d66493145b71afd4@syzkaller.appspotmail.com
First crash: 30d, last: 8d01h

Cause bisection: failed (bisect log)
Patch testing requests:
Created Duration User Patch Repo Result
2022/04/28 03:22 8m wanjiabing@vivo.com patch linux-next report log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in mas_safe_min lib/maple_tree.c:715 [inline]
BUG: KASAN: use-after-free in mas_next_nentry+0x997/0xaa0 lib/maple_tree.c:4542
Read of size 8 at addr ffff88801b1c5a20 by task syz-executor247/3614

CPU: 1 PID: 3614 Comm: syz-executor247 Not tainted 5.18.0-rc6-next-20220513-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313
 print_report mm/kasan/report.c:429 [inline]
 kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
 mas_safe_min lib/maple_tree.c:715 [inline]
 mas_next_nentry+0x997/0xaa0 lib/maple_tree.c:4542
 mas_next_entry lib/maple_tree.c:4632 [inline]
 mas_next+0x1eb/0xc40 lib/maple_tree.c:5720
 userfaultfd_unregister fs/userfaultfd.c:1652 [inline]
 userfaultfd_ioctl+0x344c/0x41f0 fs/userfaultfd.c:2002
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl fs/ioctl.c:856 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
 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:0x7fa6e43d0e99
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fa6e4361208 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fa6e4459418 RCX: 00007fa6e43d0e99
RDX: 00000000200000c0 RSI: 000000008010aa01 RDI: 0000000000000004
RBP: 00007fa6e4459410 R08: 00007fa6e4361700 R09: 00007fa6e4459418
R10: 00007fa6e4361700 R11: 0000000000000246 R12: 00007fa6e445941c
R13: 00007ffe883f82cf R14: 00007fa6e4361300 R15: 0000000000022000
 </TASK>

Allocated by task 3611:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 __kasan_slab_alloc+0x90/0xc0 mm/kasan/common.c:469
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:750 [inline]
 kmem_cache_alloc_bulk+0x39f/0x720 mm/slub.c:3728
 mt_alloc_bulk lib/maple_tree.c:151 [inline]
 mas_alloc_nodes+0x1df/0x6b0 lib/maple_tree.c:1244
 mas_node_count+0x101/0x130 lib/maple_tree.c:1303
 mas_split lib/maple_tree.c:3406 [inline]
 mas_commit_b_node lib/maple_tree.c:3508 [inline]
 mas_wr_modify+0x24a1/0x5a50 lib/maple_tree.c:4247
 mas_wr_store_entry.isra.0+0x66e/0x1030 lib/maple_tree.c:4285
 mas_store+0xac/0xf0 lib/maple_tree.c:5519
 dup_mmap+0x88a/0x1090 kernel/fork.c:687
 dup_mm+0x91/0x370 kernel/fork.c:1520
 copy_mm kernel/fork.c:1569 [inline]
 copy_process+0x3bad/0x7010 kernel/fork.c:2233
 kernel_clone+0xe7/0xab0 kernel/fork.c:2648
 __do_sys_clone+0xba/0x100 kernel/fork.c:2782
 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 3614:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track+0x21/0x30 mm/kasan/common.c:45
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328
 kasan_slab_free include/linux/kasan.h:200 [inline]
 slab_free_hook mm/slub.c:1727 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1753
 slab_free mm/slub.c:3507 [inline]
 kmem_cache_free_bulk mm/slub.c:3654 [inline]
 kmem_cache_free_bulk+0x2c0/0xb60 mm/slub.c:3641
 mt_free_bulk lib/maple_tree.c:157 [inline]
 mas_destroy+0x394/0x5c0 lib/maple_tree.c:5682
 mas_store_prealloc+0xec/0x150 lib/maple_tree.c:5563
 __vma_adjust+0x6d7/0x1900 mm/mmap.c:832
 vma_adjust include/linux/mm.h:2667 [inline]
 __split_vma+0x443/0x530 mm/mmap.c:2311
 split_vma+0x9f/0xe0 mm/mmap.c:2344
 userfaultfd_unregister fs/userfaultfd.c:1631 [inline]
 userfaultfd_ioctl+0x3896/0x41f0 fs/userfaultfd.c:2002
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl fs/ioctl.c:856 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856
 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

The buggy address belongs to the object at ffff88801b1c5a00
 which belongs to the cache maple_node of size 256
The buggy address is located 32 bytes inside of
 256-byte region [ffff88801b1c5a00, ffff88801b1c5b00)

The buggy address belongs to the physical page:
page:ffffea00006c7100 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1b1c4
head:ffffea00006c7100 order:1 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea00006c7180 dead000000000004 ffff888010c4fdc0
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0x52800(GFP_NOWAIT|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 3317, tgid 3317 (dhcpcd-run-hook), ts 29258456930, free_ts 27859483519
 prep_new_page mm/page_alloc.c:2439 [inline]
 get_page_from_freelist+0xa25/0x3d00 mm/page_alloc.c:4259
 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5483
 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2280
 alloc_slab_page mm/slub.c:1797 [inline]
 allocate_slab+0x26c/0x3c0 mm/slub.c:1942
 new_slab mm/slub.c:2002 [inline]
 ___slab_alloc+0x985/0xd90 mm/slub.c:3002
 kmem_cache_alloc_bulk+0x21c/0x720 mm/slub.c:3704
 mt_alloc_bulk lib/maple_tree.c:151 [inline]
 mas_alloc_nodes+0x1df/0x6b0 lib/maple_tree.c:1244
 mas_node_count+0x101/0x130 lib/maple_tree.c:1303
 mas_split lib/maple_tree.c:3406 [inline]
 mas_commit_b_node lib/maple_tree.c:3508 [inline]
 mas_wr_modify+0x24a1/0x5a50 lib/maple_tree.c:4247
 mas_wr_store_entry.isra.0+0x66e/0x1030 lib/maple_tree.c:4285
 mas_store+0xac/0xf0 lib/maple_tree.c:5519
 dup_mmap+0x88a/0x1090 kernel/fork.c:687
 dup_mm+0x91/0x370 kernel/fork.c:1520
 copy_mm kernel/fork.c:1569 [inline]
 copy_process+0x3bad/0x7010 kernel/fork.c:2233
 kernel_clone+0xe7/0xab0 kernel/fork.c:2648
 __do_sys_clone+0xba/0x100 kernel/fork.c:2782
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1354 [inline]
 free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1404
 free_unref_page_prepare mm/page_alloc.c:3290 [inline]
 free_unref_page+0x19/0x7b0 mm/page_alloc.c:3405
 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2521
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:446
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:750 [inline]
 slab_alloc_node mm/slub.c:3214 [inline]
 slab_alloc mm/slub.c:3222 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3229 [inline]
 kmem_cache_alloc+0x204/0x3b0 mm/slub.c:3239
 getname_flags.part.0+0x50/0x4f0 fs/namei.c:139
 getname_flags+0x9a/0xe0 include/linux/audit.h:323
 vfs_fstatat+0x73/0xb0 fs/stat.c:254
 __do_sys_newfstatat+0x91/0x110 fs/stat.c:425
 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

Memory state around the buggy address:
 ffff88801b1c5900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88801b1c5980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88801b1c5a00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff88801b1c5a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88801b1c5b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (163):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-linux-next-kasan-gce-root 2022/05/13 17:16 linux-next 1e1b28b936ae 107f6434 .config log report syz C KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 13:31 linux-next f02ac5c95dfd 1fa34c1b .config log report syz C KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 13:04 linux-next f02ac5c95dfd 1fa34c1b .config log report syz C KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 12:48 linux-next f02ac5c95dfd 1fa34c1b .config log report syz C KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 12:32 linux-next f02ac5c95dfd 1fa34c1b .config log report syz C KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/19 17:56 linux-next 3f7bdc402fb0 50c53f39 .config log report syz KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/13 16:57 linux-next 1e1b28b936ae 107f6434 .config log report syz KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/12 18:17 linux-next 187b9ac8c348 9ad6612a .config log report syz KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/12 17:58 linux-next 187b9ac8c348 9ad6612a .config log report syz KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/16 01:34 linux-next 1e1b28b936ae 744a39e2 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/15 17:48 linux-next 1e1b28b936ae 744a39e2 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/15 17:20 linux-next 1e1b28b936ae 744a39e2 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/15 06:20 linux-next 1e1b28b936ae 744a39e2 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/15 03:02 linux-next 1e1b28b936ae 744a39e2 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/14 11:56 linux-next 1e1b28b936ae 744a39e2 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/13 19:11 linux-next 1e1b28b936ae 107f6434 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/13 16:12 linux-next 1e1b28b936ae 107f6434 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/13 10:14 linux-next 1e1b28b936ae 9ad6612a .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/13 02:34 linux-next 187b9ac8c348 9ad6612a .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/12 13:29 linux-next 187b9ac8c348 9ad6612a .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/05/12 11:30 linux-next 187b9ac8c348 beb0b407 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/28 15:14 linux-next bdc61aad77fa 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/28 11:36 linux-next f02ac5c95dfd 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/28 10:04 linux-next f02ac5c95dfd 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/28 08:10 linux-next f02ac5c95dfd 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/28 07:50 linux-next f02ac5c95dfd 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/28 05:34 linux-next f02ac5c95dfd 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/28 04:24 linux-next f02ac5c95dfd 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/28 02:04 linux-next f02ac5c95dfd 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/28 00:42 linux-next f02ac5c95dfd 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 23:37 linux-next f02ac5c95dfd 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 21:36 linux-next f02ac5c95dfd 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 21:17 linux-next f02ac5c95dfd 8a1f1f07 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 15:06 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 11:23 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 10:19 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 09:21 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:47 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:45 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:45 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:44 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:43 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:42 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:42 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:36 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:36 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:31 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:27 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:25 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:24 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:22 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 08:20 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/04/27 06:49 linux-next f02ac5c95dfd 1fa34c1b .config log report info KASAN: use-after-free Read in mas_next_nentry