From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: philmd@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 24 Sep 2019 03:37:15 -0700 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4EA112A09D6 for ; Tue, 24 Sep 2019 10:37:14 +0000 (UTC) Received: by mail-wr1-f72.google.com with SMTP id m14so403693wru.17 for ; Tue, 24 Sep 2019 03:37:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=3t4xUPQ4r7Vlr1Xs0Fq3O1JOPahbVRbgXOnGngFdQsA=; b=DMWnw7YXzJ/+kpPq/bwjeqF5AqU5Ult8fPgvqYUHL+SLCnHfsGw8kgCsDwL37Ui3Pp yBNIeUF9ynBVuUqkZELyDbEPFJDai2IQrmAV7Cgiw4LA0oZDF855ql5TkFkuOjy6tnf+ DJxvBrs8ts+aesVjKB8a0tZ0OTOqnRkWTP/gVcGztTeO91g5tG+ExtIi5lK6w83Eu75z pc+9tZGxrbFXd98TMoMx1c0WzTHg2sAvP/POj1BS16ZabIxMqXBNg6RA8JW93TC/MSMv KbPTW9Rpbb/xC4YoA82S30TiEjYRjKxXp5TskJwNVrLQ8i8UxG/MFYhQ2bmmrpi/VPyQ JfyA== X-Gm-Message-State: APjAAAWDpr3ucSV8xKL3edqDQVeA4ewUYg0QDSDG5HGI1gFjPVQU/pQc /KK72EAFVNKvqPpr9On8xJS1/VGERxsm2Kt/uNuShfTmJSLhca/9qLgc+9+M25t98//RhnNqT/z pm4365g31KwiI8w== X-Received: by 2002:a1c:1981:: with SMTP id 123mr2076041wmz.88.1569321432705; Tue, 24 Sep 2019 03:37:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqybX7AP6Wga36yZaeU82vQp6nt+JostfKuIHRnAlsYyjb71fGoWXO+pokN67beRLBFvQ05Riw== X-Received: by 2002:a1c:1981:: with SMTP id 123mr2076028wmz.88.1569321432489; Tue, 24 Sep 2019 03:37:12 -0700 (PDT) Received: from [192.168.1.115] (240.red-88-21-68.staticip.rima-tde.net. [88.21.68.240]) by smtp.gmail.com with ESMTPSA id e6sm1626749wrp.91.2019.09.24.03.37.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Sep 2019 03:37:11 -0700 (PDT) Subject: Re: [edk2-devel] [patch v2 4/5] MdeModulePkg/PlatformDriOverride: Unload image on EFI_SECURITY_VIOLATION To: devel@edk2.groups.io, dandan.bi@intel.com Cc: Jian J Wang , Hao A Wu , Liming Gao , Laszlo Ersek References: <20190918030557.55256-1-dandan.bi@intel.com> <20190918030557.55256-5-dandan.bi@intel.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Openpgp: id=89C1E78F601EE86C867495CBA2A3FD6EDEADC0DE; url=http://pgp.mit.edu/pks/lookup?op=get&search=0xA2A3FD6EDEADC0DE Message-ID: <726d6d91-0e3a-b752-2bce-f9765510b5c5@redhat.com> Date: Tue, 24 Sep 2019 12:37:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190918030557.55256-5-dandan.bi@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 9/18/19 5:05 AM, Dandan Bi wrote: > 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=1992 > Signed-off-by: Dandan Bi > --- > .../PlatformDriOverrideDxe/PlatDriOverrideLib.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/MdeModulePkg/Universal/PlatformDriOverrideDxe/PlatDriOverrideLib.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 vverride mapping. > > - 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 > > **/ > > #include "InternalPlatDriOverrideDxe.h" > @@ -1484,10 +1484,19 @@ GetDriverFromMapping ( > ); > ASSERT (DriverBinding != NULL); > DriverImageInfo->ImageHandle = 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 execution of an image, we should > + // unload image for the EFI_SECURITY_VIOLATION to avoid resource leak. > + // > + if (Status == EFI_SECURITY_VIOLATION) { > + gBS->UnloadImage (ImageHandle); > + } > DriverImageInfo->UnLoadable = TRUE; > DriverImageInfo->ImageHandle = NULL; > } > } > } > Reviewed-by: Philippe Mathieu-Daude