Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753351AbdGGDIE (ORCPT ); Thu, 6 Jul 2017 23:08:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43058 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753296AbdGGDID (ORCPT ); Thu, 6 Jul 2017 23:08:03 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 85B2F4E4D2 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=bhe@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 85B2F4E4D2 Date: Fri, 7 Jul 2017 11:07:59 +0800 From: Baoquan He To: Matt Fleming Cc: Naoya Horiguchi , 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 Message-ID: <20170707030759.GA2343@x1> References: <20170706083106.GA21796@hori1.linux.bs1.fc.nec.co.jp> <20170706145727.GB3080@codeblueprint.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170706145727.GB3080@codeblueprint.co.uk> User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 07 Jul 2017 03:08:02 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1136 Lines: 28 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.