From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com [IPv6:2a00:1450:400c:c09::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B705582245 for ; Wed, 22 Feb 2017 10:25:14 -0800 (PST) Received: by mail-wm0-x231.google.com with SMTP id v186so148569892wmd.0 for ; Wed, 22 Feb 2017 10:25:14 -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=jl3Cv2W9dBV/wPbqxZBS//P62jVQme8foGbc/HQDDck=; b=dr6eG8ae5wfAP7t1XpPnzuOx1FszajxZa77P67DSqRlepZZqPyTKBaH7DoDgc8Blt2 jTmhBVLx117616HZazrc7URRY59lIBV4DiEMd3kcGurDYTjGIdHR8bygSN4/nB+3oAgu 6NPE/6i0LwrZPS1/sVlyzEArgD86n0PRE1IZk= 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=jl3Cv2W9dBV/wPbqxZBS//P62jVQme8foGbc/HQDDck=; b=aGb6sTfwPtN1A1AVMGZee/+dlzhSuGZ8ipAgPya/CCDIHLC/WvV6cOmUTAG6g8D0Ct XC3QTw+pKYMljXay1JdQ4NnkPZP3CyLj6SwKBBhpVuG0b33dPfo914dgLVm6bAVa64hU qsOrPpeaj1oeYyBMmk+Xd9dtrUfqz9ybNFz0dKV0OQq7M/g7rrnTlKfHF9ZDNkx2I4Xi H28Mp6T2A/6AJXqk6OnRux9qQMxu4NvnZ1pDR9wAflG7ouw6eRW0x15KhiCFmrsORwW3 cnoaD2H1aTttUiNSe1R39/f/MnWPwl9Vg6eWWr/AyBd7qmHv13Nu0OoYdiyJhCHmJ568 iU8Q== X-Gm-Message-State: AMke39lqWPSXzI8YWHEF2gj7O1fycpkeM1hTerENeFQFF53DM1bJGGc9ZP7jEpwNkx1UuKHp X-Received: by 10.28.226.67 with SMTP id z64mr3446117wmg.137.1487787913176; Wed, 22 Feb 2017 10:25:13 -0800 (PST) Received: from localhost.localdomain ([196.80.204.181]) by smtp.gmail.com with ESMTPSA id e73sm3504667wmi.32.2017.02.22.10.25.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Feb 2017 10:25:12 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, afish@apple.com, leif.lindholm@linaro.org, michael.d.kinney@intel.com, liming.gao@intel.com, jiewen.yao@intel.com Cc: lersek@redhat.com, feng.tian@intel.com, star.zeng@intel.com, Ard Biesheuvel Date: Wed, 22 Feb 2017 18:24:57 +0000 Message-Id: <1487787898-5222-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487787898-5222-1-git-send-email-ard.biesheuvel@linaro.org> References: <1487787898-5222-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [RFC PATCH 3/4] MdeModulePkg/DxeCore: lift non-exec permissions on loaded images X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Feb 2017 18:25:15 -0000 To ensure that loaded PE/COFF images are executable regardless of the protection policy and the section alignment, clear all permission restrictions when loading PE/COFF images. Subsequently, permissions may be restricted again if the protection policy and section alignment allow it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdeModulePkg/Core/Dxe/Image/Image.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MdeModulePkg/Core/Dxe/Image/Image.c b/MdeModulePkg/Core/Dxe/Image/Image.c index 652da8bf1075..cab06e821e39 100644 --- a/MdeModulePkg/Core/Dxe/Image/Image.c +++ b/MdeModulePkg/Core/Dxe/Image/Image.c @@ -644,6 +644,14 @@ CoreLoadPeImage ( InvalidateInstructionCacheRange ((VOID *)(UINTN)Image->ImageContext.ImageAddress, (UINTN)Image->ImageContext.ImageSize); // + // Remove any permission restrictions. + // + if (gCpu != NULL) { + gCpu->SetMemoryAttributes (gCpu, Image->ImageContext.ImageAddress, + Image->ImageContext.ImageSize, 0); + } + + // // Copy the machine type from the context to the image private data. This // is needed during image unload to know if we should call an EBC protocol // to unload the image. -- 2.7.4