From patchwork Fri Feb 10 17:16:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9567151 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 4203B601EA for ; Fri, 10 Feb 2017 17:17:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 328F827B81 for ; Fri, 10 Feb 2017 17:17:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2711327F9E; Fri, 10 Feb 2017 17:17:22 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 67ED527B81 for ; Fri, 10 Feb 2017 17:17:21 +0000 (UTC) Received: (qmail 7584 invoked by uid 550); 10 Feb 2017 17:17:12 -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 7352 invoked from network); 10 Feb 2017 17:17:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wiQZmp/MaGnOyxTPPd464RgFuP1FXDDsUMZB4HHrCRw=; b=ERXcbtE2qHmOCuyjWyrMDQdDfIRHVSSYO+Da3Dq+G1UTOd8YZqLqY2qRT/6jMtv5y7 B31UcQhPMSIxdrvMpKSoeO0pmiDsPUCEWy4Ppv0dI4BOgLDpYnn5hpYqjH4CNu8CYuo3 K2Du4fzKHaxs27Aq1WIc8q0R8B3IudUIEFEmA= 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:in-reply-to :references; bh=wiQZmp/MaGnOyxTPPd464RgFuP1FXDDsUMZB4HHrCRw=; b=hO/kM0mB+MnqARglubMH97HGE65EEHKKTYb4P5q30Ksh2QemJeWQPED8KsevGBUWs8 YroRnD+KPNdvgBb/GooQIssF6mrfRWoyALKBe79C3ZEmFBxzFYdcPzURko3sdIVrU8QX MKqL8kimUQ5xb0kEXTggRjg0IfeBISLnbgu9YGKPPpD7YMCRGcdp7xjPgCNfZH4hTv1w RkiFsAyy7cMP2UtTXAyde/rd3L15nEOS9qvAu1F8/CUl6gEyQstx5eXTN7/8PxWg8ApE QVFN8rx4r8zrUC8pTsgyC2NsoUX96yfsaPXxqbzIyzE+5JhgiB+Y57WnbVa2Prw2Cr8P MuQA== X-Gm-Message-State: AMke39l+uK3HtB4I/FBLvnB6UF3RFJjrIB4WtuZqmt2qW38LUn0I7sobPcEb77bvmp3+LXqv X-Received: by 10.28.131.72 with SMTP id f69mr9011272wmd.140.1486747019023; Fri, 10 Feb 2017 09:16:59 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, keescook@chromium.org, labbott@fedoraproject.org, james.morse@arm.com Cc: kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, christoffer.dall@linaro.org, kernel-hardening@lists.openwall.com, andre.przywara@arm.com, Ard Biesheuvel Date: Fri, 10 Feb 2017 17:16:44 +0000 Message-Id: <1486747005-15973-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486747005-15973-1-git-send-email-ard.biesheuvel@linaro.org> References: <1486747005-15973-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [kernel-hardening] [PATCH 3/4] arm64: mmu: map .text as read-only from the outset X-Virus-Scanned: ClamAV using ClamSMTP Now that alternatives patching code no longer relies on the primary mapping of .text being writable, we can remove the code that removes the writable permissions post-init time, and map it read-only from the outset. Signed-off-by: Ard Biesheuvel Reviewed-by: Kees Cook --- arch/arm64/mm/mmu.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index f4b045d1cc53..5b0dbb9156ce 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -442,9 +442,6 @@ void mark_rodata_ro(void) { unsigned long section_size; - section_size = (unsigned long)_etext - (unsigned long)_text; - create_mapping_late(__pa_symbol(_text), (unsigned long)_text, - section_size, PAGE_KERNEL_ROX); /* * mark .rodata as read only. Use __init_begin rather than __end_rodata * to cover NOTES and EXCEPTION_TABLE. @@ -487,7 +484,7 @@ static void __init map_kernel(pgd_t *pgd) { static struct vm_struct vmlinux_text, vmlinux_rodata, vmlinux_init, vmlinux_data; - map_kernel_segment(pgd, _text, _etext, PAGE_KERNEL_EXEC, &vmlinux_text); + map_kernel_segment(pgd, _text, _etext, PAGE_KERNEL_ROX, &vmlinux_text); map_kernel_segment(pgd, __start_rodata, __init_begin, PAGE_KERNEL, &vmlinux_rodata); map_kernel_segment(pgd, __init_begin, __init_end, PAGE_KERNEL_EXEC, &vmlinux_init);