Re: [PATCH v2] x86/mm/KASLR: EFI region is mistakenly included into KASLR VA space for randomization
From: Dave Young
Date: Fri Mar 24 2017 - 04:54:20 EST
On 03/24/17 at 09:08am, Ingo Molnar wrote:
>
> * Baoquan He <bhe@xxxxxxxxxx> wrote:
>
> > Currently KASLR is enabled on three regions: the direct mapping of physical
> > memory, vamlloc and vmemmap. However EFI region is also mistakenly included
> > for VA space randomization because of misusing EFI_VA_START macro and
> > assuming EFI_VA_START < EFI_VA_END.
> >
> > The EFI region is reserved for EFI runtime services virtual mapping which
> > should not be included in kaslr ranges. In Documentation/x86/x86_64/mm.txt,
> > we can see:
> > ffffffef00000000 - fffffffeffffffff (=64 GB) EFI region mapping space
> > EFI use the space from -4G to -64G thus EFI_VA_START > EFI_VA_END,
> > Here EFI_VA_START = -4G, and EFI_VA_END = -64G.
> >
> > Changing EFI_VA_START to EFI_VA_END in mm/kaslr.c fixes this problem.
> >
> > Cc: <stable@xxxxxxxxxxxxxxx> #4.8+
> > Signed-off-by: Baoquan He <bhe@xxxxxxxxxx>
> > Acked-by: Dave Young <dyoung@xxxxxxxxxx>
> > Reviewed-by: Bhupesh Sharma <bhsharma@xxxxxxxxxx>
> > Acked-by: Thomas Garnier <thgarnie@xxxxxxxxxx>
> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> > Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> > Cc: "H. Peter Anvin" <hpa@xxxxxxxxx>
> > Cc: x86@xxxxxxxxxx
> > Cc: linux-efi@xxxxxxxxxxxxxxx
> > Cc: Thomas Garnier <thgarnie@xxxxxxxxxx>
> > Cc: Kees Cook <keescook@xxxxxxxxxxxx>
> > Cc: Borislav Petkov <bp@xxxxxxxxx>
> > Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> > Cc: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>
> > Cc: Dave Young <dyoung@xxxxxxxxxx>
> > Cc: Bhupesh Sharma <bhsharma@xxxxxxxxxx>
>
> So I applied this kexec fix and extended the changelog to clearly show why this
> fix matters in practice.
>
> Also, to make sure I understood it correctly: these addresses are all dynamic on
> 64-bit kernels, i.e. we are establishing and then tearing down these page tables
> around EFI calls, and they are 'normally' not present at all, right?
Ingo, if I understand the question right "these addresses" means EFI va addresses
then it is right, EFI switch to its own page tables, so they are not
present in kernel page tables.
>
> Thanks,
>
> Ingo