Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752092AbdGGGNU convert rfc822-to-8bit (ORCPT ); Fri, 7 Jul 2017 02:13:20 -0400 Received: from tyo162.gate.nec.co.jp ([114.179.232.162]:48596 "EHLO tyo162.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750886AbdGGGNT (ORCPT ); Fri, 7 Jul 2017 02:13:19 -0400 From: Naoya Horiguchi To: Baoquan He CC: Matt Fleming , Kees Cook , LKML , "x86@kernel.org" , Thomas Gleixner , "H. Peter Anvin" , Ingo Molnar , "izumi.taku@jp.fujitsu.com" , Thomas Garnier , "fanc.fnst@cn.fujitsu.com" , Junichi Nomura Subject: Re: [PATCH] x86/boot/KASLR: exclude EFI_BOOT_SERVICES_{CODE|DATA} from KASLR's choice Thread-Topic: [PATCH] x86/boot/KASLR: exclude EFI_BOOT_SERVICES_{CODE|DATA} from KASLR's choice Thread-Index: AQHS9jI2mWWdXsD8kkSmPgVylBsaHqJGTRmAgADMHICAADM/AA== Date: Fri, 7 Jul 2017 06:11:24 +0000 Message-ID: <20170707061123.GA32236@hori1.linux.bs1.fc.nec.co.jp> References: <20170706083106.GA21796@hori1.linux.bs1.fc.nec.co.jp> <20170706145727.GB3080@codeblueprint.co.uk> <20170707030759.GA2343@x1> In-Reply-To: <20170707030759.GA2343@x1> Accept-Language: en-US, ja-JP Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.128.101.16] Content-Type: text/plain; charset="iso-2022-jp" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-TM-AS-MML: disable Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1536 Lines: 39 On Fri, Jul 07, 2017 at 11:07:59AM +0800, Baoquan He wrote: > On 07/06/17 at 03:57pm, Matt Fleming wrote: > > On Thu, 06 Jul, at 08:31:07AM, Naoya Horiguchi wrote: > > > + for (i = 0; i < nr_desc; i++) { > > > + md = (efi_memory_desc_t *)(pmap + (i * e->efi_memdesc_size)); > > > + > > > + /* > > > + * EFI_BOOT_SERVICES_{CODE|DATA} are avoided because boot > > > + * services regions could be accessed after ExitBootServices() > > > + * due to the workaround for buggy firmware. > > > + */ > > > + if (!(md->type == EFI_LOADER_CODE || > > > + md->type == EFI_LOADER_DATA || > > > + md->type == EFI_CONVENTIONAL_MEMORY)) > > > + continue; > > > > Wouldn't it make more sense to *only* use EFI_CONVENTIONAL_MEMORY? > > > > You can't re-use EFI_LOADER_* regions because the kaslr code is run so > > early in boot that you've no idea if data the kernel will need is in > > those EFI_LOADER_* regions. > > > > For example, we pass struct setup_data objects inside of > > EFI_LOADER_DATA regions. > > It doesn't matter because we have tried to avoid those memory setup_data > resides in in mem_avoid_overlap(). Here discarding EFI_LOADER_* could > discard the whole regions while setup_data could occupy small part of > them. Hi Matt, Baoquan, I added these three checks to accept any regions corresponding to E820_TYPE_RAM except EFI_BOOT_SERVICES_*, just thinking of that it's minimum surprising. Baoquan gave a good justification on that, so I'll leave it as-is in next version. Thanks, Naoya Horiguchi