Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934874AbdCXIyN (ORCPT ); Fri, 24 Mar 2017 04:54:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45428 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753080AbdCXIyG (ORCPT ); Fri, 24 Mar 2017 04:54:06 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BAB92342C54 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dyoung@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BAB92342C54 Date: Fri, 24 Mar 2017 16:53:55 +0800 From: Dave Young To: Ingo Molnar Cc: Baoquan He , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-efi@vger.kernel.org, Thomas Garnier , Kees Cook , Borislav Petkov , Andrew Morton , Masahiro Yamada , Bhupesh Sharma Subject: Re: [PATCH v2] x86/mm/KASLR: EFI region is mistakenly included into KASLR VA space for randomization Message-ID: <20170324085355.GB6807@dhcp-128-65.nay.redhat.com> References: <1490331592-31860-1-git-send-email-bhe@redhat.com> <20170324080833.GA15200@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170324080833.GA15200@gmail.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 24 Mar 2017 08:54:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2121 Lines: 51 On 03/24/17 at 09:08am, Ingo Molnar wrote: > > * Baoquan He 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: #4.8+ > > Signed-off-by: Baoquan He > > Acked-by: Dave Young > > Reviewed-by: Bhupesh Sharma > > Acked-by: Thomas Garnier > > Cc: Thomas Gleixner > > Cc: Ingo Molnar > > Cc: "H. Peter Anvin" > > Cc: x86@kernel.org > > Cc: linux-efi@vger.kernel.org > > Cc: Thomas Garnier > > Cc: Kees Cook > > Cc: Borislav Petkov > > Cc: Andrew Morton > > Cc: Masahiro Yamada > > Cc: Dave Young > > Cc: Bhupesh Sharma > > 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