Commit 13725c06 authored by Marios Pomonis's avatar Marios Pomonis Committed by Greg Kroah-Hartman

KVM: x86: Protect ioapic_read_indirect() from Spectre-v1/L1TF attacks

commit 8c86405f upstream.

This fixes a Spectre-v1/L1TF vulnerability in ioapic_read_indirect().
This function contains index computations based on the
(attacker-controlled) IOREGSEL register.

Fixes: a2c118bf ("KVM: Fix bounds checking in ioapic indirect register reads (CVE-2013-1798)")
Signed-off-by: default avatarNick Finco <nifi@google.com>
Signed-off-by: default avatarMarios Pomonis <pomonis@google.com>
Reviewed-by: default avatarAndrew Honig <ahonig@google.com>
Cc: stable@vger.kernel.org
Reviewed-by: default avatarJim Mattson <jmattson@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent eb08d0fe
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/nospec.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/current.h> #include <asm/current.h>
...@@ -73,13 +74,14 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic, ...@@ -73,13 +74,14 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
default: default:
{ {
u32 redir_index = (ioapic->ioregsel - 0x10) >> 1; u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
u64 redir_content; u64 redir_content = ~0ULL;
if (redir_index < IOAPIC_NUM_PINS) if (redir_index < IOAPIC_NUM_PINS) {
redir_content = u32 index = array_index_nospec(
ioapic->redirtbl[redir_index].bits; redir_index, IOAPIC_NUM_PINS);
else
redir_content = ~0ULL; redir_content = ioapic->redirtbl[index].bits;
}
result = (ioapic->ioregsel & 0x1) ? result = (ioapic->ioregsel & 0x1) ?
(redir_content >> 32) & 0xffffffff : (redir_content >> 32) & 0xffffffff :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment