Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1004832ybv; Wed, 5 Feb 2020 19:01:34 -0800 (PST) X-Google-Smtp-Source: APXvYqz/jqlcQ5qgALKWHd9P6V16Jg4b9Yhbw5W7cnBTlpUdQJZGJ3204zLAt3xo5bES3pZu1z/h X-Received: by 2002:a9d:53c2:: with SMTP id i2mr27111466oth.43.1580958093915; Wed, 05 Feb 2020 19:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580958093; cv=none; d=google.com; s=arc-20160816; b=qP4M4XY0gd5sIphtqwiGHqLuRS4pCY499q8ss94HEVLP/IFHNNsDKsto/MQzWsafcx O6qLGEgBuGKUxfcIH/7spHO59ZCoR/YrcPyrhDMZSdnizRS1n9ZeOsZL7Wre0DS27OpU XNc5+XXafpHy0/EmJWg//C508M0nXQRS7vW3v7NxP7FA0MgftnriUFnfqE7cQMUk1HBk UDtqoyV3Fk7vqwRal1UFGMDj1j0gQ8z0g0O6+6wSfXhourH0G2p+nSLmWlyMUS/Ewqht vomZKv4RkoLABIRVkTZ6GLTSPG16mQ/DDv5wy91Yn0KPza4kzqtPcdF6eFXHGqx+czoD MLGw== 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=bHTTK5BYMFftTSoW95j78fO3wuM/BBwly2/OA5JdTZkj4UZrZ5Jhz9ncYUs8ThKLMy jwwGKIlwFxJi7byEVQ4GinQswK8x46zo+b5OFRrvHJMDy9guc57i0+1KnnoONYf1eCzX 6GlaWlBZBoJqQxOxG6ax9CmwHGkNW9kqsDHd+C4TcCRgYm+RttMtLtFJX28MJ+0xuuog 4SKu+GFyBtxsOwxo4tVFPsSXELi08cGJzYNBx258x/6Sk9Ssq+bPJwA6IbMfiJvySbPX t4Dd+s0YnQp0oapV4ow30CDYZTnROACbX8rIA5iovco9v8ej9FdRfoZvr8IdI/nRirMb srUA== 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 w7si1147980otq.250.2020.02.05.19.01.21; Wed, 05 Feb 2020 19:01:33 -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 S1727841AbgBFC7t (ORCPT + 99 others); Wed, 5 Feb 2020 21:59:49 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:10157 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727806AbgBFC7q (ORCPT ); Wed, 5 Feb 2020 21:59:46 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 3D61C27A59F3BC42EF3F; Thu, 6 Feb 2020 10:59:40 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Thu, 6 Feb 2020 10:59:30 +0800 From: Jason Yan To: , , , , , , , , , CC: , , Jason Yan Subject: [PATCH v3 6/6] powerpc/fsl_booke/kaslr: rename kaslr-booke32.rst to kaslr-booke.rst and add 64bit part Date: Thu, 6 Feb 2020 10:58:25 +0800 Message-ID: <20200206025825.22934-7-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200206025825.22934-1-yanaijie@huawei.com> References: <20200206025825.22934-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