syzbot


KASAN: slab-out-of-bounds Read in gfn_to_hva

Status: closed as dup on 2020/04/10 17:54
Subsystems: kvm
[Documentation on labels]
Reported-by: syzbot+e06e0f40470ee2de4dda@syzkaller.appspotmail.com
First crash: 1424d, last: 1386d
Cause bisection: introduced by (bisect log) :
commit 5c0b4f3d5ccc2ced94b01c3256db1cf79dc95b81
Author: Sean Christopherson <sean.j.christopherson@intel.com>
Date: Tue Feb 18 21:07:26 2020 +0000

  KVM: Move memslot deletion to helper function

Crash: KASAN: vmalloc-out-of-bounds Read in srcu_invoke_callbacks (log)
Repro: syz .config
  
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
KASAN: slab-out-of-bounds Read in __kvm_gfn_to_hva_cache_init kvm C done 1537 1382d 1427d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: slab-out-of-bounds Read in gfn_to_hva 1 (2) 2020/04/10 17:54

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in search_memslots include/linux/kvm_host.h:1051 [inline]
BUG: KASAN: slab-out-of-bounds in __gfn_to_memslot include/linux/kvm_host.h:1063 [inline]
BUG: KASAN: slab-out-of-bounds in gfn_to_memslot arch/x86/kvm/../../../virt/kvm/kvm_main.c:1597 [inline]
BUG: KASAN: slab-out-of-bounds in gfn_to_hva+0x4a0/0x4c0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1677
Read of size 8 at addr ffff8880a66c7468 by task syz-executor832/11856

CPU: 0 PID: 11856 Comm: syz-executor832 Not tainted 5.7.0-rc1-next-20200415-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x188/0x20d lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd3/0x315 mm/kasan/report.c:382
 __kasan_report.cold+0x35/0x4d mm/kasan/report.c:511
 kasan_report+0x33/0x50 mm/kasan/common.c:625
 search_memslots include/linux/kvm_host.h:1051 [inline]
 __gfn_to_memslot include/linux/kvm_host.h:1063 [inline]
 gfn_to_memslot arch/x86/kvm/../../../virt/kvm/kvm_main.c:1597 [inline]
 gfn_to_hva+0x4a0/0x4c0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1677
 kvm_arch_mmu_notifier_invalidate_range+0x21/0x80 arch/x86/kvm/x86.c:8142
 kvm_mmu_notifier_invalidate_range_start+0x1a1/0x280 arch/x86/kvm/../../../virt/kvm/kvm_main.c:421
 mn_hlist_invalidate_range_start mm/mmu_notifier.c:493 [inline]
 __mmu_notifier_invalidate_range_start+0x4bc/0x6b0 mm/mmu_notifier.c:525
 mmu_notifier_invalidate_range_start include/linux/mmu_notifier.h:446 [inline]
 change_pmd_range mm/mprotect.c:247 [inline]
 change_pud_range mm/mprotect.c:297 [inline]
 change_p4d_range mm/mprotect.c:317 [inline]
 change_protection_range mm/mprotect.c:342 [inline]
 change_protection+0x1ed0/0x2710 mm/mprotect.c:365
 mprotect_fixup+0x46c/0x940 mm/mprotect.c:487
 do_mprotect_pkey+0x542/0x950 mm/mprotect.c:613
 __do_sys_mprotect mm/mprotect.c:638 [inline]
 __se_sys_mprotect mm/mprotect.c:635 [inline]
 __x64_sys_mprotect+0x74/0xb0 mm/mprotect.c:635
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x446a27
Code: 00 00 00 b8 0b 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 7d 06 fc ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 b8 0a 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 5d 06 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffda70da9b8 EFLAGS: 00000246 ORIG_RAX: 000000000000000a
RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 0000000000446a27
RDX: 0000000000000000 RSI: 0000000000001000 RDI: 00007f35ddfbb000
RBP: 00007ffda70daaa0 R08: 00000000006dba20 R09: 00000000006dba20
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffda70daac0
R13: 00007f35ddfdb700 R14: 00007f35ddfdb9c0 R15: 000000000000002d

Allocated by task 11861:
 save_stack+0x1b/0x40 mm/kasan/common.c:49
 set_track mm/kasan/common.c:57 [inline]
 __kasan_kmalloc mm/kasan/common.c:495 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:468
 kmalloc_node include/linux/slab.h:578 [inline]
 kvmalloc_node+0x61/0xf0 mm/util.c:574
 kvmalloc include/linux/mm.h:757 [inline]
 kvzalloc include/linux/mm.h:765 [inline]
 kvm_dup_memslots arch/x86/kvm/../../../virt/kvm/kvm_main.c:1101 [inline]
 kvm_set_memslot+0x115/0x1530 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1118
 __kvm_set_memory_region+0xcf7/0x1320 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1300
 kvm_set_memory_region+0x29/0x50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1321
 kvm_vm_ioctl_set_memory_region arch/x86/kvm/../../../virt/kvm/kvm_main.c:1333 [inline]
 kvm_vm_ioctl+0x678/0x2400 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3604
 vfs_ioctl fs/ioctl.c:47 [inline]
 ksys_ioctl+0x11a/0x180 fs/ioctl.c:763
 __do_sys_ioctl fs/ioctl.c:772 [inline]
 __se_sys_ioctl fs/ioctl.c:770 [inline]
 __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:770
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

