syzbot


KASAN: use-after-free Read in anon_vma_interval_tree_remove

Status: upstream: reported C repro on 2022/05/13 07:42
Reported-by: syzbot+dae32a647a56f4d153da@syzkaller.appspotmail.com
First crash: 138d, last: 3d12h

Cause bisection: introduced by (bisect log) :
commit ff59d518bcac98f97fb365666eb3649320a3af93
Author: Liam R. Howlett <Liam.Howlett@Oracle.com>
Date: Thu May 12 01:12:46 2022 +0000

  mm: remove rb tree.

Crash: KASAN: use-after-free Read in anon_vma_interval_tree_insert (log)
Repro: C syz .config
similar bugs (1):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream general protection fault in anon_vma_interval_tree_remove (2) 2 486d 499d 0/24 auto-closed as invalid on 2021/08/27 20:15
Patch testing requests:
Created Duration User Patch Repo Result
2022/05/13 14:25 26m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/ 187b9ac8c348 OK

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in vma_last_pgoff mm/interval_tree.c:20 [inline]
BUG: KASAN: use-after-free in avc_last_pgoff mm/interval_tree.c:68 [inline]
BUG: KASAN: use-after-free in __anon_vma_interval_tree_augment_compute_max mm/interval_tree.c:71 [inline]
BUG: KASAN: use-after-free in __anon_vma_interval_tree_augment_propagate mm/interval_tree.c:71 [inline]
BUG: KASAN: use-after-free in __rb_erase_augmented include/linux/rbtree_augmented.h:295 [inline]
BUG: KASAN: use-after-free in rb_erase_augmented include/linux/rbtree_augmented.h:303 [inline]
BUG: KASAN: use-after-free in rb_erase_augmented_cached include/linux/rbtree_augmented.h:314 [inline]
BUG: KASAN: use-after-free in __anon_vma_interval_tree_remove mm/interval_tree.c:71 [inline]
BUG: KASAN: use-after-free in anon_vma_interval_tree_remove+0xc7d/0xf30 mm/interval_tree.c:88
Read of size 8 at addr ffff88801882dde8 by task syz-executor269/3611

CPU: 0 PID: 3611 Comm: syz-executor269 Not tainted 6.0.0-rc6-next-20220923-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:284 [inline]
 print_report+0x15e/0x45d mm/kasan/report.c:395
 kasan_report+0xbb/0x1f0 mm/kasan/report.c:495
 vma_last_pgoff mm/interval_tree.c:20 [inline]
 avc_last_pgoff mm/interval_tree.c:68 [inline]
 __anon_vma_interval_tree_augment_compute_max mm/interval_tree.c:71 [inline]
 __anon_vma_interval_tree_augment_propagate mm/interval_tree.c:71 [inline]
 __rb_erase_augmented include/linux/rbtree_augmented.h:295 [inline]
 rb_erase_augmented include/linux/rbtree_augmented.h:303 [inline]
 rb_erase_augmented_cached include/linux/rbtree_augmented.h:314 [inline]
 __anon_vma_interval_tree_remove mm/interval_tree.c:71 [inline]
 anon_vma_interval_tree_remove+0xc7d/0xf30 mm/interval_tree.c:88
 unlink_anon_vmas+0x218/0x860 mm/rmap.c:408
 free_pgtables+0x24d/0x420 mm/memory.c:430
 exit_mmap+0x1ec/0x7a0 mm/mmap.c:3099
 __mmput+0x128/0x4c0 kernel/fork.c:1188
 mmput+0x5c/0x70 kernel/fork.c:1210
 exit_mm kernel/exit.c:516 [inline]
 do_exit+0xa39/0x2a20 kernel/exit.c:807
 do_group_exit+0xd0/0x2a0 kernel/exit.c:950
 __do_sys_exit_group kernel/exit.c:961 [inline]
 __se_sys_exit_group kernel/exit.c:959 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:959
 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:0x7fb77682f739
Code: Unable to access opcode bytes at 0x7fb77682f70f.
RSP: 002b:00007ffec26f9018 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007fb7768a23d0 RCX: 00007fb77682f739
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 0000000000000000
R10: 0000000000000003 R11: 0000000000000246 R12: 00007fb7768a23d0
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001
 </TASK>

Allocated by task 3611:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45
 kasan_set_track+0x21/0x30 mm/kasan/common.c:52
 __kasan_slab_alloc+0x7e/0x80 mm/kasan/common.c:325
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slab.h:754 [inline]
 slab_alloc_node mm/slub.c:3336 [inline]
 slab_alloc mm/slub.c:3344 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3351 [inline]
 kmem_cache_alloc+0x2b7/0x3d0 mm/slub.c:3360
 vm_area_dup+0x81/0x380 kernel/fork.c:466
 copy_vma+0x376/0x880 mm/mmap.c:3219
 move_vma+0x449/0xf60 mm/mremap.c:626
 __do_sys_mremap+0x487/0x16b0 mm/mremap.c:1075
 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 3611:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:45
 kasan_set_track+0x21/0x30 mm/kasan/common.c:52
 kasan_save_free_info+0x2a/0x40 mm/kasan/generic.c:511
 ____kasan_slab_free mm/kasan/common.c:236 [inline]
 ____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:200
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1669 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1695
 slab_free mm/slub.c:3599 [inline]
 kmem_cache_free+0xea/0x5b0 mm/slub.c:3621
 copy_vma+0x6bc/0x880 mm/mmap.c:3246
 move_vma+0x449/0xf60 mm/mremap.c:626
 __do_sys_mremap+0x487/0x16b0 mm/mremap.c:1075
 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 ffff88801882dd80
 which belongs to the cache vm_area_struct of size 152
