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: 154d, last: 18h40m

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:721 [inline]
BUG: KASAN: use-after-free in mas_next_nentry+0x9e4/0xab0 lib/maple_tree.c:4662
Read of size 8 at addr ffff888076721a20 by task syz-executor250/3606

CPU: 0 PID: 3606 Comm: syz-executor250 Not tainted 6.0.0-rc3-next-20220901-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/26/2022
Call Trace:
 <TASK>
 __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:317 [inline]
 print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
 kasan_report+0xb1/0x1e0 mm/kasan/report.c:495
 mas_safe_min lib/maple_tree.c:721 [inline]
 mas_next_nentry+0x9e4/0xab0 lib/maple_tree.c:4662
 mas_next_entry lib/maple_tree.c:4757 [inline]
 mas_next+0x1fb/0xc90 lib/maple_tree.c:5868
 userfaultfd_unregister fs/userfaultfd.c:1657 [inline]
 userfaultfd_ioctl+0x33c3/0x4200 fs/userfaultfd.c:2005
 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+0x63/0xcd
RIP: 0033:0x7f7393aaf909
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:00007f7393a5f208 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f7393b383e8 RCX: 00007f7393aaf909
RDX: 0000000020000240 RSI: 000000008010aa01 RDI: 0000000000000003
RBP: 00007f7393b383e0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f7393b383ec
R13: 00007fff099d5c8f R14: 00007f7393a5f300 R15: 0000000000022000
 </TASK>

Allocated by task 3604:
 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:437 [inline]
 __kasan_slab_alloc+0x90/0xc0 mm/kasan/common.c:470
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:737 [inline]
 kmem_cache_alloc_bulk+0x3f8/0x860 mm/slub.c:3773
 mt_alloc_bulk lib/maple_tree.c:157 [inline]
 mas_alloc_nodes+0x309/0x810 lib/maple_tree.c:1256
 mas_node_count_gfp+0x106/0x140 lib/maple_tree.c:1316
 mas_node_count lib/maple_tree.c:1330 [inline]
 mas_expected_entries+0x113/0x200 lib/maple_tree.c:5822
 dup_mmap+0x4ca/0x10b0 kernel/fork.c:616
 dup_mm+0x91/0x370 kernel/fork.c:1528
 copy_mm kernel/fork.c:1577 [inline]
 copy_process+0x3be1/0x7120 kernel/fork.c:2258
 kernel_clone+0xe7/0xab0 kernel/fork.c:2678
 __do_sys_clone+0xba/0x100 kernel/fork.c:2819
 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+0x63/0xcd

Freed by task 3606:
 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:367 [inline]
 ____kasan_slab_free+0x166/0x1c0 mm/kasan/common.c:329
 kasan_slab_free include/linux/kasan.h:200 [inline]
 slab_free_hook mm/slub.c:1651 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1677
 slab_free mm/slub.c:3580 [inline]
 kmem_cache_free_bulk.part.0+0x205/0x780 mm/slub.c:3698
 mt_free_bulk lib/maple_tree.c:163 [inline]
 mas_destroy+0x394/0x5c0 lib/maple_tree.c:5769
 mas_store_prealloc+0xec/0x150 lib/maple_tree.c:5704
 __vma_adjust+0xc47/0x1a70 mm/mmap.c:783
 vma_adjust include/linux/mm.h:2656 [inline]
 __split_vma+0x4b0/0x5c0 mm/mmap.c:2236
 split_vma+0x9f/0xe0 mm/mmap.c:2272
 userfaultfd_unregister fs/userfaultfd.c:1636 [inline]
 userfaultfd_ioctl+0x3855/0x4200 fs/userfaultfd.c:2005
 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+0x63/0xcd

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

The buggy address belongs to the physical page:
page:ffffea0001d9c800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x76720
head:ffffea0001d9c800 order:1 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0001d9c880 dead000000000003 ffff88801184fdc0
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 3308, tgid 3308 (dhcpcd-run-hook), ts 23803367813, free_ts 21911174041
 prep_new_page mm/page_alloc.c:2534 [inline]
 get_page_from_freelist+0x109b/0x2ce0 mm/page_alloc.c:4284
 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5542
 alloc_pages+0x1a6/0x270 mm/mempolicy.c:2280
 alloc_slab_page mm/slub.c:1721 [inline]
 allocate_slab+0x228/0x370 mm/slub.c:1866
 new_slab mm/slub.c:1919 [inline]
 ___slab_alloc+0xad0/0x1440 mm/slub.c:3100
 kmem_cache_alloc_bulk+0x291/0x860 mm/slub.c:3749
 mt_alloc_bulk lib/maple_tree.c:157 [inline]
 mas_alloc_nodes+0x309/0x810 lib/maple_tree.c:1256
 mas_node_count_gfp+0x106/0x140 lib/maple_tree.c:1316
 mas_node_count lib/maple_tree.c:1330 [inline]
 mas_expected_entries+0x113/0x200 lib/maple_tree.c:5822
 dup_mmap+0x4ca/0x10b0 kernel/fork.c:616
 dup_mm+0x91/0x370 kernel/fork.c:1528
 copy_mm kernel/fork.c:1577 [inline]
 copy_process+0x3be1/0x7120 kernel/fork.c:2258
 kernel_clone+0xe7/0xab0 kernel/fork.c:2678
 __do_sys_clone+0xba/0x100 kernel/fork.c:2819
 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+0x63/0xcd
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1451 [inline]
 free_pcp_prepare+0x5e4/0xd20 mm/page_alloc.c:1501
 free_unref_page_prepare mm/page_alloc.c:3382 [inline]
 free_unref_page+0x19/0x4d0 mm/page_alloc.c:3478
 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2514
 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:447
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:737 [inline]
 slab_alloc_node mm/slub.c:3317 [inline]
 slab_alloc mm/slub.c:3325 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3332 [inline]
 kmem_cache_alloc+0x2b7/0x3d0 mm/slub.c:3341
 getname_flags.part.0+0x50/0x4f0 fs/namei.c:139
 getname_flags+0x9a/0xe0 include/linux/audit.h:320
 user_path_at_empty+0x2b/0x60 fs/namei.c:2875
 do_readlinkat+0xcd/0x2f0 fs/stat.c:456
 __do_sys_readlink fs/stat.c:489 [inline]
 __se_sys_readlink fs/stat.c:486 [inline]
 __x64_sys_readlink+0x74/0xb0 fs/stat.c:486
 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+0x63/0xcd

