From: Rusty Russell Nasty bug where the host is the first to write a MAP_PRIVATE page: the guest still references the old one and won't see the write. This can happen with just the wrong data layouts for the initial setup hypercall (the other places in the code are always written guest-first). Signed-off-by: Rusty Russell Signed-off-by: Andrew Morton --- drivers/lguest/hypercalls.c | 6 ++++++ 1 files changed, 6 insertions(+) diff -puN drivers/lguest/hypercalls.c~lguest-the-host-code-fix-obscure-but-nasty-cow-bug drivers/lguest/hypercalls.c --- a/drivers/lguest/hypercalls.c~lguest-the-host-code-fix-obscure-but-nasty-cow-bug +++ a/drivers/lguest/hypercalls.c @@ -155,6 +155,12 @@ static void initialize(struct lguest *lg || put_user(4U*1024*1024, &lg->lguest_data->reserve_mem) || put_user(lg->guestid, &lg->lguest_data->guestid)) kill_guest(lg, "bad guest page %p", lg->lguest_data); + + /* This is the one case where the above accesses might have + * been the first write to a Guest page. This may have caused + * a copy-on-write fault, but the Guest might be referring to + * the old (read-only) page. */ + guest_pagetable_clear_all(lg); } /* Even if we go out to userspace and come back, we don't want to do _