From patchwork Sat Feb 11 20:23:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9568153 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 749836043D for ; Sat, 11 Feb 2017 20:24:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65552284F6 for ; Sat, 11 Feb 2017 20:24:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 59BED28567; Sat, 11 Feb 2017 20:24:27 +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 6E17A284F6 for ; Sat, 11 Feb 2017 20:24:26 +0000 (UTC) Received: (qmail 21719 invoked by uid 550); 11 Feb 2017 20:24:24 -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 20073 invoked from network); 11 Feb 2017 20:24:18 -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=+Mv+7/SjXbePgllzG1mbQKn+e7SUpStfeaPEJDHFldg=; b=QRofD+SfvaA0ovYOgiFIjn/UwAaacR+6B3wralwBwn4BMZszgLK9BPOCN27EKwQieD xP3AOpd7uZKr2wIl7fp+Vuy+7Ku3GDc15V1+SyCAqBh4UCXBvU5VpuanUgrrF2yV+Mwz nfk6arkKIn3nFDlV3hEagFPg7qS2CrI/XXbv0= 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=+Mv+7/SjXbePgllzG1mbQKn+e7SUpStfeaPEJDHFldg=; b=VVqlQqi4LMZvgNzOD6EC4+r1DtycbL/M6+j7SdJ3yZZ2HL1PIPO+V3LQF4nstSD8In 61KBjTRoaMBFaOTWGXQWGHPWLOgiHqM+icTT8qoG9BddY2548g21ZtAuasng4RxgHhPS X0nH/NTIk/f/Poi+0GdJhAgkj2SCQGRKUzgaNySh9nczF01Lmkjzefxl6bZPur2pNCtW gPcYiX3aeNlUuGGWB+5Dm8WAZmHgAfugu5TNHl8qQ/dMWLxfdkRwPaookuQ+5Ygv4iPJ uMib+yKwR5E2AASOxJvx61aQCV2DCxpVeSzYbxtM8gIhuDt6LqYjcHUOZRvNuVFh9V4y 4Z/A== X-Gm-Message-State: AMke39msGuwK6WoisimXl71gcDPvznFLVsEUUcfilSFFGWJQtfZgxAThLqKI7KibnEUHYN7E X-Received: by 10.28.148.76 with SMTP id w73mr32236490wmd.74.1486844646889; Sat, 11 Feb 2017 12:24:06 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, labbott@fedoraproject.org Cc: kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, andre.przywara@arm.com, Suzuki.Poulose@arm.com, james.morse@arm.com, keescook@chromium.org, kernel-hardening@lists.openwall.com, Ard Biesheuvel Date: Sat, 11 Feb 2017 20:23:05 +0000 Message-Id: <1486844586-26135-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486844586-26135-1-git-send-email-ard.biesheuvel@linaro.org> References: <1486844586-26135-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [kernel-hardening] [PATCH v2 4/5] 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. Reviewed-by: Laura Abbott Reviewed-by: Kees Cook Signed-off-by: Ard Biesheuvel --- 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 7ed981c7f4c0..e97f1ce967ec 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. @@ -484,7 +481,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);