20220325132140.25650-2-vkuznets@xxxxxxxxxx> Message-ID: <166056796954136@xxxxxxxxx> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-stable: commit X-Patchwork-Hint: ignore This is a note to let you know that I've just added the patch titled KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: kvm-x86-check-lapic_in_kernel-before-attempting-to-set-a-synic-irq.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Mon Aug 15 02:52:08 PM CEST 2022 From: Stefan Ghinea <stefan.ghinea@xxxxxxxxxxxxx> Date: Wed, 10 Aug 2022 23:24:38 +0300 Subject: KVM: x86: Check lapic_in_kernel() before attempting to set a SynIC irq To: stable@xxxxxxxxxxxxxxx Cc: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Stefan Ghinea <stefan.ghinea@xxxxxxxxxxxxx> Message-ID: <20220810202439.32051-2-stefan.ghinea@xxxxxxxxxxxxx> From: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> commit 7ec37d1cbe17d8189d9562178d8b29167fe1c31a upstream When KVM_CAP_HYPERV_SYNIC{,2} is activated, KVM already checks for irqchip_in_kernel() so normally SynIC irqs should never be set. It is, however, possible for a misbehaving VMM to write to SYNIC/STIMER MSRs causing erroneous behavior. The immediate issue being fixed is that kvm_irq_delivery_to_apic() (kvm_irq_delivery_to_apic_fast()) crashes when called with 'irq.shorthand = APIC_DEST_SELF' and 'src == NULL'. Signed-off-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> Message-Id: <20220325132140.25650-2-vkuznets@xxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> Signed-off-by: Stefan Ghinea <stefan.ghinea@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- arch/x86/kvm/hyperv.c | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -428,6 +428,9 @@ static int synic_set_irq(struct kvm_vcpu struct kvm_lapic_irq irq; int ret, vector; + if (KVM_BUG_ON(!lapic_in_kernel(vcpu), vcpu->kvm)) + return -EINVAL; + if (sint >= ARRAY_SIZE(synic->sint)) return -EINVAL; Patches currently in stable-queue which might be from stefan.ghinea@xxxxxxxxxxxxx are queue-5.10/kvm-x86-avoid-theoretical-null-pointer-dereference-in-kvm_irq_delivery_to_apic_fast.patch queue-5.10/kvm-x86-check-lapic_in_kernel-before-attempting-to-set-a-synic-irq.patch queue-5.10/kvm-add-infrastructure-and-macro-to-mark-vm-as-bugged.patch