From patchwork Mon Nov 9 08:55:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 56189 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp63731lbb; Mon, 9 Nov 2015 00:57:50 -0800 (PST) X-Received: by 10.68.57.235 with SMTP id l11mr38937220pbq.26.1447059470363; Mon, 09 Nov 2015 00:57:50 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id tk2si21049202pab.196.2015.11.09.00.57.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Nov 2015 00:57:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZviFo-0007ZQ-OY; Mon, 09 Nov 2015 08:56:44 +0000 Received: from mail-wi0-x232.google.com ([2a00:1450:400c:c05::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZviFR-0007Sm-B3 for linux-arm-kernel@lists.infradead.org; Mon, 09 Nov 2015 08:56:23 +0000 Received: by wimw2 with SMTP id w2so65906916wim.1 for ; Mon, 09 Nov 2015 00:55:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9oUE3QbfKr14D0dS6OvhHFvRaq7jbBS6ogDWPKJ2+Mc=; b=swOzq5f01po8h7Jf08bpPSFFiYO7Qwh4r1WSrEysl5/5jueoS0BFuoikrExpthLwIc PrsR299FszJGbSb71AFcb2d7SHHrikAl0lJ5YmarN70buSCRHARNMXrc4jbnwScbOGWt Px4iE17LS/pDIKzkEIMKlLJAJPoAnqmr3ru6mzwYW7B+AZIgO/XFuXFpOGtf2zxM/CUs E89g20ma5xIPrWsPPjOTk0s9DC4gLHhvJfwvGUyPzye/CScPn9sLweGNZx4bUxUlhlam 7lAgR/bcxIBXa0tEUz2k152xPbB0FDitqo5vthidju6zjiEr6H2qpxI1dNBgpldLlqro 9qGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9oUE3QbfKr14D0dS6OvhHFvRaq7jbBS6ogDWPKJ2+Mc=; b=GKpoiDFRlLTcbZTVksBsPpW/clvOWMTczO9m29mALzO9D2D6tDCxzCiC1Z0okumUJu 6LT1HpeDqFFsX+YnSDdrjx7MbPVrw3mQhj8J5blwiNc+KqeayLR7lBLdEQIC92kvyvuJ HEldPsFXl8vJC94aD7cPGGvC2AaF3RP1YKWVVt/i/3GWSTyQjVRxkBFbtZeK4xkaBJ/a A2WNHRz0Fmfg9M1uGyyYGiS8ybQNp8tEzO+nxsixvY6Kzn/20BdVDvQbKu2bXa9G2cwr EZ+F72aC4f3qOwODF9hb1JqB8wr1asFpUjPLszHIKejKG74zlM8AwGhTSzBwYsmhKybb tjrQ== X-Gm-Message-State: ALoCoQlZJu4L7Uepl+DfJm6CQIi+UbQCp0XbI9OcwNzpQNyGndwFUKxXHAbX2mvQH0aRUw8C8W6c X-Received: by 10.194.205.9 with SMTP id lc9mr14026232wjc.120.1447059359768; Mon, 09 Nov 2015 00:55:59 -0800 (PST) Received: from localhost.localdomain ([176.244.176.159]) by smtp.gmail.com with ESMTPSA id t126sm13053106wmd.23.2015.11.09.00.55.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Nov 2015 00:55:59 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com Subject: [PATCH 2/2] arm64: fix R/O permissions of FDT mapping Date: Mon, 9 Nov 2015 09:55:46 +0100 Message-Id: <1447059346-12050-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447059346-12050-1-git-send-email-ard.biesheuvel@linaro.org> References: <1447059346-12050-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151109_005621_553010_00D421F1 X-CRM114-Status: GOOD ( 14.84 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c05:0:0:0:232 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: will.deacon@arm.com, jeremy.linton@arm.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org The mapping permissions of the FDT are set to 'PAGE_KERNEL | PTE_RDONLY' in an attempt to map the FDT as read-only. However, not only does this break at build time under STRICT_MM_TYPECHECKS (since the two terms are of different types in that case), it also results in both the PTE_WRITE and PTE_RDONLY attributes to be set, which means the region is still writable under ARMv8.1 DBM (and an attempted write will simply clear the PT_RDONLY bit). So instead, define PAGE_KERNEL_RO (which already has an established meaning across architectures) and use that instead. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/pgtable.h | 1 + arch/arm64/mm/mmu.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index f3acf421ded4..9819a9426b69 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -80,6 +80,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val); #define _PAGE_DEFAULT (PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL)) #define PAGE_KERNEL __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE) +#define PAGE_KERNEL_RO __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_RDONLY) #define PAGE_KERNEL_EXEC __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE) #define PAGE_KERNEL_EXEC_CONT __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_CONT) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 46a2b8805c97..7471f08b1d98 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -755,7 +755,7 @@ void __set_fixmap(enum fixed_addresses idx, void *__init fixmap_remap_fdt(phys_addr_t dt_phys) { const u64 dt_virt_base = __fix_to_virt(FIX_FDT); - pgprot_t prot = PAGE_KERNEL | PTE_RDONLY; + pgprot_t prot = PAGE_KERNEL_RO; int size, offset; void *dt_virt;