Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp82483ybl; Fri, 9 Aug 2019 02:53:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgCXm0dQhaEpbxTPq8FOToXHlaevG1yuqd4dKoTd/GF/Po5QyuBZUnUiegY/33WuNSclG8 X-Received: by 2002:a17:902:30d:: with SMTP id 13mr8133979pld.284.1565344393218; Fri, 09 Aug 2019 02:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565344393; cv=none; d=google.com; s=arc-20160816; b=F6SCvrG8rTI/fQHIovFbN40gHY6pXqozdsWK/h+vwV3s36hBaXi80CVp/GvA+y1iK1 TAfXzB49bYAIx3SoiaTpUc2sYUw3LwcqTZCBnjrdUaEXyZ+HVCFo4fYf9Hw+qhzyrzan fCCTyiwV6IsWmsmaalWiUSTjniOhopANYXQFDc0MRQD8+rTtM1W081C+Ns812vk36dVH vBiDzUF3IMDg5bTdcyVJC8XxQXNayYWx34Iv71HHI+qygR3R8JNBGxwDGcUf3OhU0BZN pFd/j23kIMMbJm4fpZluSzAQysw8GFxp8F7fwD7iUQeAgleCF6Rz0xdgtI+DwxPw4Oox nJUA== 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=Xc/pSYTNcljnmi8134DzdAU91A/ShBwpL3BOskya8e8=; b=neQ4anKoezIvp40lQhXCklAVZzVktsEk5/qZkY1mhRAe9u7muSZMWLLfIi23pq8kB1 7n4FcwW/48jcTtr3/PLvgoPC238T3Mfqldahj3aGJJDlAVaTG6IE6nwSdgfrRgm1l5j6 KqQuIOKpb7uFB1zh4/o7hil7SjkqaLikXoskCmqUE4/t0/DXttQCsMJT29Fq1kt7IBJO kMMV2zwypPGzaYSmeqTEBk3JjkJtNkeeupUKHCi3CKZ4pSq8mjeJ6mfnkujdT76jYUko i3zynVa3nLWsKzy25l2ZZ355UKVZV7rdZxIX4xDc7m8dF5lJla0ACTcyRaSELDqB+uI6 S3NQ== 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 n9si52957311pgp.338.2019.08.09.02.52.57; Fri, 09 Aug 2019 02:53:13 -0700 (PDT) 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 S2406003AbfHIJwM (ORCPT + 99 others); Fri, 9 Aug 2019 05:52:12 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:34442 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2406224AbfHIJwL (ORCPT ); Fri, 9 Aug 2019 05:52:11 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 1FFCDCF690B9438D699B; Fri, 9 Aug 2019 17:52:08 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Fri, 9 Aug 2019 17:51:59 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v6 12/12] powerpc/fsl_booke/32: Document KASLR implementation Date: Fri, 9 Aug 2019 18:08:00 +0800 Message-ID: <20190809100800.5426-13-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190809100800.5426-1-yanaijie@huawei.com> References: <20190809100800.5426-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 Add document to explain how we implement KASLR for fsl_booke32. Signed-off-by: Jason Yan Cc: Diana Craciun Cc: Michael Ellerman Cc: Christophe Leroy Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Nicholas Piggin Cc: Kees Cook --- Documentation/powerpc/kaslr-booke32.rst | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/powerpc/kaslr-booke32.rst diff --git a/Documentation/powerpc/kaslr-booke32.rst b/Documentation/powerpc/kaslr-booke32.rst new file mode 100644 index 000000000000..8b259fdfdf03 --- /dev/null +++ b/Documentation/powerpc/kaslr-booke32.rst @@ -0,0 +1,42 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=========================== +KASLR for Freescale BookE32 +=========================== + +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 +attempts relying on knowledge of the location of kernel internals. + +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 +entries are not suitable to map the kernel directly in a randomized +region, so we chose to copy the kernel to a proper place and restart to +relocate. + +Entropy is derived from the banner and timer base, which will change every +build and boot. This not so much safe so additionally the bootloader may +pass entropy via the /chosen/kaslr-seed node in device tree. + +We will use the first 512M of the low memory to randomize the kernel +image. The memory will be split in 64M zones. We will use the lower 8 +bit of the entropy to decide the index of the 64M zone. Then we chose a +16K aligned offset inside the 64M zone to put the kernel in:: + + KERNELBASE + + |--> 64M <--| + | | + +---------------+ +----------------+---------------+ + | |....| |kernel| | | + +---------------+ +----------------+---------------+ + | | + |-----> 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