Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4245778ybc; Fri, 15 Nov 2019 01:12:50 -0800 (PST) X-Google-Smtp-Source: APXvYqw2K+R17rFowtzvRlImzFlaaSvWJvK+NHF3/FN9uqtMBjWnLR4AZ1H2gvbN+2Y8ZrIjqUtR X-Received: by 2002:adf:e987:: with SMTP id h7mr13434276wrm.373.1573809170870; Fri, 15 Nov 2019 01:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573809170; cv=none; d=google.com; s=arc-20160816; b=H8WYMI+vgdOyC1tb0k65BEOa+jSW32sEafnhBYsxNc9U0dDX6+QuDIp7aBCud7zt8p nRT8E/HD9FWXKskHPwKmPEdsaojOS7C6vp9Kz96ajGlJSuzL1Q+CKDW3AtypM87pt9Z0 g9XBLPiwO6JQpihKILAOy2xMJcprNKgegMo3Bw8ztac8YAThDH907x6ZAvV8cKFzv4fA PdCt5SGBhKC+GpZF4/yr3wFoXhxR4NSSofPpcW7XPlTVm6P/liFe24OJj9xMZepxm8Z0 dahruFuaU1pw9W18XD54P78aPXiZqglt1o4m7OVuv6vWlcvnoRTXZT6dnMy2Pd1QF/fA NktA== 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=llpoXGo3h+fPtXCqZC0Xnzpz2YCPpV5QhsRndADrFutvPNaBi7iGvdCREbjGu/JQvU lRjZZI0I8lOzfyPaEhGTs13QyA9TmU/LqhSY0fnIKIZ6gPoeFOT174N3Mx9WDApCiiLV iUVoqw55TdQgvouK6rjA1zX0gfobyfuoTtlVbe5vtK3kv9aIOxxgU6tF2DgeHXe4RUjH FZoT5v5dljgma16svEqjcy07jvLs8Gk7VfYjnHsruhc8fL2ImE1OA3EnC7D4MxG8sth/ 5JgfTh07wXY2SNwAMcQuXhh827ZnMogWgHymDwtJTv3ylLo2+z4xi7aCvmpgXnlAM1qk 96zA== 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 d15si5963061edn.49.2019.11.15.01.12.24; Fri, 15 Nov 2019 01:12:50 -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 S1727419AbfKOJLL (ORCPT + 99 others); Fri, 15 Nov 2019 04:11:11 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:6677 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726196AbfKOJLK (ORCPT ); Fri, 15 Nov 2019 04:11:10 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 0F0E4234DB2A165C0FA1; Fri, 15 Nov 2019 17:11:08 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Fri, 15 Nov 2019 17:10:57 +0800 From: Jason Yan To: , , , , , , , , CC: , , Jason Yan Subject: [PATCH 6/6] powerpc/fsl_booke/kaslr: rename kaslr-booke32.rst to kaslr-booke.rst and add 64bit part Date: Fri, 15 Nov 2019 17:32:09 +0800 Message-ID: <20191115093209.26434-7-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20191115093209.26434-1-yanaijie@huawei.com> References: <20191115093209.26434-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