Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10793525ybi; Thu, 25 Jul 2019 05:20:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSsz53yu3Y2C1+g4J2nun6AsK/jG+h6lULovBHS7TO0z2w21L2FvHP9Xr+FBKrXAiz81Gl X-Received: by 2002:a63:188:: with SMTP id 130mr84841406pgb.231.1564057244733; Thu, 25 Jul 2019 05:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564057244; cv=none; d=google.com; s=arc-20160816; b=tMafVybjdn3xhiUaHW994jfBlUKTirzjhK9+EoNC9uZIkzV1bYYSasVh1PGoQHpB8d Vax7B38C32odINU171wzHUi2O6B0TE0aaAKjIeSyhBrconKnuKx9akwREzzQ/UkrZqkU ojR4n+amYUme9u0WU1y+nfk5JWfXUSy7m7AOgquO5bX0ZGS2mxd0bn+jhIharBY9QAAl 0smESgzFaOjBHlHA9A284OhwO+WdcGbQpCInkqUpzFH4R0JAmYnfu2V5utFyG2ssX+D0 IDzQbOGVSyAbGu8bxq53+OqI+NEgEiTnrSIhmf7ChPlxjIavrlxQBEFeqopRsLGt7KIK /SOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=b7IVn3QJfKt3+nMdc8KrVJ5b6zOa0odG78W8Fu0x4nA=; b=wyFTWTo5ysRkNGUcEWAce4mK2gZepF8ZOo24anUwmQ4mimrN5zV7ngkg9SodLVb8tz pvwgr/x6xQP33gyxmSouuN0yvJjPXpMybols8BvmV2WeqD0uk7612lJ/tglGuezWUyGA gSHaVBhnBt7OKjGA7SI98FbD3sjf1xrRGBVg7/nKK2zrGKXBHft35Egp0fgjIKA946hB DvYm64P4adllYIlnr/OrjXSDhhevYKelAimJjQVcKJUnm99EDvCFgoFBo6+ZFC/TxmxK Pz8cC/4E88hgcEhEqzLAmJ9N3ltHSUrtAlVCDNO5A51ZnQlny1CfaPkh0PZiv/VaDL60 VjDw== 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 c64si16296041pje.9.2019.07.25.05.20.29; Thu, 25 Jul 2019 05:20:44 -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 S2387820AbfGYHQk (ORCPT + 99 others); Thu, 25 Jul 2019 03:16:40 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2721 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387776AbfGYHQj (ORCPT ); Thu, 25 Jul 2019 03:16:39 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 6D97166E45FB2AA639F1; Thu, 25 Jul 2019 15:16:37 +0800 (CST) Received: from [127.0.0.1] (10.177.96.203) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Thu, 25 Jul 2019 15:16:30 +0800 Subject: Re: [RFC PATCH 00/10] implement KASLR for powerpc/fsl_booke/32 To: , , , , , , , , CC: , , , , , References: <20190717080621.40424-1-yanaijie@huawei.com> From: Jason Yan Message-ID: Date: Thu, 25 Jul 2019 15:16:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: <20190717080621.40424-1-yanaijie@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.96.203] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, any comments? On 2019/7/17 16:06, Jason Yan wrote: > This series implements KASLR for powerpc/fsl_booke/32, as 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 <-----| > > kimage_vaddr > > We also check if we will overlap with some areas like the dtb area, the > initrd area or the crashkernel area. If we cannot find a proper area, > kaslr will be disabled and boot from the original kernel. > > Jason Yan (10): > powerpc: unify definition of M_IF_NEEDED > powerpc: move memstart_addr and kernstart_addr to init-common.c > powerpc: introduce kimage_vaddr to store the kernel base > powerpc/fsl_booke/32: introduce create_tlb_entry() helper > powerpc/fsl_booke/32: introduce reloc_kernel_entry() helper > powerpc/fsl_booke/32: implement KASLR infrastructure > powerpc/fsl_booke/32: randomize the kernel image offset > powerpc/fsl_booke/kaslr: clear the original kernel if randomized > powerpc/fsl_booke/kaslr: support nokaslr cmdline parameter > powerpc/fsl_booke/kaslr: dump out kernel offset information on panic > > arch/powerpc/Kconfig | 11 + > arch/powerpc/include/asm/nohash/mmu-book3e.h | 10 + > arch/powerpc/include/asm/page.h | 7 + > arch/powerpc/kernel/Makefile | 1 + > arch/powerpc/kernel/early_32.c | 2 +- > arch/powerpc/kernel/exceptions-64e.S | 10 - > arch/powerpc/kernel/fsl_booke_entry_mapping.S | 23 +- > arch/powerpc/kernel/head_fsl_booke.S | 61 ++- > arch/powerpc/kernel/kaslr_booke.c | 439 ++++++++++++++++++ > arch/powerpc/kernel/machine_kexec.c | 1 + > arch/powerpc/kernel/misc_64.S | 5 - > arch/powerpc/kernel/setup-common.c | 23 + > arch/powerpc/mm/init-common.c | 7 + > arch/powerpc/mm/init_32.c | 5 - > arch/powerpc/mm/init_64.c | 5 - > arch/powerpc/mm/mmu_decl.h | 10 + > arch/powerpc/mm/nohash/fsl_booke.c | 8 +- > 17 files changed, 580 insertions(+), 48 deletions(-) > create mode 100644 arch/powerpc/kernel/kaslr_booke.c >