From patchwork Thu May 31 10:31:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Yao X-Patchwork-Id: 10440643 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 0C848603B5 for ; Thu, 31 May 2018 10:31:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 002F929206 for ; Thu, 31 May 2018 10:31:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E913D29213; Thu, 31 May 2018 10:31:45 +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 3030129206 for ; Thu, 31 May 2018 10:31:45 +0000 (UTC) Received: (qmail 11990 invoked by uid 550); 31 May 2018 10:31:43 -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 Received: (qmail 11949 invoked from network); 31 May 2018 10:31:42 -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=NV16T1//EUiVbR39bLg1C7F+I+VkofUknipazDNm0Pk=; b=ObJcrdobH2EvfYykSdsgEAt7Gm9YcQjTmX3PL9bDHNUZ4nRyk8onDvtBE32ESO939R pGPoVQbhPRppcUTK1qLWyFte635PwtIV5Kmamy8isyYfs6GL7SIUrW7tYOmaKmXY3XMT jQ65Gf9um7QkFLdLp9+CfUoITByJg690zz8/P7S921nMlQool8iRwpw0X39Vyo/xWRnZ JnDd1VectkcFh9WtnVXk21hqQbgL+/8UrjzkKKyAqBa8b1/Ov+YPqna77o2UUfjT80Nj Dn0OH0sll0XGceW2kAoxKxlZ8SAGNwYSagv3plU9pymZ85DQJzO5dXvIo4vnZQx3JpPq S/iw== 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=NV16T1//EUiVbR39bLg1C7F+I+VkofUknipazDNm0Pk=; b=INpHM1/VutYgyjJfuRbMIOIk4dt5kwJyz1HiuIlBSAGalDbz9+Q2bttgO/7nsZ38lH JaK1vMSgWtsMq+WBrV/TuLyMTilhpVkJUrRg24QyBmhW2CvME3KaAfoK+R/ADvaYRYna 2sNbgLTOPqM9GiUlMVP7usPu0rVGpk+szkuzq4CcZHodBcLGEC1uE975IQmqj7aCwkko IgxB/fnDQMbpfx+ZLxwg6QsvkDXUxtr3rNrIG8/rWDy+Pc4ibh6SY6ZAHJongH14cqd0 v67ILgT4ovfhrCg/VCpQq9/JXedSR0BrC9qQfi55N8nmPD/Lgsa3fdwQ+I8mGP2yMSYm Aeug== X-Gm-Message-State: ALKqPwcHKagU/H9EeHRowLBEQFfmoQy/JlIjCtZfkkuQx8eMkyjklhgH cISH2k9BTc7ygsrWTdJHlMQ= X-Google-Smtp-Source: ADUXVKKf+izTxaehS2bLBvm07kaUrS67nC4eFk7WvVAGYEb6zxaaUiiErr38GgNeFjklewbPsob6Nw== X-Received: by 2002:a17:902:680c:: with SMTP id h12-v6mr6585171plk.113.1527762690699; Thu, 31 May 2018 03:31:30 -0700 (PDT) From: Jun Yao To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, ard.biesheuvel@linaro.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH v2 2/2] arm64/mm: make tramp_pg_dir read-only Date: Thu, 31 May 2018 18:31:22 +0800 Message-Id: <20180531103122.31793-1-yaojun8558363@gmail.com> X-Mailer: git-send-email 2.17.0 X-Virus-Scanned: ClamAV using ClamSMTP Make tramp_pg_dir read-only. Signed-off-by: Jun Yao --- arch/arm64/mm/mmu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index a675fb88914e..2c6e6433090c 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -542,6 +542,7 @@ static int __init map_entry_trampoline(void) { pgprot_t prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC; phys_addr_t pa_start = __pa_symbol(__entry_tramp_text_start); + int segment_size; /* The trampoline is always mapped and can therefore be global */ pgprot_val(prot) &= ~PTE_NG; @@ -551,6 +552,11 @@ static int __init map_entry_trampoline(void) __create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS, PAGE_SIZE, prot, pgd_pgtable_alloc, 0); + segment_size = __tramp_pgdir_segment_end - __tramp_pgdir_segment_start; + update_mapping_prot(__pa_symbol(__tramp_pgdir_segment_start), + (unsigned long)__tramp_pgdir_segment_start, + segment_size, PAGE_KERNEL_RO); + /* Map both the text and data into the kernel page table */ __set_fixmap(FIX_ENTRY_TRAMP_TEXT, pa_start, prot); if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {