lguest: fix spurious BUG_ON() on invalid guest stack.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 31 Mar 2009 03:55:23 +0000 (21:55 -0600)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 30 Mar 2009 11:25:23 +0000 (21:55 +1030)
Impact: fix crash on misbehaving guest

gpte_addr() contains a BUG_ON(), insisting that the present flag is
set.  We need to return before we call it if that isn't the case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: stable@kernel.org
drivers/lguest/page_tables.c

index 576a8318221c9dfe47dc28a660565094c9ef7753..82ff484bd8c8e9629625a4ddf8d016484aab8055 100644 (file)
@@ -373,8 +373,10 @@ unsigned long guest_pa(struct lg_cpu *cpu, unsigned long vaddr)
        /* First step: get the top-level Guest page table entry. */
        gpgd = lgread(cpu, gpgd_addr(cpu, vaddr), pgd_t);
        /* Toplevel not present?  We can't map it in. */
-       if (!(pgd_flags(gpgd) & _PAGE_PRESENT))
+       if (!(pgd_flags(gpgd) & _PAGE_PRESENT)) {
                kill_guest(cpu, "Bad address %#lx", vaddr);
+               return -1UL;
+       }
 
        gpte = lgread(cpu, gpte_addr(gpgd, vaddr), pte_t);
        if (!(pte_flags(gpte) & _PAGE_PRESENT))