lkml.org 
[lkml]   [2021]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] kfence: unpoison pool region before use
On Sat, Apr 3, 2021 at 7:13 AM Peter Collingbourne <pcc@google.com> wrote:
>
> If the memory region allocated by KFENCE had previously been poisoned,
> any validity checks done using kasan_byte_accessible() will fail. Fix
> it by unpoisoning the memory before using it as the pool region.

Which kasan_byte_accessible() call fails?

KASAN checks shouldn't be performed for KFENCE objects. We have a
number of is_kfence_address() checks in KASAN runtime, but maybe we're
missing some. Perhaps, we should even move those checks into the
high-level wrappers in include/linux/kasan.h.

> Link: https://linux-review.googlesource.com/id/I0af99e9f1c25eaf7e1ec295836b5d148d76940c5
> Signed-off-by: Peter Collingbourne <pcc@google.com>
> ---
> mm/kfence/core.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/mm/kfence/core.c b/mm/kfence/core.c
> index d53c91f881a4..bb22b0cf77aa 100644
> --- a/mm/kfence/core.c
> +++ b/mm/kfence/core.c
> @@ -633,13 +633,19 @@ static DECLARE_DELAYED_WORK(kfence_timer, toggle_allocation_gate);
>
> void __init kfence_alloc_pool(void)
> {
> + void *pool;
> +
> if (!kfence_sample_interval)
> return;
>
> - __kfence_pool = memblock_alloc(KFENCE_POOL_SIZE, PAGE_SIZE);
> -
> - if (!__kfence_pool)
> + pool = memblock_alloc(KFENCE_POOL_SIZE, PAGE_SIZE);
> + if (!pool) {
> pr_err("failed to allocate pool\n");
> + return;
> + }
> +
> + kasan_unpoison_range(pool, KFENCE_POOL_SIZE);
> + __kfence_pool = pool;
> }
>
> void __init kfence_init(void)
> --
> 2.31.0.208.g409f899ff0-goog
>

\
 
 \ /
  Last update: 2021-04-03 16:06    [W:0.083 / U:0.532 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site