From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935777AbdACUPW (ORCPT ); Tue, 3 Jan 2017 15:15:22 -0500 Received: from mga02.intel.com ([134.134.136.20]:10454 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934743AbdACUPO (ORCPT ); Tue, 3 Jan 2017 15:15:14 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,456,1477983600"; d="scan'208";a="209277852" Subject: Re: [PATCH] x86: fix kaslr and memmap collision To: Dan Williams , Baoquan He References: <147977413859.13657.2181994710415174471.stgit@djiang5-desk3.ch.intel.com> <20161122084754.GA25596@gmail.com> <20170103083137.GA15788@x1> Cc: Ingo Molnar , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , X86 ML , david , "linux-kernel@vger.kernel.org" , "linux-nvdimm@lists.01.org" , Kees Cook , dyoung@redhat.com From: Dave Jiang Message-ID: Date: Tue, 3 Jan 2017 13:15:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/03/2017 11:24 AM, Dan Williams wrote: > On Tue, Jan 3, 2017 at 12:31 AM, Baoquan He wrote: >> Hi Dan, >> >> On 11/22/16 at 09:26am, Dan Williams wrote: >>> [ replying for Dave since he's offline today and tomorrow ] >>> >>> On Tue, Nov 22, 2016 at 12:47 AM, Ingo Molnar wrote: >>>> >>>> * Dave Jiang wrote: >>>> >>>>> CONFIG_RANDOMIZE_BASE relocates the kernel to a random base address. >>>>> However it does not take into account the memmap= parameter passed in from >>>>> the kernel commandline. >>>> >>>> memmap= parameters are often used as a list. >>>> >>>>> [...] This results in the kernel sometimes being put in the middle of the user >>>>> memmap. [...] >>>> >>>> What does this mean? If memmap= is used to re-define the memory map then the >>>> kernel getting in the middle of a RAM area is what we want, isn't it? What we >>>> don't want is for the kernel to get into reserved areas, right? >>> >>> Right, this is about teaching kaslr to not land the kernel in newly >>> defined reserved regions that were not marked reserved in the initial >>> e820 map from platform firmware. >> >> If only tell kaslr to not land kernel in newly defined reserved regions, >> memory added by "memmap=nn[KMG]@ss[KMG]" should not be avoided since >> it's usable memory. Kernel randomized into this region is also what we >> want. Not sure if I understand it right. > > You're right, this is supposed to be for memmap=nn!ss cases which > defines reserved persistent memory ranges, not memmap=nn@ss which > defines usable memory. > > We need to fix mem_avoid_memmap() to only skip memmap= statements that > specify reserved memory. > I think nn@ss is the only one that we should skip over, otherwise everything else looks like should be avoided. I'll update.