Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753313AbdGJFsT convert rfc822-to-8bit (ORCPT ); Mon, 10 Jul 2017 01:48:19 -0400 Received: from tyo161.gate.nec.co.jp ([114.179.232.161]:52320 "EHLO tyo161.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750847AbdGJFsR (ORCPT ); Mon, 10 Jul 2017 01:48:17 -0400 From: Naoya Horiguchi To: Matt Fleming CC: Baoquan He , 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 , "Ard Biesheuvel" 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/AIAAUCQAgARgMIA= Date: Mon, 10 Jul 2017 05:47:34 +0000 Message-ID: <20170710054733.GA22619@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> <20170707061123.GA32236@hori1.linux.bs1.fc.nec.co.jp> <20170707105814.GB9917@codeblueprint.co.uk> In-Reply-To: <20170707105814.GB9917@codeblueprint.co.uk> Accept-Language: en-US, ja-JP Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.128.101.5] 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: 1960 Lines: 44 On Fri, Jul 07, 2017 at 11:58:14AM +0100, Matt Fleming wrote: > On Fri, 07 Jul, at 06:11:24AM, Naoya Horiguchi wrote: > > 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. > > I disagree. The least surprising option would be to use the region > type that everyone (boot loader, kernel, firmware) agrees is free: > EFI_CONVENTIONAL_MEMORY. OK, I will do it.