--- linux-2.4.14/mm/bootmem.c.orig Tue Sep 18 23:10:43 2001 +++ linux-2.4.14/mm/bootmem.c Wed Jan 9 17:21:32 2002 @@ -249,7 +249,11 @@ count++; ClearPageReserved(page); set_page_count(page, 1); +#ifdef CONFIG_ASO_MMFREE + __free_pages_init(page, 0); +#else __free_page(page); +#endif } } total += count; @@ -264,7 +268,11 @@ count++; ClearPageReserved(page); set_page_count(page, 1); - __free_page(page); +#ifdef CONFIG_ASO_MMFREE + __free_pages_init(page, 0); +#else + __free_page(page); +#endif } total += count; bdata->node_bootmem_map = NULL; --- linux-2.4.14/mm/page_alloc.c.orig Mon Nov 5 17:25:38 2001 +++ linux-2.4.14/mm/page_alloc.c Wed Jan 9 17:21:32 2002 @@ -62,8 +62,13 @@ * Hint: -mask = 1+~mask */ +#ifdef CONFIG_ASO_MMFREE +static void FASTCALL(__free_pages_ok2 (struct page *page, unsigned int order)); +static void __free_pages_ok2 (struct page *page, unsigned int order) +#else static void FASTCALL(__free_pages_ok (struct page *page, unsigned int order)); static void __free_pages_ok (struct page *page, unsigned int order) +#endif { unsigned long index, page_idx, mask, flags; free_area_t *area; @@ -147,6 +152,24 @@ current->nr_local_pages++; } +#ifdef CONFIG_ASO_MMFREE +static void __free_pages_ok(struct page *page, unsigned int order) +{ + if (!atomic_read(&page->count)) { + unsigned int page_cnt; + void *address = page_address(page); + + for (page_cnt = (1 << order); page_cnt; page_cnt--) { + clear_page(address); + + address = (void *) (((char *) address) + PAGE_SIZE); + } + } + + __free_pages_ok2(page, order); +} +#endif + #define MARK_USED(index, order, area) \ __change_bit((index) >> (1+(order)), (area)->map) @@ -568,6 +591,14 @@ show_swap_cache_info(); #endif } + +#ifdef CONFIG_ASO_MMFREE +void __free_pages_init(struct page *page, unsigned int order) +{ + if (!PageReserved(page) && put_page_testzero(page)) + __free_pages_ok2(page, order); +} +#endif void show_free_areas(void) { --- linux-2.4.14/mm/slab.c.orig Tue Sep 18 23:16:26 2001 +++ linux-2.4.14/mm/slab.c Wed Jan 9 17:21:32 2002 @@ -1346,6 +1346,20 @@ objp = kmem_cache_alloc_one(cachep); #endif local_irq_restore(save_flags); +#ifdef CONFIG_ASO_MMFREE + if (objp) { + unsigned int local_flags; + unsigned long ctor_flags; + + ctor_flags = SLAB_CTOR_CONSTRUCTOR; + local_flags = (flags & SLAB_LEVEL_MASK); + if (local_flags == SLAB_ATOMIC) + ctor_flags |= SLAB_CTOR_ATOMIC; + + if (cachep->ctor) + cachep->ctor(objp, cachep, ctor_flags); + } +#endif return objp; alloc_new_slab: #ifdef CONFIG_SMP @@ -1471,8 +1485,17 @@ */ static inline void __kmem_cache_free (kmem_cache_t *cachep, void* objp) { +#ifdef CONFIG_ASO_MMFREE #ifdef CONFIG_SMP cpucache_t *cc = cc_data(cachep); +#endif + memset(objp, 0, cachep->objsize); +#endif + +#ifdef CONFIG_SMP +#ifndef CONFIG_ASO_MMFREE + cpucache_t *cc = cc_data(cachep); +#endif CHECK_PAGE(virt_to_page(objp)); if (cc) { --- linux-2.4.14/arch/i386/config.in.orig Tue Jan 8 18:13:56 2002 +++ linux-2.4.14/arch/i386/config.in Wed Jan 9 16:31:15 2002 @@ -271,6 +271,9 @@ bool ' Use real mode APM BIOS call to power off' CONFIG_APM_REAL_MODE_POWER_OFF fi +comment 'Advanced security options' +bool ' Clear Memory when freeing' CONFIG_ASO_MMFREE + endmenu source drivers/mtd/Config.in