Permalink
Browse files

Erase memory pages as soon as they are freed to prevent new processes…

… getting old information (franciscofranco)
  • Loading branch information...
1 parent c88688e commit 3a9f10b82d9a5b6dc54ceab4d7edb60c5a7f19e6 @DJNoXD committed Apr 7, 2012
Showing with 19 additions and 0 deletions.
  1. +1 −0 arch/arm/include/asm/kmap_types.h
  2. +12 −0 include/linux/highmem.h
  3. +6 −0 mm/page_alloc.c
@@ -21,6 +21,7 @@ enum km_type {
KM_L1_CACHE,
KM_L2_CACHE,
KM_KDB,
+ KM_CLEARPAGE,
KM_TYPE_NR
};
View
@@ -143,6 +143,18 @@ static inline void clear_highpage(struct page *page)
kunmap_atomic(kaddr, KM_USER0);
}
+static inline void sanitize_highpage(struct page *page)
+{
+ void *kaddr;
+ unsigned long flags;
+
+ local_irq_save(flags);
+ kaddr = kmap_atomic(page, KM_CLEARPAGE);
+ clear_page(kaddr);
+ kunmap_atomic(kaddr, KM_CLEARPAGE);
+ local_irq_restore(flags);
+}
+
static inline void zero_user_segments(struct page *page,
unsigned start1, unsigned end1,
unsigned start2, unsigned end2)
View
@@ -648,6 +648,8 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
int i;
int bad = 0;
+ unsigned long index = 1UL << order;
+
trace_mm_page_free_direct(page, order);
kmemcheck_free_shadow(page, order);
@@ -666,6 +668,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
debug_check_no_obj_freed(page_address(page),
PAGE_SIZE << order);
}
+
+ for (; index; --index)
+ sanitize_highpage(page + index - 1);
+
arch_free_page(page, order);
kernel_map_pages(page, 1 << order, 0);

0 comments on commit 3a9f10b

Please sign in to comment.