Received: by 10.223.148.5 with SMTP id 5csp6669917wrq; Wed, 17 Jan 2018 17:13:22 -0800 (PST) X-Google-Smtp-Source: ACJfBotroNM7B4CuSHreepm3l2T7pZGBPLB8NQfIeR8s0ztvyzqsbW12l1HwcBbJNZDr85E997Qb X-Received: by 10.98.41.2 with SMTP id p2mr38880301pfp.25.1516238002338; Wed, 17 Jan 2018 17:13:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516238002; cv=none; d=google.com; s=arc-20160816; b=q4gUV2ppeEi0rtkRN01cfhC80CENAv168XGfeVeHuvRjUToUC7H6NGEzepy6WVBMmy /1o46cJA+q3KkH4VYMBv+WRJHNmRzBPMcas+lMNQmE0EjiOitGjIMKqHuEGJw9jH300p qeBVnRACp7e/b1jKf2vkOu1A76tx1NH0BccBps1eFeZcqc8srKR0XQOpRm+AqyX3Nybo uKWQtj2NEhQQallJXtrAf/2zFXo4UDxLVxgEVXOTrIvWnJEJyKyGC7hUnm9lhEyBCfcT i21+MM00CoBQx2NGEyY9QMQYZicB3Y3XW0lb2Jf4xcDkf5DwFaSELFyBDIOL5YhUrFpp pUfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=f5IVKi8pQAuzb3FaXc77rtnMM6Yp9XFzrORepvpjYuY=; b=yGOlXG2ipuz2AuJaPW9WmoLoeTk4rgxlDC0cfhHY1HkpkWasWmwK161LMJ93urrXG+ 9BWJXFayrBKQIZbbQP6+E9DbGWeJNnpQRfz/10UIVd4jH63hqr/OdM2a0HUi2aOKq1gP 8heTuSnCMc5m7yKMcr/BZvCOX0XGykdlg4M9QJOLQ/E20oNPqZ0hLPr62HUHZnYrZsAH FjKwFJZC1R66lKo0tmo4nD1Fn0rqwt9q3putBAgXdYlhXZ2tAIM9iXvGbVccbccDK/UF TRAZxOGwpbtxnWgbdMDCNLVhsiXbLtuqplN5q8IrSdU9nIV6hYk9YNPoXKImG4LasE58 HIKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z75si5394942pfd.119.2018.01.17.17.13.08; Wed, 17 Jan 2018 17:13:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752446AbeARBMg (ORCPT + 99 others); Wed, 17 Jan 2018 20:12:36 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:16276 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750816AbeARBMf (ORCPT ); Wed, 17 Jan 2018 20:12:35 -0500 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="35426945" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 18 Jan 2018 09:12:34 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 65EA9480D736; Thu, 18 Jan 2018 09:12:33 +0800 (CST) Received: from localhost.localdomain (10.167.225.56) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 18 Jan 2018 09:12:37 +0800 Date: Thu, 18 Jan 2018 09:11:14 +0800 From: Chao Fan To: Luiz Capitulino CC: , , , , , , , , Subject: Re: [PATCH v7 0/5] x86/KASLR: Add parameter kaslr_mem=nn[KMG]@ss[KMG] Message-ID: <20180118011113.GA24593@localhost.localdomain> References: <20180117105351.12226-1-fanc.fnst@cn.fujitsu.com> <20180117123235.2276f2e7@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180117123235.2276f2e7@redhat.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Originating-IP: [10.167.225.56] X-yoursite-MailScanner-ID: 65EA9480D736.AA126 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: fanc.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 17, 2018 at 12:32:35PM -0500, Luiz Capitulino wrote: >On Wed, 17 Jan 2018 18:53:46 +0800 >Chao Fan wrote: > >> ***Background: >> People reported that kaslr may randomly chooses some positions >> which are located in movable memory regions. This will break memory >> hotplug feature. >> >> And also on kvm guest with 4GB meory, the good unfragmented 1GB could >> be occupied by randomized kernel. It will cause hugetlb failing to >> allocate 1GB page. While kernel with 'nokaslr' has not such issue. >> This causes regression. Please see the discussion mail: >> https://lkml.org/lkml/2018/1/4/236 >> >> ***Solutions: >> Introduce a new kernel parameter 'kaslr_mem=nn@ss' to let users to >> specify the memory regions where kernel can be allowed to randomize >> safely. > >I've tested this series with a 4GB KVM guest. With kaslr_mem=1G, I >got one 1GB page allocated 100% of the time in 85 boots. Without >kaslr_mem=, I got 3 failures in only 10 boots (that is, in 3 boots >I had no 1GB page allocated). > >So, this series solves the 1GB page problem for me. > Thanks for Luiz's test. Thanks, Chao Fan >> >> E.g if 'movable_node' is spedified, we can use 'kaslr_mem=nn@ss' to >> tell KASLR where we can put kernel safely. Then KASLR code can avoid >> those movable regions and only choose those immovable regions >> specified. >> >> For hugetlb case, users can always add 'kaslr_mem=1G' in kernel >> cmdline since the 0~1G is always fragmented region because of BIOS >> reserved area. Surely users can specify regions more precisely if >> they know system memory very well. >> >> *** Issues need be discussed >> There are several issues I am not quite sure, please help review and >> give suggestions: >> >> 1) Since there's already mem_avoid[] which stores the memory regions >> KASLR need avoid. For the regions KASLR can safely use, I name it as >> mem_usable[], not sure if it's appropriate. Or kaslr_mem[] directly? >> >> 2) In v6, I made 'kaslr_mem=' as a kernel parameter which users can use >> to specify memory regions where kenrel can be extracted safely by >> 'kaslr_mem=nn@ss', or regions where we need avoid to extract kernel by >> 'kaslr_mem=nn!ss'. While later I rethink about it, seems >> 'kaslr_mem=nn@ss' can satisfy the current requirement, there's no need >> to introduce the 'kaslr_mem=nn!ss'. So I just take that >> 'kaslr_mem=nn!ss' handling patch off, may add it later if anyone think >> it's necessary. Any suggestions? >> https://www.spinics.net/lists/kernel/msg2698457.html >> >> ***Test results: >> - I did some tests for the memory hotplug issues. I specify the memory >> region in one node, then I found every time the kernel will be >> extracted to the memory of this node. >> - Luiz said he will do some tests for the 1G huge page issue. >> >> ***History >> v6->v7: >> - Drop the unnecessary avoid part for now. >> - Add document for the new parameter. >> >> v5->v6: >> - Add the last patch to save the avoid memory regions. >> >> v4->v5: >> - Change the problem reported by LKP >> Follow Dou's suggestion: >> - Also return if match "movable_node" when parsing kernel commandline >> in handle_mem_filter without define CONFIG_MEMORY_HOTPLUG >> >> v3->v4: >> Follow Kees's suggestion: >> - Put the functions variables of immovable_mem to #ifdef >> CONFIG_MEMORY_HOTPLUG and change some code place >> - Change the name of "process_mem_region" to "slots_count" >> - Reanme the new function "process_immovable_mem" to "process_mem_region" >> Follow Baoquan's suggestion: >> - Fail KASLR if "movable_node" specified without "immovable_mem" >> - Ajust the code place of handling mem_region directely if no >> immovable_mem specified >> Follow Randy's suggestion: >> - Change the mistake and add detailed description for the document. >> >> v2->v3: >> Follow Baoquan He's suggestion: >> - Change names of several functions. >> - Add a new parameter "immovable_mem" instead of extending mvoable_node >> - Use the clamp to calculate the memory intersecting, which makes >> logical more clear. >> - Disable memory mirror if movable_node specified >> >> v1->v2: >> Follow Dou Liyang's suggestion: >> - Add the parse for movable_node=nn[KMG] without @ss[KMG] >> - Fix the bug for more than one "movable_node=" specified >> - Drop useless variables and use mem_vector region directely >> - Add more comments. >> >> Chao Fan (5): >> x86/KASLR: Add kaslr_mem=nn[KMG]@ss[KMG] >> x86/KASLR: Handle the memory regions specified in kaslr_mem >> x86/KASLR: Give a warning if movable_node specified without kaslr_mem= >> x86/KASLR: Skip memory mirror handling if movable_node specified >> document: add document for kaslr_mem >> >> Documentation/admin-guide/kernel-parameters.txt | 10 ++ >> arch/x86/boot/compressed/kaslr.c | 154 +++++++++++++++++++++--- >> 2 files changed, 150 insertions(+), 14 deletions(-) >> > > >