From patchwork Sun Feb 19 10:04:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoeun Ryu X-Patchwork-Id: 9581533 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 C588B604A0 for ; Sun, 19 Feb 2017 10:06:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7E822872E for ; Sun, 19 Feb 2017 10:06:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABD1228779; Sun, 19 Feb 2017 10:06:08 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 C85C82872E for ; Sun, 19 Feb 2017 10:06:07 +0000 (UTC) Received: (qmail 23763 invoked by uid 550); 19 Feb 2017 10:06:06 -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 23740 invoked from network); 19 Feb 2017 10:06:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qPKPWqd8PQE6F8qqBNxuv4B5SOlxXXvnwJghx+RNdR8=; b=s0dpCOY5rhdFiPrlCZpJlP9gaEnA5rO5W3HA/6F2BIOnkMZWd00DiV4oYdv+83sKFg Ilmbqm8gzccNCzWUUxoTOOtLl18u2SyU/EraOW5D3leyS22igG7oQr6V1F60+jegepq7 scxqHsZoy75BzWC1zLWNY/ElW2Ep06JOYL2smI6QeHOJzz2Oum1LmtRl6JtPu8hwlt2D lXS8Cfhd/MbeiFDyRriEq+mD6MfM2sN3JBGuZA1mQiHgEKAOY0hqNCqr0iVQDKxWNKxc ZJej0iW81Th1GnYPjiiG9ZnRZN0BaeNkf/+vZ1h204zlECP/V8boTy7eqFZBmWrodrZ6 LAzA== 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=qPKPWqd8PQE6F8qqBNxuv4B5SOlxXXvnwJghx+RNdR8=; b=dPyX2sRLRZenqGBhusZL5gxKZCe8LADtM5v2w0ZyJF8fhAf/7pBElEX8l/mGMKgSd0 GoKMwtc9GoTN/n8nBb0PZfkhdTfk7Rmws6Rgm0jkwnChU2CgRvfrqXzE1A2zm1j1C8xR 6pPlM3gFEZX5KkNyhuZtXJ60tKLBwElY4qIu2PbSQGQDf0tI8PswJidLf19Bqx6QIZTl deqIBRIpEvr9l3kp6rMGjL3kzq8vXdbahi09tev2NnLSVH7UJx5VMVaMZ8O6T96qoOSA pxgLKXr4xfLdXyYRhWhhLLa/f+J9y8QfjZY59Kg2xQNsfVws814JDEWoem3uQaMC/8OG nhpQ== X-Gm-Message-State: AMke39lk+i7mnZun8pZlMeYvEUiVVkQpNv7Ls+WZoWn9v+5Lz9FSooWu9sIQFkyoC9cjtA== X-Received: by 10.98.198.90 with SMTP id m87mr19176389pfg.153.1487498753754; Sun, 19 Feb 2017 02:05:53 -0800 (PST) From: Hoeun Ryu To: kernel-hardening@lists.openwall.com, linux-kernel@vger.kernel.org Cc: Hoeun Ryu , Catalin Marinas , Will Deacon , Ard Biesheuvel , Mark Rutland , Laura Abbott , Kefeng Wang , Jeremy Linton , linux-arm-kernel@lists.infradead.org Date: Sun, 19 Feb 2017 19:04:09 +0900 Message-Id: <1487498660-16600-6-git-send-email-hoeun.ryu@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487498660-16600-1-git-send-email-hoeun.ryu@gmail.com> References: <1487498660-16600-1-git-send-email-hoeun.ryu@gmail.com> Subject: [kernel-hardening] [RFC 6/7] arm64: add __map_kernel_segment to accept additional vm flags X-Virus-Scanned: ClamAV using ClamSMTP Memory attribute for `__ro_mostly_after_init` section should be changed via set_memory_rw/ro that doesn't work against vm areas which don't have VM_ALLOC. Add this function to map `__ro_mostly_after_init` section with VM_ALLOC flag set in map_kernel. Signed-off-by: Hoeun Ryu --- arch/arm64/mm/mmu.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index b805c01..91271b1 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -444,8 +444,10 @@ void mark_rodata_ro(void) debug_checkwx(); } -static void __init map_kernel_segment(pgd_t *pgd, void *va_start, void *va_end, - pgprot_t prot, struct vm_struct *vma) +static void __init __map_kernel_segment(pgd_t *pgd, + void *va_start, void *va_end, + pgprot_t prot, struct vm_struct *vma, + unsigned long flags) { phys_addr_t pa_start = __pa_symbol(va_start); unsigned long size = va_end - va_start; @@ -459,12 +461,18 @@ static void __init map_kernel_segment(pgd_t *pgd, void *va_start, void *va_end, vma->addr = va_start; vma->phys_addr = pa_start; vma->size = size; - vma->flags = VM_MAP; + vma->flags = flags; vma->caller = __builtin_return_address(0); vm_area_add_early(vma); } +static void __init map_kernel_segment(pgd_t *pgd, void *va_start, void *va_end, + pgprot_t prot, struct vm_struct *vma) +{ + return __map_kernel_segment(pgd, va_start, va_end, prot, vma, VM_MAP); +} + /* * Create fine-grained mappings for the kernel. */