From patchwork Wed Aug 9 20:07:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tycho Andersen X-Patchwork-Id: 9891887 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 7859960363 for ; Wed, 9 Aug 2017 20:10:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6ADF228A9C for ; Wed, 9 Aug 2017 20:10:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FD3428AA2; Wed, 9 Aug 2017 20:10:26 +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 6CC9028AA5 for ; Wed, 9 Aug 2017 20:10:25 +0000 (UTC) Received: (qmail 32665 invoked by uid 550); 9 Aug 2017 20:09:22 -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 32300 invoked from network); 9 Aug 2017 20:09:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=docker.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oUK/Cd9olSgfS9OZExNyctMbH2xfPkGDnCQw7YKt39Q=; b=f0t/u581gskFaUDSWbGQGi1rCU8g/A7+etedUxEeYS0gVzi+P2Fa0kWh3769xaDg7j R1aXCaOI+brPtJaHQzBoz+yPodILBKSvdFvRDNbiVXfh+vfvXrEjgc7alAdnin+WyY7g v8KXVrd77mMIG7C7USiuyc+lCZ9lAoI6BhdNY= 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=oUK/Cd9olSgfS9OZExNyctMbH2xfPkGDnCQw7YKt39Q=; b=BiWPpw1jkwUg2Lw7Jmns8HkamCuI1JmGHwle3RnY6BHjkSC2yhODGkr5NV2W7Siq2R dXvyqFkoE6mH0JP1H25tLGFhnVv5WvNjA3yoNhQH1DYhb2GX/s7lv0hHnaWVdCmnIoDl kknYi3lGG6V5btH9PtzNuqKPsd2KCLEhyacTUH7jDOfg0+2r48XPRMn7vwjPVJsLNCp/ JtbQQprE4ZSYvgLhpn0arVddCSRs8y7NzGa4q+g6ES/Gqfua5P1pTt6eJQOGLmbshVwd JXlN1qMwCsqewOqpqJIKm8ls6P/cHq8FuZkJpTUmzCrhmBElFTzWFe0SsYRaaE5lrGRp BFIw== X-Gm-Message-State: AHYfb5j8s9o6940sdL6xfQrrA8C+rgXWgaTlwVDc00Q0O1NBJQ6cfx+J ByMhsV+yurmyKTWc X-Received: by 10.36.64.209 with SMTP id n200mr7957932ita.63.1502309340821; Wed, 09 Aug 2017 13:09:00 -0700 (PDT) From: Tycho Andersen To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, kernel-hardening@lists.openwall.com, Marco Benatto , Juerg Haefliger , Juerg Haefliger Date: Wed, 9 Aug 2017 14:07:51 -0600 Message-Id: <20170809200755.11234-7-tycho@docker.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170809200755.11234-1-tycho@docker.com> References: <20170809200755.11234-1-tycho@docker.com> Subject: [kernel-hardening] [PATCH v5 06/10] arm64/mm: Disable section mappings if XPFO is enabled X-Virus-Scanned: ClamAV using ClamSMTP From: Juerg Haefliger XPFO (eXclusive Page Frame Ownership) doesn't support section mappings yet, so disable it if XPFO is turned on. Signed-off-by: Juerg Haefliger Tested-by: Tycho Andersen --- arch/arm64/mm/mmu.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index f1eb15e0e864..38026b3ccb46 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -176,6 +176,18 @@ static void alloc_init_cont_pte(pmd_t *pmd, unsigned long addr, } while (addr = next, addr != end); } +static inline bool use_section_mapping(unsigned long addr, unsigned long next, + unsigned long phys) +{ + if (IS_ENABLED(CONFIG_XPFO)) + return false; + + if (((addr | next | phys) & ~SECTION_MASK) != 0) + return false; + + return true; +} + static void init_pmd(pud_t *pud, unsigned long addr, unsigned long end, phys_addr_t phys, pgprot_t prot, phys_addr_t (*pgtable_alloc)(void), int flags) @@ -190,7 +202,7 @@ static void init_pmd(pud_t *pud, unsigned long addr, unsigned long end, next = pmd_addr_end(addr, end); /* try section mapping first */ - if (((addr | next | phys) & ~SECTION_MASK) == 0 && + if (use_section_mapping(addr, next, phys) && (flags & NO_BLOCK_MAPPINGS) == 0) { pmd_set_huge(pmd, phys, prot);