From patchwork Tue Mar 7 11:25:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94975 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp1840185qgd; Tue, 7 Mar 2017 03:25:54 -0800 (PST) X-Received: by 10.200.42.166 with SMTP id b35mr20545054qta.195.1488885954091; Tue, 07 Mar 2017 03:25:54 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p27si5256778qkp.98.2017.03.07.03.25.53; Tue, 07 Mar 2017 03:25:54 -0800 (PST) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B3C8E62D50; Tue, 7 Mar 2017 11:25:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 9CFCD62CCC; Tue, 7 Mar 2017 11:25:49 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 15B0862D0B; Tue, 7 Mar 2017 11:25:29 +0000 (UTC) Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by lists.linaro.org (Postfix) with ESMTPS id A68D762D07 for ; Tue, 7 Mar 2017 11:25:21 +0000 (UTC) Received: by mail-wm0-f53.google.com with SMTP id t189so1952626wmt.1 for ; Tue, 07 Mar 2017 03:25:21 -0800 (PST) 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; bh=UUjtJLeyHNwUH3lWAfCJSAgWcD/tD4nB0niNVfkL2cQ=; b=Vyj3B2wWbNioAu/Vg0xopzygOBLlJkm0SKYXmTLdeqPCWSGqgZz2URaEmulfZbGuBd duH/KYnJYl00+kfZ7wbXlwyj7kImGpmhd0kC4G15DsGSjXFQVUU1PJay4MpqDL09IlXi eT58deSfvFi4Lh/MWHzddV1AJ+ow5gnelWT5fHr9e8k1JofGdj0snYTbnOFS6E5jQuMy 6e96xQoTooXCPxRXqyhvFgOOt9/Y2bzPARla12J4kngmeDtzeglwaXS7SKs7ARFuDt0G yu98QPhItMibEjEABib/wVGdmR/+F6CSkAbp9U+TJ+dPyBtrpY3IuawPSG0pgeQ974Y7 XuSA== X-Gm-Message-State: AMke39mvrc5yY9qG2s82hY+hVnU/jp36KfYUG4MxaYbta2zDG1+MluuqkUinUKUPV6guPZzkDe0= X-Received: by 10.28.187.213 with SMTP id l204mr16907115wmf.104.1488885920717; Tue, 07 Mar 2017 03:25:20 -0800 (PST) Received: from ards-macbook-pro.c.hoisthospitality.com ([109.74.56.122]) by smtp.gmail.com with ESMTPSA id m29sm30793458wrm.38.2017.03.07.03.25.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Mar 2017 03:25:19 -0800 (PST) From: Ard Biesheuvel To: linaro-uefi@lists.linaro.org, leif.lindholm@linaro.org Date: Tue, 7 Mar 2017 12:25:17 +0100 Message-Id: <1488885917-10445-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [Linaro-uefi] [PATCH] Platforms/ARM: enable memory protection features X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" This enables the recently added and/or enhanced memory protection features in upstream EDK2: - strict code/data separation PE/COFF sections so that mappings can be made either read-only or non-executable - remove exec permissions from all other (i.e., non-code) regions (as far as is feasible without breaking GRUB) - remap the DXE stack as non-executable before entering DxeCore Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Tested-by: Ryan Harkin Reviewed-by: Leif Lindholm --- Platforms/ARM/VExpress/ArmVExpress.dsc.inc | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Platforms/ARM/VExpress/ArmVExpress.dsc.inc b/Platforms/ARM/VExpress/ArmVExpress.dsc.inc index c94001b3bcdb..431d6d0f76ce 100644 --- a/Platforms/ARM/VExpress/ArmVExpress.dsc.inc +++ b/Platforms/ARM/VExpress/ArmVExpress.dsc.inc @@ -14,6 +14,9 @@ [Defines] SECURE_BOOT_ENABLE = FALSE +[BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION] + GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 + [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] GCC:*_*_ARM_DLINK_FLAGS = -z common-page-size=0x1000 GCC:*_*_AARCH64_DLINK_FLAGS = -z common-page-size=0x10000 @@ -437,6 +440,24 @@ # GUID of the UI app gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 } + # + # Enable strict image permissions for all images. (This applies + # only to images that were built with >= 4 KB section alignment.) + # + gEfiMdeModulePkgTokenSpaceGuid.PcdImageProtectionPolicy|0x3 + + # + # Enable NX memory protection for all non-code regions, including OEM and OS + # reserved ones, with the exception of LoaderData regions, of which OS loaders + # (i.e., GRUB) may assume that its contents are executable. + # + gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy|0xC000000000007FD1 + + # + # Enable the non-executable DXE stack. (This gets set up by DxeIpl) + # + gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE + [Components.common] MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {