Re: [PATCH] page_poison: plays nicely with KASAN

From: Andrey Ryabinin
Date: Fri Jan 11 2019 - 13:45:09 EST




On 1/8/19 1:36 AM, Qian Cai wrote:

>
> diff --git a/mm/page_poison.c b/mm/page_poison.c
> index f0c15e9017c0..e546b70e592a 100644
> --- a/mm/page_poison.c
> +++ b/mm/page_poison.c
> @@ -6,6 +6,7 @@
> #include <linux/page_ext.h>
> #include <linux/poison.h>
> #include <linux/ratelimit.h>
> +#include <linux/kasan.h>
>
> static bool want_page_poisoning __read_mostly;
>
> @@ -40,6 +41,7 @@ static void poison_page(struct page *page)
> {
> void *addr = kmap_atomic(page);
>
> + kasan_unpoison_shadow(addr, PAGE_SIZE);
> memset(addr, PAGE_POISON, PAGE_SIZE);

kasan_disable/enable_current() should be slightly more efficient for this case.

> kunmap_atomic(addr);
> }
>