lkml.org 
[lkml]   [2015]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/1] x86_64: fix KASan shadow region page tables
On 05/29/2015 04:46 PM, Alexander Popov wrote:
> KASan shadow region page tables can't be filled statically because
> physical addresses in these page tables depend on phys_base.
> Initialize KASan shadow region page tables in kasan_early_init().
>
> Signed-off-by: Alexander Popov <alpopov@ptsecurity.com>
> ---

Thanks. Couple comments bellow, otherwise looks good.

>
> -extern unsigned char kasan_zero_page[PAGE_SIZE];
> +static pud_t kasan_zero_pud[PTRS_PER_PUD] __page_aligned_data;
> +static pmd_t kasan_zero_pmd[PTRS_PER_PMD] __page_aligned_data;
> +static pte_t kasan_zero_pte[PTRS_PER_PTE] __page_aligned_data;

It's better to keep these in bss.


> +/*
> + * This page used as early shadow. We don't use empty_zero_page
> + * at early stages, stack instrumentation could write some garbage
> + * to this page.
> + * Latter we reuse it as zero shadow for large ranges of memory
> + * that allowed to access, but not instrumented by kasan
> + * (vmalloc/vmemmap ...).
> + */
> +static unsigned char kasan_zero_page[PAGE_SIZE] __page_aligned_bss;
>
> static int __init map_range(struct range *range)
> {
> @@ -166,6 +178,23 @@ static struct notifier_block kasan_die_notifier = {
> };
> #endif
>
> +void __init kasan_early_init(void)
> +{
> + int i;
> + pteval_t pte_val = __pa_nodebug(kasan_zero_page) | _KERNPG_TABLE;


Should be __PAGE_KERNEL.
Yes, currently kasan's ptes have _KERNPG_TABLE flags, but that is wrong.


\
 
 \ /
  Last update: 2015-05-29 17:21    [W:0.032 / U:3.088 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site