Freed by task 10589:
 save_stack+0x1b/0x40 mm/kasan/common.c:49
 set_track mm/kasan/common.c:57 [inline]
 kasan_set_free_info mm/kasan/common.c:317 [inline]
 __kasan_slab_free+0xf7/0x140 mm/kasan/common.c:456
 __cache_free mm/slab.c:3426 [inline]
 kfree+0x109/0x2b0 mm/slab.c:3757
 kvfree+0x42/0x50 mm/util.c:603
 kvm_free_memslots+0x1b9/0x230 arch/x86/kvm/../../../virt/kvm/kvm_main.c:601
 kvm_destroy_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:810 [inline]
 kvm_put_kvm+0x7d2/0xc40 arch/x86/kvm/../../../virt/kvm/kvm_main.c:828
 kvm_vm_release+0x3f/0x50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:851
 __fput+0x33e/0x880 fs/file_table.c:280
 task_work_run+0xf4/0x1b0 kernel/task_work.c:123
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xb53/0x2e10 kernel/exit.c:795
 do_group_exit+0x125/0x340 kernel/exit.c:893
 get_signal+0x47b/0x24e0 kernel/signal.c:2735
 do_signal+0x81/0x2240 arch/x86/kernel/signal.c:784
 exit_to_usermode_loop+0x26c/0x360 arch/x86/entry/common.c:161
 prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:279 [inline]
 do_syscall_64+0x6b1/0x7d0 arch/x86/entry/common.c:305
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

The buggy address belongs to the object at ffff8880a66c7000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1128 bytes inside of
 2048-byte region [ffff8880a66c7000, ffff8880a66c7800)
The buggy address belongs to the page:
page:ffffea000299b1c0 refcount:1 mapcount:0 mapping:00000000b32d132d index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea0002980848 ffffea0002980f88 ffff8880aa000e00
raw: 0000000000000000 ffff8880a66c7000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a66c7300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880a66c7380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880a66c7400: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc
                                                          ^
 ffff8880a66c7480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880a66c7500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (29):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/05/05 05:14 linux-next ac935d227366 9941337c .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/05/03 03:14 linux-next ac935d227366 5457883a .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/04/10 09:50 upstream 5d30bcacd91a a8c6a3f8 .config console log report syz ci-upstream-kasan-gce
2020/04/15 14:27 upstream 8632e9b5645b 3f3c5574 .config console log report syz ci-upstream-kasan-gce-386
2020/04/21 16:23 upstream ae83d0b416db 2e44d63e .config console log report ci-upstream-kasan-gce
2020/04/19 22:57 upstream 0fe5f9ca2235 6dfd45e1 .config console log report ci-upstream-kasan-gce
2020/04/18 11:14 upstream 90280eaa88ac 435c6d53 .config console log report ci-upstream-kasan-gce-selinux-root
2020/04/18 11:08 upstream 90280eaa88ac 435c6d53 .config console log report ci-upstream-kasan-gce-root
2020/04/18 10:28 upstream 90280eaa88ac 435c6d53 .config console log report ci-upstream-kasan-gce
2020/04/13 00:06 upstream 4f8a3cc1183c 36b0b050 .config console log report ci-upstream-kasan-gce
2020/04/12 23:56 upstream 4f8a3cc1183c 36b0b050 .config console log report ci-upstream-kasan-gce-selinux-root
2020/04/12 23:56 upstream 4f8a3cc1183c 36b0b050 .config console log report ci-upstream-kasan-gce-selinux-root
2020/04/12 23:46 upstream 4f8a3cc1183c 36b0b050 .config console log report ci-upstream-kasan-gce
2020/04/12 23:44 upstream 4f8a3cc1183c 36b0b050 .config console log report ci-upstream-kasan-gce
2020/04/12 10:20 upstream b032227c6293 a8c6a3f8 .config console log report ci-upstream-kasan-gce-selinux-root
2020/04/12 10:14 upstream b032227c6293 a8c6a3f8 .config console log report ci-upstream-kasan-gce
2020/04/12 10:10 upstream b032227c6293 a8c6a3f8 .config console log report ci-upstream-kasan-gce-root
2020/04/10 09:32 upstream 5d30bcacd91a a8c6a3f8 .config console log report ci-upstream-kasan-gce
2020/04/18 11:48 upstream 90280eaa88ac 435c6d53 .config console log report ci-upstream-kasan-gce-386
2020/04/13 00:16 upstream 4f8a3cc1183c 36b0b050 .config console log report ci-upstream-kasan-gce-386
2020/04/12 23:46 upstream 4f8a3cc1183c 36b0b050 .config console log report ci-upstream-kasan-gce-386
2020/05/18 18:48 linux-next ac935d227366 684d3606 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/18 01:45 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/17 02:24 linux-next ac935d227366 37bccd4e .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/08 09:54 linux-next ac935d227366 6c70a1c2 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/08 09:47 linux-next ac935d227366 6c70a1c2 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/04/29 22:35 linux-next ac935d227366 496a08ae .config console log report ci-upstream-linux-next-kasan-gce-root
2020/04/19 04:36 linux-next ac935d227366 365fba24 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/04/12 23:34 linux-next d2a22790db70 36b0b050 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.