Patchwork [Precise,Quantal,Raring,CVE-2013-1798] KVM: Fix bounds checking in ioapic indirect register reads (CVE-2013-1798)

login
register
mail settings
Submitter Luis Henriques
Date April 8, 2013, 1:44 p.m.
Message ID <1365428685-6308-4-git-send-email-luis.henriques@canonical.com>
Download mbox | patch
Permalink /patch/234779/
State New
Headers show

Comments

Luis Henriques - April 8, 2013, 1:44 p.m.
From: Andy Honig <ahonig@google.com>

CVE-2013-1798

BugLink: http://bugs.launchpad.net/bugs/1158262

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>
(cherry picked from commit a2c118bfab8bc6b8bb213abfc35201e441693d55)

Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 virt/kvm/ioapic.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Stefan Bader - April 9, 2013, 2:11 p.m.
Maybe just Thunderbird loosing its ordering, just here looked like the same
thread as cve-2013-1797...
Luis Henriques - April 9, 2013, 2:29 p.m.
On Tue, Apr 09, 2013 at 04:11:12PM +0200, Stefan Bader wrote:
> Maybe just Thunderbird loosing its ordering, just here looked like the same
> thread as cve-2013-1797...
> 

No, not thunderbird's fault -- it was me using git-send-email the wrong
way... Sorry about that.

Cheers,
--
Luis
Tim Gardner - April 9, 2013, 3:42 p.m.

Patch

diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index 26fd54d..fdb1faf 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -73,9 +73,12 @@  static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
 			u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
 			u64 redir_content;
 
-			ASSERT(redir_index < IOAPIC_NUM_PINS);
+			if (redir_index < IOAPIC_NUM_PINS)
+				redir_content =
+					ioapic->redirtbl[redir_index].bits;
+			else
+				redir_content = ~0ULL;
 
-			redir_content = ioapic->redirtbl[redir_index].bits;
 			result = (ioapic->ioregsel & 0x1) ?
 			    (redir_content >> 32) & 0xffffffff :
 			    redir_content & 0xffffffff;