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.
Unified · Split
| @@ -74,9 +74,12 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic, · 73 unmodified lines | ||
| 74 | 74 | u32 redir_index = (ioapic->ioregsel - 0x10) >> 1; |
| 75 | 75 | u64 redir_content; |
| 76 | 76 | |
| 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; | |
| 78 | 82 | |
| 79 | − redir_content = ioapic->redirtbl[redir_index].bits; | |
| 80 | 83 | result = (ioapic->ioregsel & 0x1) ? |
| 81 | 84 | (redir_content >> 32) & 0xffffffff : |
| 82 | 85 | redir_content & 0xffffffff; |