]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
lguest: Revert 1ce70c4fac3c3954bd48c035f448793867592bc0, fix real problem.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 11 Mar 2008 14:35:57 +0000 (09:35 -0500)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 10 Mar 2008 22:35:58 +0000 (09:35 +1100)
Ahmed managed to crash the Host in release_pgd(), which cannot be a Guest
bug, and indeed it wasn't.

The bug was that handing a 0 as the address of the toplevel page table
being manipulated can cause the lookup code in find_pgdir() to return
an uninitialized cache entry (we shadow up to 4 top level page tables
for each Guest).

Commit 37cc8d7f963ba2deec29c9b68716944516a3244f introduced this
behaviour in the Guest, uncovering the bug.

The patch which he submitted (which removed the /4 from the index
calculation) simply ensured that these high-indexed entries hit the
early exit path of guest_set_pmd().  But you get lots of segfaults in
guest userspace as the PMDs aren't being updated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
arch/x86/lguest/boot.c
drivers/lguest/page_tables.c

index 9c27c104d83cbe9b623639564da116e8b32637b1..a104c532ff706cb9845140421371fc208a90605b 100644 (file)
@@ -480,7 +480,7 @@ static void lguest_set_pmd(pmd_t *pmdp, pmd_t pmdval)
 {
        *pmdp = pmdval;
        lazy_hcall(LHCALL_SET_PMD, __pa(pmdp)&PAGE_MASK,
-                  (__pa(pmdp)&(PAGE_SIZE-1)), 0);
+                  (__pa(pmdp)&(PAGE_SIZE-1))/4, 0);
 }
 
 /* There are a couple of legacy places where the kernel sets a PTE, but we
index 275f23c2deb49ff302e836abfb4eb14e26395a06..a7f64a9d67e009437b30e5007a208c25863be392 100644 (file)
@@ -391,7 +391,7 @@ static unsigned int find_pgdir(struct lguest *lg, unsigned long pgtable)
 {
        unsigned int i;
        for (i = 0; i < ARRAY_SIZE(lg->pgdirs); i++)
-               if (lg->pgdirs[i].gpgdir == pgtable)
+               if (lg->pgdirs[i].pgdir && lg->pgdirs[i].gpgdir == pgtable)
                        break;
        return i;
 }