[PATCH] i386: instead of poisoning .init zone, change protectionbits to force a fault

From: Eric Dumazet
Date: Sun Jan 29 2006 - 15:02:59 EST


Chasing some invalid accesses to .init zone, I found that free_init_pages() was properly freeing the pages but virtual was still usable.

A poisoning (memset(page, 0xcc, PAGE_SIZE)) was done but this is not reliable.

Applying this patch at least in mm is a good thing...

(After that we could map non possible cpu percpu data to the initial percpudata that is included in .init and discarded in free_initmem())

Signed-off-by: Eric Dumazet <dada1@xxxxxxxxxxxxx>

--- linux-2.6.16-rc1-mm3/arch/i386/mm/init.c 2006-01-25 10:17:24.000000000 +0100
+++ linux-2.6.16-rc1-mm3-ed/arch/i386/mm/init.c 2006-01-29 21:46:39.000000000 +0100
@@ -750,11 +750,12 @@
for (addr = begin; addr < end; addr += PAGE_SIZE) {
ClearPageReserved(virt_to_page(addr));
set_page_count(virt_to_page(addr), 1);
- memset((void *)addr, 0xcc, PAGE_SIZE);
+ change_page_attr(virt_to_page(addr), 1, __pgprot(0));
free_page(addr);
totalram_pages++;
}
printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
+ global_flush_tlb();
}

void free_initmem(void)