Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp176766ybv; Tue, 4 Feb 2020 18:59:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxayK/0bZRwoSK7Qq5Cn/ztRVw3YWDL171Pu4fd43rufyyO1kSMeE2Io66H3NogJzNHiF9e X-Received: by 2002:a05:6808:5d0:: with SMTP id d16mr1484174oij.45.1580871589761; Tue, 04 Feb 2020 18:59:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580871589; cv=none; d=google.com; s=arc-20160816; b=lFWfY6Ryu6RchIhXEXYHFicGfp46LWpGDb+PVEE9MWo/D9qst6KFddWP75cF2Xsm6Q D7tthSr7o/htx7Tx89jM8OId92x+f/kCEMqtS/ANVeaCfZErjwbkh+ph4wx2SE+sAenC luefjt/QcFbDUyRf3x/AlwqquYSojmfbBf/zSIJlAfigNNjt6Fvvzbz/ETePLBvBD7hx 2kPExbzpKS5cLL3MT+v2ZJMBN+Q3AfsGAbhXFoIQi0ZeaxmFYMUQQ1uEY9Y+JpNca+AN +IbY8gkece9vhFRjuody8s+J5zRzd99kUPciaJjTKUpywLzAqOK2+R//x6i06m++xnec gqmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=rNQ6dzdbhJ4nrwJI0X0/bv2rX/esvioz5LhtCbkiEdU=; b=HjJT1Wk1SM4kfu/Hjo7sgqCqGi9t1BZdiumtt9RmvllLPgwX+amPFCWGmcG9Abej+B +EgXnd9iYAo2mVndvOxSOJJuOJmQIX6g1WCfili8eQmWKlAv/klZY4WKjRuBuVwdnUF6 FwGFiKMV1C7xIOJyLpxeNUpWPvRFFE6rFL5vUjRdrpppuiCn6URSBXVIS6TJ5gOBLQuJ 2Qu296/LJPy3zRaN4yACP3fx8v2dQ9EeFugR95TTHBNJmS8TAb0ptoGjPR3F8yndK3G2 nwNNYrSfH9aPZSd6Ia/iQ779ulLgZ9PN7oRFjkm9OG028U2URWcNgt7VlQWgnZkK8ysh q8Bg== 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 r66si6693727oie.255.2020.02.04.18.59.32; Tue, 04 Feb 2020 18:59:49 -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 S1727981AbgBEC5T (ORCPT + 99 others); Tue, 4 Feb 2020 21:57:19 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:42074 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727855AbgBEC5T (ORCPT ); Tue, 4 Feb 2020 21:57:19 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A41588CE0A3BFBCBC63E; Wed, 5 Feb 2020 10:56:41 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Wed, 5 Feb 2020 10:56:32 +0800 From: Jason Yan To: , , , , , , , , , CC: , , Jason Yan Subject: [PATCH v2 6/6] powerpc/fsl_booke/kaslr: rename kaslr-booke32.rst to kaslr-booke.rst and add 64bit part Date: Wed, 5 Feb 2020 10:55:27 +0800 Message-ID: <20200205025527.28640-7-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200205025527.28640-1-yanaijie@huawei.com> References: <20200205025527.28640-1-yanaijie@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now we support both 32 and 64 bit KASLR for fsl booke. Add document for 64 bit part and rename kaslr-booke32.rst to kaslr-booke.rst. Signed-off-by: Jason Yan Cc: Scott Wood Cc: Diana Craciun Cc: Michael Ellerman Cc: Christophe Leroy Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Nicholas Piggin Cc: Kees Cook --- .../{kaslr-booke32.rst => kaslr-booke.rst} | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) rename Documentation/powerpc/{kaslr-booke32.rst => kaslr-booke.rst} (59%) diff --git a/Documentation/powerpc/kaslr-booke32.rst b/Documentation/powerpc/kaslr-booke.rst similarity index 59% rename from Documentation/powerpc/kaslr-booke32.rst rename to Documentation/powerpc/kaslr-booke.rst index 8b259fdfdf03..42121fed8249 100644 --- a/Documentation/powerpc/kaslr-booke32.rst +++ b/Documentation/powerpc/kaslr-booke.rst @@ -1,15 +1,18 @@ .. SPDX-License-Identifier: GPL-2.0 -=========================== -KASLR for Freescale BookE32 -=========================== +========================= +KASLR for Freescale BookE +========================= The word KASLR stands for Kernel Address Space Layout Randomization. This document tries to explain the implementation of the KASLR for -Freescale BookE32. KASLR is a security feature that deters exploit +Freescale BookE. KASLR is a security feature that deters exploit attempts relying on knowledge of the location of kernel internals. +KASLR for Freescale BookE32 +------------------------- + Since CONFIG_RELOCATABLE has already supported, what we need to do is map or copy kernel to a proper place and relocate. Freescale Book-E parts expect lowmem to be mapped by fixed TLB entries(TLB1). The TLB1 @@ -38,5 +41,29 @@ bit of the entropy to decide the index of the 64M zone. Then we chose a kernstart_virt_addr + +KASLR for Freescale BookE64 +--------------------------- + +The implementation for Freescale BookE64 is similar as BookE32. One +difference is that Freescale BookE64 set up a TLB mapping of 1G during +booting. Another difference is that ppc64 needs the kernel to be +64K-aligned. So we can randomize the kernel in this 1G mapping and make +it 64K-aligned. This can save some code to creat another TLB map at early +boot. The disadvantage is that we only have about 1G/64K = 16384 slots to +put the kernel in:: + + KERNELBASE + + 64K |--> kernel <--| + | | | + +--+--+--+ +--+--+--+--+--+--+--+--+--+ +--+--+ + | | | |....| | | | | | | | | |....| | | + +--+--+--+ +--+--+--+--+--+--+--+--+--+ +--+--+ + | | 1G + |-----> offset <-----| + + kernstart_virt_addr + To enable KASLR, set CONFIG_RANDOMIZE_BASE = y. If KASLR is enable and you want to disable it at runtime, add "nokaslr" to the kernel cmdline. -- 2.17.2