Memory state around the buggy address:
 ffff888076721900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888076721980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888076721a00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff888076721a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888076721b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (268):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-linux-next-kasan-gce-root 2022/09/04 08:01 linux-next e47eb90a0a9a 28811d0a .config log report syz C KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/06/13 06:17 linux-next 6d0c80680317 0d5abf15 .config log report syz C KASAN: use-after-free Read in mas_next_nentry
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/08/08 01:40 linux-next cb71b93c2dc3 88e3a122 .config log report syz KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/08 01:19 linux-next cb71b93c2dc3 88e3a122 .config log report syz KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/06/13 06:32 linux-next 6d0c80680317 0d5abf15 .config log report syz KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/06/11 21:12 linux-next 6d0c80680317 0d5abf15 .config log report syz KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/06/03 23:06 linux-next 1cfd968b58a1 eee80d3c .config log report syz 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/09/27 22:29 linux-next aaa11ce2ffc8 87840e00 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/25 05:24 linux-next aaa11ce2ffc8 0042f2b4 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/19 11:54 linux-next e47eb90a0a9a dd9a85ff .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/19 06:48 linux-next e47eb90a0a9a dd9a85ff .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/18 19:20 linux-next e47eb90a0a9a dd9a85ff .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/18 05:53 linux-next e47eb90a0a9a dd9a85ff .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/17 18:45 linux-next e47eb90a0a9a dd9a85ff .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/17 14:49 linux-next e47eb90a0a9a dd9a85ff .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/16 00:58 linux-next e47eb90a0a9a dd9a85ff .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/14 01:20 linux-next e47eb90a0a9a b884348d .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/08 23:42 linux-next e47eb90a0a9a f3027468 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/07 02:51 linux-next e47eb90a0a9a 5fc30c37 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/03 13:40 linux-next e47eb90a0a9a 49e94a20 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/09/02 13:28 linux-next e47eb90a0a9a a805568e .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/31 01:06 linux-next 282342f2dc97 4a380809 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/29 09:20 linux-next b27a3ca08ba7 07177916 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/29 07:04 linux-next 8d0c42c9e807 07177916 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/28 18:05 linux-next 8d0c42c9e807 07177916 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/28 15:48 linux-next 8d0c42c9e807 07177916 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/26 14:43 linux-next 8d0c42c9e807 e5a303f1 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/26 09:49 linux-next 8d0c42c9e807 15195ea3 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/25 04:42 linux-next 68a00424bf69 514514f6 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/23 07:09 linux-next 05477f3653b8 26a13b38 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/03 07:55 linux-next cb71b93c2dc3 1c9013ac .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/08/01 18:25 linux-next cb71b93c2dc3 fef302b1 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/27 02:18 linux-next cb71b93c2dc3 279b89c2 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/24 08:23 linux-next cb71b93c2dc3 22343af4 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/21 23:12 linux-next cb71b93c2dc3 5e6028b9 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/21 15:50 linux-next cb71b93c2dc3 6e67af9d .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/20 17:46 linux-next cb71b93c2dc3 775344bc .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/18 20:02 linux-next cb71b93c2dc3 ff988920 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/18 14:29 linux-next cb71b93c2dc3 ff988920 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/15 04:50 linux-next cb71b93c2dc3 5d921b08 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/11 11:14 linux-next cb71b93c2dc3 da3d6955 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/06 09:47 linux-next cb71b93c2dc3 bff65f44 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/06 09:47 linux-next cb71b93c2dc3 bff65f44 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/04 23:04 linux-next cb71b93c2dc3 bff65f44 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/04 01:45 linux-next cb71b93c2dc3 1434eec0 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/03 02:16 linux-next cb71b93c2dc3 1434eec0 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/07/01 21:33 linux-next cb71b93c2dc3 1434eec0 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/06/30 18:27 linux-next cb71b93c2dc3 1434eec0 .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/06/27 07:05 linux-next aab35c3d5112 a371c43c .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/06/27 02:23 linux-next 2f9cb3d3bd73 a371c43c .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/06/26 01:33 linux-next 2f9cb3d3bd73 a371c43c .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/06/26 01:21 linux-next 2f9cb3d3bd73 a371c43c .config log report info KASAN: use-after-free Read in mas_next_nentry
ci-upstream-linux-next-kasan-gce-root 2022/06/25 23:02 linux-next 2f9cb3d3bd73 a371c43c .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
* Struck through repros no longer work on HEAD.