From patchwork Wed Mar 29 18:15:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9652195 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 38F51602C8 for ; Wed, 29 Mar 2017 18:17:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2326E27165 for ; Wed, 29 Mar 2017 18:17:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 180CC284EF; Wed, 29 Mar 2017 18:17:13 +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 4C99A27165 for ; Wed, 29 Mar 2017 18:17:12 +0000 (UTC) Received: (qmail 23879 invoked by uid 550); 29 Mar 2017 18:16:51 -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 20450 invoked from network); 29 Mar 2017 18:16:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uIcbJoE3YskpamKiFw1R8V8AQOL5LQY4rTwYGD4m1Hg=; b=OCyn+PImlYjLhyHbZX8daJ3xwvHaeYvBs8XOQSpyXv/uquXL4IVAbcjfLyya0VkBM0 Q1TJmbbpnljdyMhGWzKIzjJKHHqadlrDV41IGuRmS7dyqtRzCCaUYm+0znuXTp7p6VZ4 gROAuFmOl0Ft8Ra9lqjfLiZJ1HfiOhAiXeqiA= 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=uIcbJoE3YskpamKiFw1R8V8AQOL5LQY4rTwYGD4m1Hg=; b=Yf3V0hYvQCXZIuc1SJC3IeqWK0WtXjAfONh49If4ikTxKWe41qc8A45gwRNFPtuHeR JUHGUvKSNv5uHBO24iA8vDuDvL6YNVqwIBVc7La+zEnSn+bhpHP6WRrQyxnQgdxJmRk/ 1zN/MMxKZ5a73xZ1DPK1+NH23TdrGyQt6DKX3zpd+OqoJFxr/DUDOeoWFwndNRvc0G+m hkJyOIBnKhyeyXBnPlEPv6tO1aP9hvhHCzrZdG04KWcJeh/HCy8TBzcHu86sd1+EbI1k K2tFhrWp+gV6j9cH3k9Kms/Rvjyi/q/6+WgLgPF1BriNTnPoCnR9fFyFf3YHQ0eEKXx6 XIvw== X-Gm-Message-State: AFeK/H0jQar/K5YYVGs6G5S6STYxqrNrQupVLvjMgkDhYQrzvj2uY5rUb3QnopPSaEchiM1d X-Received: by 10.98.201.212 with SMTP id l81mr1842197pfk.13.1490811384618; Wed, 29 Mar 2017 11:16:24 -0700 (PDT) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , Mark Rutland , Andy Lutomirski , Hoeun Ryu , PaX Team , Emese Revfy , Russell King , x86@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Date: Wed, 29 Mar 2017 11:15:59 -0700 Message-Id: <1490811363-93944-8-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490811363-93944-1-git-send-email-keescook@chromium.org> References: <1490811363-93944-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [RFC v2][PATCH 07/11] ARM: mm: set DOMAIN_WR_RARE for rodata X-Virus-Scanned: ClamAV using ClamSMTP This creates DOMAIN_WR_RARE for the kernel's .rodata section, separate from DOMAIN_KERNEL to avoid predictive fetching in device memory during a DOMAIN_MANAGER transition. TODO: handle kernel module vmalloc memory, which needs to be marked as DOMAIN_WR_RARE too, for module .rodata sections. Signed-off-by: Kees Cook --- arch/arm/include/asm/domain.h | 3 +++ arch/arm/mm/dump.c | 2 ++ arch/arm/mm/init.c | 7 ++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h index 8b33bd7f6bf9..b5ca80ac823c 100644 --- a/arch/arm/include/asm/domain.h +++ b/arch/arm/include/asm/domain.h @@ -43,6 +43,7 @@ #define DOMAIN_IO 0 #endif #define DOMAIN_VECTORS 3 +#define DOMAIN_WR_RARE 4 /* * Domain types @@ -69,11 +70,13 @@ #define DACR_INIT \ (__DACR_INIT_USER | \ domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \ + domain_val(DOMAIN_WR_RARE, DOMAIN_CLIENT) | \ domain_val(DOMAIN_IO, DOMAIN_CLIENT) | \ domain_val(DOMAIN_VECTORS, DOMAIN_CLIENT)) #define __DACR_DEFAULT \ domain_val(DOMAIN_KERNEL, DOMAIN_CLIENT) | \ + domain_val(DOMAIN_WR_RARE, DOMAIN_CLIENT) | \ domain_val(DOMAIN_IO, DOMAIN_CLIENT) | \ domain_val(DOMAIN_VECTORS, DOMAIN_CLIENT) diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c index 35ff45470dbf..b1aa9a17e0c3 100644 --- a/arch/arm/mm/dump.c +++ b/arch/arm/mm/dump.c @@ -288,6 +288,8 @@ static const char *get_domain_name(pmd_t *pmd) return "IO "; case PMD_DOMAIN(DOMAIN_VECTORS): return "VECTORS"; + case PMD_DOMAIN(DOMAIN_WR_RARE): + return "WR_RARE"; default: return "unknown"; } diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 1d8558ff9827..d54a74b5718b 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c @@ -642,9 +642,10 @@ static struct section_perm ro_perms[] = { .mask = ~L_PMD_SECT_RDONLY, .prot = L_PMD_SECT_RDONLY, #else - .mask = ~(PMD_SECT_APX | PMD_SECT_AP_WRITE), - .prot = PMD_SECT_APX | PMD_SECT_AP_WRITE, - .clear = PMD_SECT_AP_WRITE, + .mask = ~(PMD_SECT_APX | PMD_SECT_AP_WRITE | PMD_DOMAIN_MASK), + .prot = PMD_SECT_APX | PMD_SECT_AP_WRITE | \ + PMD_DOMAIN(DOMAIN_WR_RARE), + .clear = PMD_SECT_AP_WRITE | PMD_DOMAIN(DOMAIN_KERNEL), #endif }, };