Skip to content

Commit a2c118b

Browse files
Andy Honigmatosatti
authored andcommitted
KVM: Fix bounds checking in ioapic indirect register reads (CVE-2013-1798)
If the guest specifies a IOAPIC_REG_SELECT with an invalid value and follows that with a read of the IOAPIC_REG_WINDOW KVM does not properly validate that request. ioapic_read_indirect contains an ASSERT(redir_index < IOAPIC_NUM_PINS), but the ASSERT has no effect in non-debug builds. In recent kernels this allows a guest to cause a kernel oops by reading invalid memory. In older kernels (pre-3.3) this allows a guest to read from large ranges of host memory. Tested: tested against apic unit tests. Signed-off-by: Andrew Honig <ahonig@google.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
1 parent 0b79459 commit a2c118b

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎virt/kvm/ioapic.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,12 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
7474
u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
7575
u64 redir_content;
7676

77-
ASSERT(redir_index < IOAPIC_NUM_PINS);
77+
if (redir_index < IOAPIC_NUM_PINS)
78+
redir_content =
79+
ioapic->redirtbl[redir_index].bits;
80+
else
81+
redir_content = ~0ULL;
7882

79-
redir_content = ioapic->redirtbl[redir_index].bits;
8083
result = (ioapic->ioregsel & 0x1) ?
8184
(redir_content >> 32) & 0xffffffff :
8285
redir_content & 0xffffffff;

0 commit comments

Comments
 (0)