From patchwork Tue May 29 04:38:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Yao X-Patchwork-Id: 10434723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3DAB1601E9 for ; Tue, 29 May 2018 09:59:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3054A286B9 for ; Tue, 29 May 2018 09:59:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 250EE286BD; Tue, 29 May 2018 09:59:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 50A1B286B9 for ; Tue, 29 May 2018 09:59:50 +0000 (UTC) Received: (qmail 32386 invoked by uid 550); 29 May 2018 09:59:37 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 19725 invoked from network); 29 May 2018 04:38:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=v7s8f9vVQ5rimv3fdudk6AP6e+92g40GBqgonb3dOwI=; b=OXxBIaWAxWMQvcl5WC2YvO9wRN5kDHiohsrVlk46pp88NCiRlwawEfqiBO8m+pMbdr szgm601v1Owxb+JdoNcAOyVSpV7S7QYk7aBjBm/RR+c46xkfgNIGyGqDVCz5kbdjUDs0 tm/NCH1JGJ2f7EsFOgGBgEUhE0ncZHJ2VtpwX6cyzqXN+qH+OG+reAOcBJDIFgw7iyfz QmDkIMgPH3TGggqHyukUEgyrZdCCPZXpjBHj3CCn+0Dp69fbSBY1eafl5EBvdp3x4gwF bsr2ELbcsXNCrwTeQUzmCdUj5UFnQBQoViu7sv2EpmXWW3qc6ILK7kV4OeQ2Qz5uKILI DniA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=v7s8f9vVQ5rimv3fdudk6AP6e+92g40GBqgonb3dOwI=; b=APAaaGvH+lzrsndrNWRvtuJRlGOm0Ya0BLpNcZfrlf7WZ8vitcSlMDPz+aAZthQ4DT 2pY2jE8oePjXpedvBbXXZZghdQibkosw3afPBlgQqenzL+n+p6br8w+Eunw/HrZVDoQl 1QxB8/FCuVNzr1SEyvLOtsjuAzyoIXcmc6FRZR52w9c1rfqSDRTGiqjv6T/UMO08McA4 85LwQApRgE0Elh9NtLPJDQNEzw1xUHxaN6B9C6AeGc70irREAMWBYZ7OyxyyFlxO32k9 VZ8qeFoGbh/E7VBCdg4MjcWn0YebF0QsoVaAe1x5Swf8xUsnZuktf+cIFVdgocegkWrL EL1g== X-Gm-Message-State: ALKqPwdbO20MfFx2WGNrcnkhxenK3dtuWjkNr3RTFKOoe96VD31lNPsW HXJ8k6XQ7hdlKW8v8WJRlwoIVw== X-Google-Smtp-Source: AB8JxZqmnCdOz27XY1Oxfj7NneqaBOpvHvwkWEMkyU0S9p1L5BewVR+AB/tBIPh3srCCQQL/3jqK6A== X-Received: by 2002:a17:902:868b:: with SMTP id g11-v6mr15763291plo.305.1527568694542; Mon, 28 May 2018 21:38:14 -0700 (PDT) From: YaoJun To: kernel-hardening@lists.openwall.com Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, jmorris@namei.org Subject: [PATCH 3/4] migrate swapper_pg_dir Date: Tue, 29 May 2018 12:38:08 +0800 Message-Id: <20180529043808.27896-1-yaojun8558363@gmail.com> X-Mailer: git-send-email 2.17.0 X-Virus-Scanned: ClamAV using ClamSMTP Because tramp_map_kernel/tramp_unmap_kernel macro update ttbr1 by add/sub offset, so we need to migrate both swapper_pg_dir and tramp_pg_dir. Before doing that, make tramp_pg_dir and swapper_pg_dir adjacent. --- arch/arm64/kernel/entry.S | 4 ++-- arch/arm64/kernel/vmlinux.lds.S | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index ec2ee720e33e..b35425feaf56 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -1004,7 +1004,7 @@ __ni_sys_trace: .macro tramp_map_kernel, tmp mrs \tmp, ttbr1_el1 - add \tmp, \tmp, #(PAGE_SIZE + RESERVED_TTBR0_SIZE) + add \tmp, \tmp, #(PAGE_SIZE) bic \tmp, \tmp, #USER_ASID_FLAG msr ttbr1_el1, \tmp #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003 @@ -1023,7 +1023,7 @@ alternative_else_nop_endif .macro tramp_unmap_kernel, tmp mrs \tmp, ttbr1_el1 - sub \tmp, \tmp, #(PAGE_SIZE + RESERVED_TTBR0_SIZE) + sub \tmp, \tmp, #(PAGE_SIZE) orr \tmp, \tmp, #USER_ASID_FLAG msr ttbr1_el1, \tmp /* diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 0221aca6493d..a094156e05a4 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -219,15 +219,15 @@ SECTIONS idmap_pg_dir = .; . += IDMAP_DIR_SIZE; -#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 - tramp_pg_dir = .; - . += PAGE_SIZE; -#endif - #ifdef CONFIG_ARM64_SW_TTBR0_PAN reserved_ttbr0 = .; . += RESERVED_TTBR0_SIZE; #endif + +#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 + tramp_pg_dir = .; + . += PAGE_SIZE; +#endif swapper_pg_dir = .; . += SWAPPER_DIR_SIZE; swapper_pg_end = .;