From patchwork Thu Mar 9 20:52: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: 9614191 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 690FD60414 for ; Thu, 9 Mar 2017 20:56:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CBA928429 for ; Thu, 9 Mar 2017 20:56:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DFA3286B2; Thu, 9 Mar 2017 20:56:41 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CEAA328429 for ; Thu, 9 Mar 2017 20:56:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HviaBClqmlIh4QPpBrwcWfn0Ufm03r31PNHUAkbLiiU=; b=Cg4MUKg09tMrSiWu1itCmT9X5l DueJiUOdM+edYHa2VPXOjtBVHeyc2HimQY0bRrr34/pimsQyBIUrYGAyKIEmXIqAIF5MRzYEC46Lq trdh1KmwYmvWpg2ImECY5oVfEDhF9/kThl9KAb9CzNQVv5uG1cUJBKDpZKjihisuP1oRzdFtKnZep sMwyzhv+5OSPTVta7ex/Y+k+bdVT4W0dZqu+3LPnRt0zNoUt4LRNqQc/HxK1mYXnd/AOynKtctDFY lH+fOHfqbI+viNsW3xMIw9u7L9kKb97DdEK65LpNJPOdhthOzbO0kHtMkWhbAFS+zGK++gPamLm08 Qf8RuD5w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cm572-0002U8-Bk; Thu, 09 Mar 2017 20:56:40 +0000 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cm54s-00080G-2Y for linux-arm-kernel@lists.infradead.org; Thu, 09 Mar 2017 20:54:29 +0000 Received: by mail-wr0-x22e.google.com with SMTP id u108so52983104wrb.3 for ; Thu, 09 Mar 2017 12:54:05 -0800 (PST) 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=8A50Pb42yz7N/B/WlXtYS57tkvWGKS58ehX/zdoPHrY=; b=kWQTdk4FfWrVbOEKd34xw4qxCOOizxolKtgcoQmF+eNvk/sL0eEI5MJJ1iwYnrEq+4 RGp06Wo+Y6Gtb/MgBD24wVvyBKrvvm4ywGUGc9sG6WtWEvtxNMbZW30x4xt42ieNl7yC DdnZiUgDnaXBsN35KhPwtaX3/7K3vv+ytzBhw= 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=8A50Pb42yz7N/B/WlXtYS57tkvWGKS58ehX/zdoPHrY=; b=YK4cw32kY7HljCUiAMXnbwBuzmBeJqRJ9WAn4IHXvqvfiikrFFef/G/CthjRFM/IIC 3aM+vnHXgZ3n+CXauT22+69nPwnSrHGo8Ijc55auqeKk24qKm+vpJyZzgHyW+PV2K8VQ ObEYX2+I30BWA929KEYb33uDp49y9e6ILA4t5/8iD/eRwHnNSQTmvJmOfdjzZ4hL5H9K 0AToEdq3CrD2guXJZyDoUp5MDNCbwjrD0dWMvO2WBN98gsFwgq8VDu8Q1VEemDdzUsIV 6BnFN3sXj0nFRYkFF6xOHNs43rUPxsKjon3LeMZZK8jd0crzj7O7Wml7WJ9y83QXb6nQ fGWg== X-Gm-Message-State: AMke39mXTkxJZkTAqgc6IQ1yx+jPKPNyWLe2NeV6SYLXZaPDlgC4rUlHwnc3gZQdJMAIqkB6 X-Received: by 10.223.172.135 with SMTP id o7mr11622978wrc.121.1489092844256; Thu, 09 Mar 2017 12:54:04 -0800 (PST) Received: from ards-macbook-pro.c.hoisthospitality.com ([109.74.56.122]) by smtp.gmail.com with ESMTPSA id g45sm9602085wrd.11.2017.03.09.12.53.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 12:54:03 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, keescook@chromium.org, labbott@fedoraproject.org Subject: [PATCH v6 07/11] arm64/mmu: ignore debug_pagealloc for kernel segments Date: Thu, 9 Mar 2017 21:52:05 +0100 Message-Id: <1489092729-16871-8-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489092729-16871-1-git-send-email-ard.biesheuvel@linaro.org> References: <1489092729-16871-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170309_125426_272690_17DDAD8B X-CRM114-Status: GOOD ( 11.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: catalin.marinas@arm.com, Ard Biesheuvel , will.deacon@arm.com, kernel-hardening@lists.openwall.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The debug_pagealloc facility manipulates kernel mappings in the linear region at page granularity to detect out of bounds or use-after-free accesses. Since the kernel segments are not allocated dynamically, there is no point in taking the debug_pagealloc_enabled flag into account for them, and we can use block mappings unconditionally. Note that this applies equally to the linear alias of text/rodata: we will never have dynamic allocations there given that the same memory is statically in use by the kernel image. Reviewed-by: Mark Rutland Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/mmu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index bb9179084217..ec23aec6433f 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -328,8 +328,7 @@ static void update_mapping_prot(phys_addr_t phys, unsigned long virt, return; } - __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot, - NULL, debug_pagealloc_enabled()); + __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot, NULL, false); /* flush the TLBs after updating live kernel mappings */ flush_tlb_kernel_range(virt, virt + size); @@ -381,7 +380,7 @@ static void __init __map_memblock(pgd_t *pgd, phys_addr_t start, phys_addr_t end */ __create_pgd_mapping(pgd, kernel_start, __phys_to_virt(kernel_start), kernel_end - kernel_start, PAGE_KERNEL, - early_pgtable_alloc, debug_pagealloc_enabled()); + early_pgtable_alloc, false); } void __init mark_linear_text_alias_ro(void) @@ -437,7 +436,7 @@ static void __init map_kernel_segment(pgd_t *pgd, void *va_start, void *va_end, BUG_ON(!PAGE_ALIGNED(size)); __create_pgd_mapping(pgd, pa_start, (unsigned long)va_start, size, prot, - early_pgtable_alloc, debug_pagealloc_enabled()); + early_pgtable_alloc, false); vma->addr = va_start; vma->phys_addr = pa_start;