bisecting cause commit starting from bef7b2a7be28638770972ab2709adf11d601c11a building syzkaller on 5ed396e666c7826bed46f06c4db1409376691fed testing commit bef7b2a7be28638770972ab2709adf11d601c11a with gcc (GCC) 8.1.0 kernel signature: 8e0a9e52629ae8377ecad4826a321095f228b200190a15af3236d06b385778cf all runs: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page testing release v5.6 testing commit 7111951b8d4973bda27ff663f2cf18b663d15b48 with gcc (GCC) 8.1.0 kernel signature: 894c630fe4d90f5f4be7b6b19259514f5328ec72a7337a43f7341eec66f042c8 all runs: OK # git bisect start bef7b2a7be28638770972ab2709adf11d601c11a 7111951b8d4973bda27ff663f2cf18b663d15b48 Bisecting: 3821 revisions left to test after this (roughly 12 steps) [29d9f30d4ce6c7a38745a54a8cddface10013490] Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next testing commit 29d9f30d4ce6c7a38745a54a8cddface10013490 with gcc (GCC) 8.1.0 kernel signature: 82e956984007b2822a152b61bda220bbc7f485c373ac806d963db9785b1273ef all runs: OK # git bisect good 29d9f30d4ce6c7a38745a54a8cddface10013490 Bisecting: 1948 revisions left to test after this (roughly 11 steps) [50a5de895dbe5df947b3a695777db5b2c313e065] Merge tag 'for-linus-hmm' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma testing commit 50a5de895dbe5df947b3a695777db5b2c313e065 with gcc (GCC) 8.1.0 kernel signature: 3ba7bc79424597e649de82b23565fd4f1a979157368646366caaacececa7b69d all runs: OK # git bisect good 50a5de895dbe5df947b3a695777db5b2c313e065 Bisecting: 1022 revisions left to test after this (roughly 10 steps) [bc3b3f4bfbded031a11c4284106adddbfacd05bb] Merge tag 'pinctrl-v5.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl testing commit bc3b3f4bfbded031a11c4284106adddbfacd05bb with gcc (GCC) 8.1.0 kernel signature: f190e69253313c62ebca24d41f008f32c9ff65655e2c3a637e47aba847668b68 all runs: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page # git bisect bad bc3b3f4bfbded031a11c4284106adddbfacd05bb Bisecting: 406 revisions left to test after this (roughly 9 steps) [6cad420cc695867b4ca710bac21fde21a4102e4b] Merge branch 'akpm' (patches from Andrew) testing commit 6cad420cc695867b4ca710bac21fde21a4102e4b with gcc (GCC) 8.1.0 kernel signature: 8a0ab3edb29c87f93265acd4c83d6e3bb47aabdac7e2cc1adb67a57e2f5538ad all runs: OK # git bisect good 6cad420cc695867b4ca710bac21fde21a4102e4b Bisecting: 188 revisions left to test after this (roughly 8 steps) [1c482452d5db0f52e4e8eed95bd7314eec537d78] Merge tag 'kvm-s390-next-5.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux into HEAD testing commit 1c482452d5db0f52e4e8eed95bd7314eec537d78 with gcc (GCC) 8.1.0 kernel signature: a305e369c982f333407cec25753e2895bd10ece346fb5b7c96a1ad2e60740721 run #0: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #1: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #2: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #3: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #4: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #5: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #6: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #7: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #8: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #9: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva # git bisect bad 1c482452d5db0f52e4e8eed95bd7314eec537d78 Bisecting: 108 revisions left to test after this (roughly 7 steps) [733deafc00df1dda5130fc14f87a1d3993913243] KVM: x86: Handle RDTSCP CPUID adjustment in VMX code testing commit 733deafc00df1dda5130fc14f87a1d3993913243 with gcc (GCC) 8.1.0 kernel signature: d1087ad9ca016ead70086a2e9283513f4eb0b008d0c36371761e133da0c80500 run #0: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #1: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #2: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #3: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #4: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #5: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #6: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #7: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #8: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #9: boot failed: can't ssh into the instance # git bisect bad 733deafc00df1dda5130fc14f87a1d3993913243 Bisecting: 54 revisions left to test after this (roughly 6 steps) [0be44352071dc87a4f9bf879642b1d44876971d9] KVM: x86/mmu: Reuse the current root if possible for fast switch testing commit 0be44352071dc87a4f9bf879642b1d44876971d9 with gcc (GCC) 8.1.0 kernel signature: b56a90f7808598e0222d4f14930f94e387c67dae56b7829b28e89b62313a2581 run #0: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #1: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #2: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #3: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #4: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #5: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #6: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #7: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #8: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #9: boot failed: can't ssh into the instance # git bisect bad 0be44352071dc87a4f9bf879642b1d44876971d9 Bisecting: 26 revisions left to test after this (roughly 5 steps) [82307e676f9d885871f121e4921b12905a53397d] KVM: PPC: Move memslot memory allocation into prepare_memory_region() testing commit 82307e676f9d885871f121e4921b12905a53397d with gcc (GCC) 8.1.0 kernel signature: 8a324a3c7df087469f7482e421b15feef00b7de4f3f0ae39c72f2a61639a2773 all runs: OK # git bisect good 82307e676f9d885871f121e4921b12905a53397d Bisecting: 13 revisions left to test after this (roughly 4 steps) [0577d1abe704c315bb5cdfc71f4ca7b9b5358f59] KVM: Terminate memslot walks via used_slots testing commit 0577d1abe704c315bb5cdfc71f4ca7b9b5358f59 with gcc (GCC) 8.1.0 kernel signature: 21381d9f0ccad0f3bb615a5267ab9834f48c0aacc6872f1cca3b8aa599639b45 run #0: OK run #1: OK run #2: OK run #3: OK run #4: OK run #5: OK run #6: OK run #7: OK run #8: OK run #9: boot failed: can't ssh into the instance # git bisect good 0577d1abe704c315bb5cdfc71f4ca7b9b5358f59 Bisecting: 6 revisions left to test after this (roughly 3 steps) [d18b2f43b9147c8005ae0844fb445d8cc6a87e31] KVM: x86: Gracefully handle __vmalloc() failure during VM allocation testing commit d18b2f43b9147c8005ae0844fb445d8cc6a87e31 with gcc (GCC) 8.1.0 kernel signature: 5296f8a0c81b13f4bbd5d6ad6b2425d45cf979828dd001fe6fc03cc4dfc467a2 run #0: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #1: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #2: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #3: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #4: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #5: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #6: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #7: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #8: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #9: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva # git bisect bad d18b2f43b9147c8005ae0844fb445d8cc6a87e31 Bisecting: 3 revisions left to test after this (roughly 2 steps) [b3594ffbf932c8e8b23201cdc2c173708a4472dc] KVM: x86/mmu: Move kvm_arch_flush_remote_tlbs_memslot() to mmu.c testing commit b3594ffbf932c8e8b23201cdc2c173708a4472dc with gcc (GCC) 8.1.0 kernel signature: 8af608b0d94e7d810e370a541c01eda9f1541ec19ff16faabaa10fc6b7a10589 all runs: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page # git bisect bad b3594ffbf932c8e8b23201cdc2c173708a4472dc Bisecting: 0 revisions left to test after this (roughly 1 step) [13e48aa9429d1be05ecf8b9eefb212ac58f3f704] KVM: selftests: Add test for KVM_SET_USER_MEMORY_REGION testing commit 13e48aa9429d1be05ecf8b9eefb212ac58f3f704 with gcc (GCC) 8.1.0 kernel signature: c15ff323fa4a84a66a97bba5f6d728b138f9a4fb80c71b7d97a165f39158d751 run #0: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #1: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #2: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #3: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #4: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #5: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #6: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #7: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #8: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #9: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva # git bisect bad 13e48aa9429d1be05ecf8b9eefb212ac58f3f704 Bisecting: 0 revisions left to test after this (roughly 0 steps) [36947254e5f981aeeedab1c7dfa35fc34d330e80] KVM: Dynamically size memslot array based on number of used slots testing commit 36947254e5f981aeeedab1c7dfa35fc34d330e80 with gcc (GCC) 8.1.0 kernel signature: 083a7848d0cc01ea5397cedfe27b8384c04d656d3141c5f418637eef2a027861 run #0: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #1: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #2: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #3: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #4: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #5: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #6: crashed: KASAN: slab-out-of-bounds Read in gfn_to_hva run #7: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #8: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page run #9: crashed: KASAN: slab-out-of-bounds Read in kvm_read_guest_page # git bisect bad 36947254e5f981aeeedab1c7dfa35fc34d330e80 36947254e5f981aeeedab1c7dfa35fc34d330e80 is the first bad commit commit 36947254e5f981aeeedab1c7dfa35fc34d330e80 Author: Sean Christopherson Date: Tue Feb 18 13:07:32 2020 -0800 KVM: Dynamically size memslot array based on number of used slots Now that the memslot logic doesn't assume memslots are always non-NULL, dynamically size the array of memslots instead of unconditionally allocating memory for the maximum number of memslots. Note, because a to-be-deleted memslot must first be invalidated, the array size cannot be immediately reduced when deleting a memslot. However, consecutive deletions will realize the memory savings, i.e. a second deletion will trim the entry. Tested-by: Christoffer Dall Tested-by: Marc Zyngier Reviewed-by: Peter Xu Signed-off-by: Sean Christopherson Signed-off-by: Paolo Bonzini include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c | 31 ++++++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) culprit signature: 083a7848d0cc01ea5397cedfe27b8384c04d656d3141c5f418637eef2a027861 parent signature: 21381d9f0ccad0f3bb615a5267ab9834f48c0aacc6872f1cca3b8aa599639b45 revisions tested: 15, total time: 3h14m33.510452799s (build: 1h28m10.306458026s, test: 1h45m32.741325276s) first bad commit: 36947254e5f981aeeedab1c7dfa35fc34d330e80 KVM: Dynamically size memslot array based on number of used slots cc: ["christoffer.dall@arm.com" "maz@kernel.org" "pbonzini@redhat.com" "peterx@redhat.com" "sean.j.christopherson@intel.com"] crash: KASAN: slab-out-of-bounds Read in kvm_read_guest_page ================================================================== BUG: KASAN: slab-out-of-bounds in search_memslots include/linux/kvm_host.h:1042 [inline] BUG: KASAN: slab-out-of-bounds in __gfn_to_memslot include/linux/kvm_host.h:1054 [inline] BUG: KASAN: slab-out-of-bounds in gfn_to_memslot arch/x86/kvm/../../../virt/kvm/kvm_main.c:1604 [inline] BUG: KASAN: slab-out-of-bounds in kvm_read_guest_page+0x424/0x440 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2274 Read of size 8 at addr ffff8880a8d81468 by task syz-executor.0/8585 CPU: 1 PID: 8585 Comm: syz-executor.0 Not tainted 5.6.0-rc1-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+0x128/0x182 lib/dump_stack.c:118 print_address_description.constprop.8.cold.10+0x9/0x317 mm/kasan/report.c:374 __kasan_report.cold.11+0x1c/0x34 mm/kasan/report.c:506 kasan_report+0xe/0x20 mm/kasan/common.c:641 search_memslots include/linux/kvm_host.h:1042 [inline] __gfn_to_memslot include/linux/kvm_host.h:1054 [inline] gfn_to_memslot arch/x86/kvm/../../../virt/kvm/kvm_main.c:1604 [inline] kvm_read_guest_page+0x424/0x440 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2274 kvm_read_guest+0x42/0x80 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2297 kvm_write_wall_clock arch/x86/kvm/x86.c:1686 [inline] kvm_set_msr_common+0x46a/0x1f30 arch/x86/kvm/x86.c:2818 vmx_set_msr+0x2ff/0x1df0 arch/x86/kvm/vmx/vmx.c:2223 __kvm_set_msr+0x16a/0x2b0 arch/x86/kvm/x86.c:1477 __msr_io arch/x86/kvm/x86.c:3229 [inline] msr_io+0x114/0x1e0 arch/x86/kvm/x86.c:3265 kvm_arch_vcpu_ioctl+0xff3/0x2980 arch/x86/kvm/x86.c:4323 kvm_vcpu_ioctl+0x1d0/0xa20 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3304 kvm_vcpu_compat_ioctl+0x16d/0x320 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3347 __do_compat_sys_ioctl fs/ioctl.c:857 [inline] __se_compat_sys_ioctl fs/ioctl.c:808 [inline] __ia32_compat_sys_ioctl+0x1ce/0x220 fs/ioctl.c:808 do_syscall_32_irqs_on arch/x86/entry/common.c:337 [inline] do_fast_syscall_32+0x231/0xb27 arch/x86/entry/common.c:408 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 Allocated by task 8585: save_stack+0x19/0x80 mm/kasan/common.c:72 set_track mm/kasan/common.c:80 [inline] __kasan_kmalloc.constprop.17+0xc1/0xd0 mm/kasan/common.c:515 kvmalloc include/linux/mm.h:645 [inline] kvzalloc include/linux/mm.h:653 [inline] kvm_dup_memslots arch/x86/kvm/../../../virt/kvm/kvm_main.c:1100 [inline] kvm_set_memslot+0xd4/0x1570 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1117 __kvm_set_memory_region+0x8fb/0xca0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1296 kvm_set_memory_region+0x23/0x40 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1317 kvm_vm_ioctl_set_memory_region arch/x86/kvm/../../../virt/kvm/kvm_main.c:1329 [inline] kvm_vm_ioctl+0xbd4/0x1f80 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3610 kvm_vm_compat_ioctl+0x10b/0x200 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3804 __do_compat_sys_ioctl fs/ioctl.c:857 [inline] __se_compat_sys_ioctl fs/ioctl.c:808 [inline] __ia32_compat_sys_ioctl+0x1ce/0x220 fs/ioctl.c:808 do_syscall_32_irqs_on arch/x86/entry/common.c:337 [inline] do_fast_syscall_32+0x231/0xb27 arch/x86/entry/common.c:408 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 Freed by task 0: (stack is not available) The buggy address belongs to the object at ffff8880a8d81000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1128 bytes inside of 2048-byte region [ffff8880a8d81000, ffff8880a8d81800) The buggy address belongs to the page: page:ffffea0002a36040 refcount:1 mapcount:0 mapping:ffff8880aa400e00 index:0x0 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00025201c8 ffffea00026af988 ffff8880aa400e00 raw: 0000000000000000 ffff8880a8d81000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880a8d81300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff8880a8d81380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff8880a8d81400: 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc ^ ffff8880a8d81480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff8880a8d81500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================