From nobody Mon Feb 9 03:13:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47447+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47447+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1568775995; cv=none; d=zoho.com; s=zohoarc; b=PmelmFh9HnlGogkLEu69bHbnIDqhATXN5rW8CbAWxBPXXK1NPnzeisVx3C1/O32N7Ve0J4Em6Yh0NUmYft03UivbqSrKsGn/AJo/jKyx35vQ82Cpd8WIiiiNEoDU3r9Zz0fa4mq1UfhXbP3/8lKHi5edMfuiEoA66pJBKu3hvJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568775995; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=BcPJUFK3Vtqufs4Sk5tVgAgtvyQlCPyECOS2ZjCwRUA=; b=FMjkPtKoOFR8YVINZdavOBM1g+vZKn7Ltd0uNqwy9e6M/d6vVFAnsEFwn/fCGeZim6veS6vaUiVB2MVG/NtXkJKLQ6T5Jyrds31SYCkbbeMxTWqW+M7m8vpyaJHP6u+iGIU6UfRsWPodhBDzk0CPT4qLjWHbIv1o/+6mT4i2MuA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47447+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1568775995272278.6337438264504; Tue, 17 Sep 2019 20:06:35 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6bqUYY1788612xcWdSIu0pTX; Tue, 17 Sep 2019 20:06:34 -0700 X-Received: from mga04.intel.com (mga04.intel.com []) by groups.io with SMTP; Tue, 17 Sep 2019 20:06:33 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Sep 2019 20:06:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,519,1559545200"; d="scan'208";a="338192333" X-Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.147]) by orsmga004.jf.intel.com with ESMTP; 17 Sep 2019 20:06:32 -0700 From: "Dandan Bi" To: devel@edk2.groups.io Cc: Jian J Wang , Hao A Wu , Liming Gao , Laszlo Ersek Subject: [edk2-devel] [patch v2 4/5] MdeModulePkg/PlatformDriOverride: Unload image on EFI_SECURITY_VIOLATION Date: Wed, 18 Sep 2019 11:05:56 +0800 Message-Id: <20190918030557.55256-5-dandan.bi@intel.com> In-Reply-To: <20190918030557.55256-1-dandan.bi@intel.com> References: <20190918030557.55256-1-dandan.bi@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dandan.bi@intel.com X-Gm-Message-State: YY7SDXj5OEmoSfKhiBTFpAWex1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1568775994; bh=8x3w/38zZGPp/o9ODooNY5re57DuIUDUGaxUEESB0k8=; h=Cc:Date:From:Reply-To:Subject:To; b=SyanCIC50tCax9zX3xYF6yJ0n7QsbxFBY8keXrOwS2GytZ6L/DFWLUvM3XucSaERLw+ CHyHzMII0irt+qKRmA9IpWuPzNss0e3570sj8t1Y84wAMva8uHRhy8gCekGnsQglX0ugA lij6iT5JWxc9hJz9PbVhMPg+x5JLpt8zufI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now. This follows UEFI Spec. But if the caller of LoadImage() doesn't have the option to defer the execution of an image, we can not treat EFI_SECURITY_VIOLATION like any other LoadImage() error, we should unload image for the EFI_SECURITY_VIOLATION to avoid resource leak. This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly for the caller in PlatformDriOverrideDxe which don't have the policy to defer the execution of the image. Cc: Jian J Wang Cc: Hao A Wu Cc: Liming Gao Cc: Laszlo Ersek REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1992 Signed-off-by: Dandan Bi Reviewed-by: Hao A Wu Reviewed-by: Philippe Mathieu-Daude --- .../PlatformDriOverrideDxe/PlatDriOverrideLib.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideL= ib.c b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.c index 2d3736b468..f91f038b7a 100644 --- a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.c +++ b/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.c @@ -1,9 +1,9 @@ /** @file Implementation of the shared functions to do the platform driver vverrid= e mapping. =20 - Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include "InternalPlatDriOverrideDxe.h" @@ -1484,10 +1484,19 @@ GetDriverFromMapping ( ); ASSERT (DriverBinding !=3D NULL); DriverImageInfo->ImageHandle =3D ImageHandle; } } else { + // + // With EFI_SECURITY_VIOLATION retval, the Image was loaded = and an ImageHandle was created + // with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can= not be started right now. + // If the caller doesn't have the option to defer the execut= ion of an image, we should + // unload image for the EFI_SECURITY_VIOLATION to avoid reso= urce leak. + // + if (Status =3D=3D EFI_SECURITY_VIOLATION) { + gBS->UnloadImage (ImageHandle); + } DriverImageInfo->UnLoadable =3D TRUE; DriverImageInfo->ImageHandle =3D NULL; } } } --=20 2.18.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#47447): https://edk2.groups.io/g/devel/message/47447 Mute This Topic: https://groups.io/mt/34184009/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-