Skip to contentSkip to conversation

mm, kasan: fix to call kasan_free_pages() after poisoning page

PATCH New [email protected] 1 participant 1 message May 20, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 49/162 mm, kasan: fix to call kasan_free_pages() after poisoning page

From: "seokhoon.yoon" <[email protected]>
Subject: mm, kasan: fix to call kasan_free_pages() after poisoning page

When CONFIG_PAGE_POISONING and CONFIG_KASAN is enabled, free_pages_prepare()'s codeflow is below.

1)kmemcheck_free_shadow() 2)kasan_free_pages()
- set shadow byte of page is freed 3)kernel_poison_pages()
3.1) check access to page is valid or not using kasan ---> error occur, kasan think it is invalid access 3.2) poison page
4)kernel_map_pages()

So kasan_free_pages() should be called after poisoning the page.

---

 mm/page_alloc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page_alloc.c renamed from mm/page_alloc.c~mm-kasan-fix-to-call-kasan_free_pages-after-poisoning-page +1 -1
diff -puN mm/page_alloc.c~mm-kasan-fix-to-call-kasan_free_pages-after-poisoning-page mm/page_alloc.c
@@ -993,7 +993,6 @@ static __always_inline bool free_pages_p
 
 	trace_mm_page_free(page, order);
 	kmemcheck_free_shadow(page, order);
-	kasan_free_pages(page, order);
 
 	/*
 	 * Check tail pages before head page information is cleared to
@@ -1035,6 +1034,7 @@ static __always_inline bool free_pages_p
 	arch_free_page(page, order);
 	kernel_poison_pages(page, 1 << order, 0);
 	kernel_map_pages(page, 1 << order, 0);
+	kasan_free_pages(page, order);
 
 	return true;
 }

_