The buggy address is located 104 bytes inside of
 152-byte region [ffff88801882dd80, ffff88801882de18)

The buggy address belongs to the physical page:
page:ffffea0000620b40 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffffea00009b7780 pfn:0x1882d
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffff8880119d3b40 dead000080120012 0000000000000000
raw: ffffea00009b7780 0000000000000004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 3316, tgid 3316 (dhcpcd-run-hook), ts 24222634229, free_ts 24219362572
 prep_new_page mm/page_alloc.c:2538 [inline]
 get_page_from_freelist+0x1092/0x2d20 mm/page_alloc.c:4287
 __alloc_pages+0x1c7/0x5a0 mm/page_alloc.c:5546
 alloc_pages+0x1a6/0x270 mm/mempolicy.c:2280
 alloc_slab_page mm/slub.c:1739 [inline]
 allocate_slab+0x213/0x300 mm/slub.c:1884
 new_slab mm/slub.c:1937 [inline]
 ___slab_alloc+0xac1/0x1430 mm/slub.c:3119
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3217
 slab_alloc_node mm/slub.c:3302 [inline]
 slab_alloc mm/slub.c:3344 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3351 [inline]
 kmem_cache_alloc+0x31c/0x3d0 mm/slub.c:3360
 vm_area_alloc+0x1c/0xf0 kernel/fork.c:458
 mmap_region+0x448/0x1bf0 mm/mmap.c:2604
 do_mmap+0x825/0xf50 mm/mmap.c:1411
 vm_mmap_pgoff+0x1ab/0x270 mm/util.c:520
 ksys_mmap_pgoff+0x79/0x5a0 mm/mmap.c:1457
 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:1458 [inline]
 free_pcp_prepare+0x65c/0xd90 mm/page_alloc.c:1508
 free_unref_page_prepare mm/page_alloc.c:3386 [inline]
 free_unref_page_list+0x172/0xc40 mm/page_alloc.c:3528
 release_pages+0xc8c/0x1360 mm/swap.c:1055
 tlb_batch_pages_flush+0xa8/0x1a0 mm/mmu_gather.c:58
 tlb_flush_mmu_free mm/mmu_gather.c:255 [inline]
 tlb_flush_mmu mm/mmu_gather.c:262 [inline]
 tlb_finish_mmu+0x147/0x7e0 mm/mmu_gather.c:353
 exit_mmap+0x1fe/0x7a0 mm/mmap.c:3101
 __mmput+0x128/0x4c0 kernel/fork.c:1188
 mmput+0x5c/0x70 kernel/fork.c:1210
 exit_mm kernel/exit.c:516 [inline]
 do_exit+0xa39/0x2a20 kernel/exit.c:807
 do_group_exit+0xd0/0x2a0 kernel/exit.c:950
 __do_sys_exit_group kernel/exit.c:961 [inline]
 __se_sys_exit_group kernel/exit.c:959 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:959
 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:
 ffff88801882dc80: fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb
 ffff88801882dd00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88801882dd80: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                          ^
 ffff88801882de00: fb fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb
 ffff88801882de80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
==================================================================

Crashes (12):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-linux-next-kasan-gce-root 2022/09/25 02:32 linux-next aaa11ce2ffc8 0042f2b4 .config log report syz C KASAN: use-after-free Read in anon_vma_interval_tree_remove
ci-upstream-linux-next-kasan-gce-root 2022/09/04 13:33 linux-next e47eb90a0a9a 28811d0a .config log report syz C KASAN: use-after-free Read in anon_vma_interval_tree_remove
ci-upstream-linux-next-kasan-gce-root 2022/07/14 05:43 linux-next cb71b93c2dc3 5d921b08 .config log report syz C KASAN: use-after-free Read in anon_vma_interval_tree_remove
ci-upstream-linux-next-kasan-gce-root 2022/05/12 22:13 linux-next 187b9ac8c348 9ad6612a .config log report syz C KASAN: use-after-free Read in anon_vma_interval_tree_remove
ci-upstream-linux-next-kasan-gce-root 2022/09/24 17:34 linux-next aaa11ce2ffc8 0042f2b4 .config log report info KASAN: use-after-free Read in anon_vma_interval_tree_remove
ci-upstream-linux-next-kasan-gce-root 2022/09/16 01:25 linux-next e47eb90a0a9a dd9a85ff .config log report info KASAN: use-after-free Read in anon_vma_interval_tree_remove
ci-upstream-linux-next-kasan-gce-root 2022/09/13 03:38 linux-next e47eb90a0a9a f371ed7e .config log report info KASAN: use-after-free Read in anon_vma_interval_tree_remove
ci-upstream-linux-next-kasan-gce-root 2022/09/04 19:50 linux-next e47eb90a0a9a 28811d0a .config log report info KASAN: use-after-free Read in anon_vma_interval_tree_remove
ci-upstream-linux-next-kasan-gce-root 2022/09/02 23:50 linux-next e47eb90a0a9a 25194605 .config log report info KASAN: use-after-free Read in anon_vma_interval_tree_remove
ci-upstream-linux-next-kasan-gce-root 2022/07/27 02:06 linux-next cb71b93c2dc3 279b89c2 .config log report info KASAN: use-after-free Read in anon_vma_interval_tree_remove
ci-upstream-linux-next-kasan-gce-root 2022/06/23 23:38 linux-next 08897940f458 912f5df7 .config log report info KASAN: use-after-free Read in anon_vma_interval_tree_remove
ci-upstream-linux-next-kasan-gce-root 2022/06/22 00:12 linux-next 34d1d36073ea 0fc5c330 .config log report info KASAN: use-after-free Read in anon_vma_interval_tree_remove
* Struck through repros no longer work on HEAD.