From nobody Sat Nov 2 16:25:35 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1487787917577927.5481492166122; Wed, 22 Feb 2017 10:25:17 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 73FD882245; Wed, 22 Feb 2017 10:25:16 -0800 (PST) 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) 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) X-Original-To: edk2-devel@lists.01.org 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) 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 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: [edk2] [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: , Cc: feng.tian@intel.com, lersek@redhat.com, star.zeng@intel.com, Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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/Im= age/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.Imag= eAddress, (UINTN)Image->ImageContext.ImageSize); =20 // + // Remove any permission restrictions. + // + if (gCpu !=3D 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 protoc= ol // to unload the image. --=20 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel