)]}' { "commit": "2f9b68f57c6278c322793a06063181deded0ad69", "tree": "f54c427ef98819dc005623641998a21bd6cfaafe", "parents": [ "7c236b816ef16c2969a88ced658dab667e9dd4ee" ], "author": { "name": "Vitaly Kuznetsov", "email": "vkuznets@redhat.com", "time": "Fri Aug 27 11:25:14 2021 +0200" }, "committer": { "name": "Paolo Bonzini", "email": "pbonzini@redhat.com", "time": "Wed Sep 22 10:33:14 2021 -0400" }, "message": "KVM: x86: Fix stack-out-of-bounds memory access from ioapic_write_indirect()\n\nKASAN reports the following issue:\n\n BUG: KASAN: stack-out-of-bounds in kvm_make_vcpus_request_mask+0x174/0x440 [kvm]\n Read of size 8 at addr ffffc9001364f638 by task qemu-kvm/4798\n\n CPU: 0 PID: 4798 Comm: qemu-kvm Tainted: G X --------- ---\n Hardware name: AMD Corporation DAYTONA_X/DAYTONA_X, BIOS RYM0081C 07/13/2020\n Call Trace:\n dump_stack+0xa5/0xe6\n print_address_description.constprop.0+0x18/0x130\n ? kvm_make_vcpus_request_mask+0x174/0x440 [kvm]\n __kasan_report.cold+0x7f/0x114\n ? kvm_make_vcpus_request_mask+0x174/0x440 [kvm]\n kasan_report+0x38/0x50\n kasan_check_range+0xf5/0x1d0\n kvm_make_vcpus_request_mask+0x174/0x440 [kvm]\n kvm_make_scan_ioapic_request_mask+0x84/0xc0 [kvm]\n ? kvm_arch_exit+0x110/0x110 [kvm]\n ? sched_clock+0x5/0x10\n ioapic_write_indirect+0x59f/0x9e0 [kvm]\n ? static_obj+0xc0/0xc0\n ? __lock_acquired+0x1d2/0x8c0\n ? kvm_ioapic_eoi_inject_work+0x120/0x120 [kvm]\n\nThe problem appears to be that \u0027vcpu_bitmap\u0027 is allocated as a single long\non stack and it should really be KVM_MAX_VCPUS long. We also seem to clear\nthe lower 16 bits of it with bitmap_zero() for no particular reason (my\nguess would be that \u0027bitmap\u0027 and \u0027vcpu_bitmap\u0027 variables in\nkvm_bitmap_or_dest_vcpus() caused the confusion: while the later is indeed\n16-bit long, the later should accommodate all possible vCPUs).\n\nFixes: 7ee30bc132c6 (\"KVM: x86: deliver KVM IOAPIC scan request to target vCPUs\")\nFixes: 9a2ae9f6b6bb (\"KVM: x86: Zero the IOAPIC scan request dest vCPUs bitmap\")\nReported-by: Dr. David Alan Gilbert \u003cdgilbert@redhat.com\u003e\nSigned-off-by: Vitaly Kuznetsov \u003cvkuznets@redhat.com\u003e\nReviewed-by: Maxim Levitsky \u003cmlevitsk@redhat.com\u003e\nReviewed-by: Sean Christopherson \u003cseanjc@google.com\u003e\nMessage-Id: \u003c20210827092516.1027264-7-vkuznets@redhat.com\u003e\nCc: stable@vger.kernel.org\nSigned-off-by: Paolo Bonzini \u003cpbonzini@redhat.com\u003e\n", "tree_diff": [ { "type": "modify", "old_id": "ff005fe738a4c1dae5e2b6b4648e1d5f34cfd24c", "old_mode": 33188, "old_path": "arch/x86/kvm/ioapic.c", "new_id": "8c065da73f8e541430770fd860653e4dee4a470c", "new_mode": 33188, "new_path": "arch/x86/kvm/ioapic.c" } ] }