From nobody Fri May 17 01:44:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+86614+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86614+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1644570136; cv=none; d=zohomail.com; s=zohoarc; b=HXx83lkNN123pRokEZI1RzGK3DBySFXdg6W6rHlt8d/WVpi0Lhq2tKD9KkIeJqiTGyxISybVfIG27/Bl0dU66gFVZB//Ou9N+uHIMCMPxoE/h9CpQA+Gj/cozXQcfaksr4rpOzve2hiW2SpBwLMtm2HOJhjGPv4s85z+GLF2hUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644570136; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=laNPsNSN5GVlkrNEoFAu/DsVrdjevNjXEC1HK8IhDBU=; b=e6j9tEE80+swQh442wLxviuS3F0aKZRWgLzlUQb+6m9WkZPj1XL77jSAy1TvbIctriW5uX6/1t3I4oAERmAs49aRlHpKdVqCWSr3FDKVuSXCgzv3yObY1153dhFQTrY+IJ/nMcn1WDdmIDLsCZ2NUejczj8roIIOVVcTq46t9TE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+86614+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1644570136096726.1357793043746; Fri, 11 Feb 2022 01:02:16 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id u9flYY1788612xf6OVqZkwOR; Fri, 11 Feb 2022 01:02:15 -0800 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.5072.1644570134094657749 for ; Fri, 11 Feb 2022 01:02:15 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10254"; a="249444055" X-IronPort-AV: E=Sophos;i="5.88,360,1635231600"; d="scan'208";a="249444055" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2022 01:02:13 -0800 X-IronPort-AV: E=Sophos;i="5.88,360,1635231600"; d="scan'208";a="483231233" X-Received: from cchiu4-mobl.gar.corp.intel.com ([10.252.189.32]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2022 01:02:11 -0800 From: "Chiu, Chasel" To: devel@edk2.groups.io Cc: "Chiu, Chasel" , Nate DeSimone , Liming Gao , Eric Dong Subject: [edk2-devel] [edk2-platforms: PATCH v3] MinPlatformPkg/SaveMemoryConfig: Variable may not be locked. Date: Fri, 11 Feb 2022 17:02:04 +0800 Message-Id: <20220211090204.987-1-chasel.chiu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,chasel.chiu@intel.com X-Gm-Message-State: h25iyG00howbd5roZF09XznZx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1644570135; bh=UpxuCA3QYjpm3h96XK5ndwsa16Z79J++Hb//GpFR+cU=; h=Cc:Date:From:Reply-To:Subject:To; b=b+QNB7lW9dQk4zk1582Y1wsUCGRtJdVD6Ljl+worH6f0znUhjOF1IBFM72SGJfjV7+H rAux6bDvf/npbyTkhGbWv//VBV5bTWTQqffpQDMr33XHAnO60i8OqfLa+Ca+vuTRDVzMx gU5xpz3TxWrvcUWc6Y/cNWPDa82aUeb+eM0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1644570137059100002 Content-Type: text/plain; charset="utf-8" From: "Chiu, Chasel" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3829 Fixed the bug that existing variable will not be locked when it is identical with hob data by creating LockLargeVariable function, also switched to VariablePolicyProtocol for locking variables. Failing to lock variable could be security vulnerability, so the function will return EFI_ABORTED when it failed and SaveMemoryConfig driver will halt the system for developers to resolve this issue. This patch also modified SaveMemoryConfig driver to be unloaded after execution because it does not produce any service protocol. To achieve this goal the DxeRuntimeVariableWriteLib should close registered ExitBootService events in its DESTRUCTOR. Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Signed-off-by: Chasel Chiu Reviewed-by: Isaac Oram --- V3: Updated LargeVariableWriteLib to return EFI_ABORTED when locking variables = failed. Also SaveMemoryConfig driver will halt the system in this case for develope= rs to fix such security vulnerability issue. Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig= .c | 27 ++++++++++++++++++++++++--- Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWr= iteLib.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRuntim= eVariableWriteLib.c | 61 +++++++++++++++++++++++++++++++++++++++++++++--= -------------- Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig= .inf | 3 ++- Platform/Intel/MinPlatformPkg/Include/Library/LargeVariableWriteLib.h = | 25 +++++++++++++++++++++++-- Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeRuntim= eVariableWriteLib.inf | 8 +++++--- 6 files changed, 209 insertions(+), 30 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/Save= MemoryConfig.c b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/= SaveMemoryConfig.c index 820585f676..54e11e20bd 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC= onfig.c +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC= onfig.c @@ -2,13 +2,14 @@ This is the driver that locates the MemoryConfigurationData HOB, if it exists, and saves the data to nvRAM. =20 -Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include #include +#include #include #include #include @@ -18,6 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include =20 /** @@ -86,6 +88,18 @@ SaveMemoryConfigEntryPoint ( Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVa= riableGuid, &BufferSize, VariableData); if (!EFI_ERROR (Status) && (BufferSize =3D=3D DataSize) && (0 = =3D=3D CompareMem (HobData, VariableData, DataSize))) { DataIsIdentical =3D TRUE; + // + // No need to update Variable, only lock it. + // + Status =3D LockLargeVariable (L"FspNvsBuffer", &gFspNvsBuff= erVariableGuid); + if (EFI_ERROR(Status)) { + // + // Fail to lock variable is security vulnerability and sho= uld not happen. + // + DEBUG ((DEBUG_ERROR, "LockVariable is requested but failed= unexpectedly!\n")); + ASSERT_EFI_ERROR (Status); + CpuDeadLoop(); + } } FreePool (VariableData); } @@ -96,6 +110,13 @@ SaveMemoryConfigEntryPoint ( if (!DataIsIdentical) { Status =3D SetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariab= leGuid, TRUE, DataSize, HobData); ASSERT_EFI_ERROR (Status); + if (Status =3D=3D EFI_ABORTED) { + // + // Fail to lock variable is security vulnerability and should no= t happen. + // + DEBUG ((DEBUG_ERROR, "LockVariable is requested but failed unexp= ectedly!\n")); + CpuDeadLoop(); + } DEBUG ((DEBUG_INFO, "Saved size of FSP / MRC Training Data: 0x%x\n= ", DataSize)); } else { DEBUG ((DEBUG_INFO, "FSP / MRC Training Data is identical to data = from last boot, no need to save.\n")); @@ -106,7 +127,7 @@ SaveMemoryConfigEntryPoint ( } =20 // - // This driver cannot be unloaded because DxeRuntimeVariableWriteLib con= structor will register ExitBootServices callback. + // This driver does not produce any protocol services, so always unload = it. // - return EFI_SUCCESS; + return EFI_REQUEST_UNLOAD_IMAGE; } diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/Lar= geVariableWriteLib.c b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVaria= bleLib/LargeVariableWriteLib.c index e4b97ef1df..154f6f448f 100644 --- a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVaria= bleWriteLib.c +++ b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVaria= bleWriteLib.c @@ -10,7 +10,7 @@ integer number will be added to the end of the variable name. This number will be incremented for each variable as needed to store the entire data= set. =20 - Copyright (c) 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -245,7 +245,7 @@ Done: @retval EFI_DEVICE_ERROR The variable could not be retrieved due t= o a hardware error. @retval EFI_WRITE_PROTECTED The variable in question is read-only. @retval EFI_WRITE_PROTECTED The variable in question cannot be delete= d. - + @retval EFI_ABORTED LockVariable was requested but failed. @retval EFI_NOT_FOUND The variable trying to be updated or dele= ted was not found. =20 **/ @@ -412,7 +412,7 @@ SetLargeVariable ( // all data is saved. // if (LockVariable) { - for (Index =3D 0; Index < VariablesSaved; Index++) { + for (Index =3D 0; Index <=3D VariablesSaved; Index++) { ZeroMem (TempVariableName, MAX_VARIABLE_NAME_SIZE); UnicodeSPrint (TempVariableName, MAX_VARIABLE_NAME_SIZE, L"%s%d", = VariableName, Index); =20 @@ -420,7 +420,7 @@ SetLargeVariable ( Status =3D VarLibVariableRequestToLock (TempVariableName, VendorGu= id); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "SetLargeVariable: Error locking variable: = Status =3D %r\n", Status)); - VariablesSaved =3D 0; + Status =3D EFI_ABORTED; goto Done; } } @@ -442,9 +442,114 @@ Done: 0, NULL ); - DEBUG ((DEBUG_ERROR, "SetLargeVariable: Error deleting variable: Statu= s =3D %r\n", Status2)); + if (EFI_ERROR (Status2)) { + DEBUG ((DEBUG_ERROR, "SetLargeVariable: Error deleting variable: S= tatus =3D %r\n", Status2)); + } } } DEBUG ((DEBUG_ERROR, "SetLargeVariable: Status =3D %r\n", Status)); return Status; } + +/** + Locks the existing large variable. + + @param[in] VariableName A Null-terminated string that is the name= of the vendor's variable. + Each VariableName is unique for each Vend= orGuid. VariableName must + contain 1 or more characters. If Variable= Name is an empty string, + then EFI_INVALID_PARAMETER is returned. + @param[in] VendorGuid A unique identifier for the vendor. + @retval EFI_SUCCESS The firmware has successfully locked the = variable. + @retval EFI_INVALID_PARAMETER An invalid combination of variable name a= nd GUID was supplied + @retval EFI_UNSUPPORTED The service for locking variable is not r= eady. + @retval EFI_NOT_FOUND The targeting variable for locking is not= present. + @retval EFI_ABORTED Fail to lock variable. +**/ +EFI_STATUS +EFIAPI +LockLargeVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid + ) +{ + CHAR16 TempVariableName[MAX_VARIABLE_NAME_SIZE]; + UINT64 VariableSize; + EFI_STATUS Status; + UINTN Index; + + // + // Check input parameters. + // + if (VariableName =3D=3D NULL || VariableName[0] =3D=3D 0 || VendorGuid = =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (!VarLibIsVariableRequestToLockSupported ()) { + return EFI_UNSUPPORTED; + } + + VariableSize =3D 0; + Index =3D 0; + ZeroMem (TempVariableName, MAX_VARIABLE_NAME_SIZE); + UnicodeSPrint (TempVariableName, MAX_VARIABLE_NAME_SIZE, L"%s%d", Variab= leName, Index); + Status =3D VarLibGetVariable (TempVariableName, VendorGuid, NULL, &Varia= bleSize, NULL); + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + // + // Lock multiple variables. + // + + // + // Lock first variable and continue to rest of the variables. + // + DEBUG ((DEBUG_INFO, "Locking %s, Guid =3D %g\n", TempVariableName, Ven= dorGuid)); + Status =3D VarLibVariableRequestToLock (TempVariableName, VendorGuid); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "LockLargeVariable: Failed! Satus =3D %r\n", St= atus)); + return EFI_ABORTED; + } + for (Index =3D 1; Index < MAX_VARIABLE_SPLIT; Index++) { + ZeroMem (TempVariableName, MAX_VARIABLE_NAME_SIZE); + UnicodeSPrint (TempVariableName, MAX_VARIABLE_NAME_SIZE, L"%s%d", Va= riableName, Index); + + VariableSize =3D 0; + Status =3D VarLibGetVariable (TempVariableName, VendorGuid, NULL, &V= ariableSize, NULL); + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + DEBUG ((DEBUG_INFO, "Locking %s, Guid =3D %g\n", TempVariableName,= VendorGuid)); + Status =3D VarLibVariableRequestToLock (TempVariableName, VendorGu= id); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "LockLargeVariable: Failed! Satus =3D %r\n"= , Status)); + return EFI_ABORTED; + } + } else if (Status =3D=3D EFI_NOT_FOUND) { + // + // No more variables need to lock. + // + return EFI_SUCCESS; + } + } // End of for loop + } else if (Status =3D=3D EFI_NOT_FOUND) { + // + // Check if it is single variable scenario. + // + VariableSize =3D 0; + Status =3D VarLibGetVariable (VariableName, VendorGuid, NULL, &Variabl= eSize, NULL); + if (Status =3D=3D EFI_BUFFER_TOO_SMALL) { + // + // Lock single variable. + // + DEBUG ((DEBUG_INFO, "Locking %s, Guid =3D %g\n", VariableName, Vendo= rGuid)); + Status =3D VarLibVariableRequestToLock (VariableName, VendorGuid); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "LockLargeVariable: Failed! Satus =3D %r\n", = Status)); + return EFI_ABORTED; + } + return EFI_SUCCESS; + } + } + + // + // Here probably means variable not present. + // + return Status; + +} diff --git a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteL= ib/DxeRuntimeVariableWriteLib.c b/Platform/Intel/MinPlatformPkg/Library/Dxe= RuntimeVariableWriteLib/DxeRuntimeVariableWriteLib.c index 9ed59f8827..28730f858b 100644 --- a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeR= untimeVariableWriteLib.c +++ b/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeR= untimeVariableWriteLib.c @@ -10,7 +10,7 @@ Using this library allows code to be written in a generic manner that ca= n be used in DXE or SMM without modification. =20 - Copyright (c) 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -18,14 +18,16 @@ #include =20 #include -#include +#include =20 #include #include #include #include =20 -STATIC EDKII_VARIABLE_LOCK_PROTOCOL *mVariableWriteLibVariableLock =3D NU= LL; +STATIC EDKII_VARIABLE_POLICY_PROTOCOL *mVariableWriteLibVariablePolicy = =3D NULL; +EFI_EVENT mExitBootServiceEvent; +EFI_EVENT mLegacyBootEvent; =20 /** Sets the value of a variable. @@ -144,7 +146,7 @@ VarLibIsVariableRequestToLockSupported ( VOID ) { - if (mVariableWriteLibVariableLock !=3D NULL) { + if (mVariableWriteLibVariablePolicy !=3D NULL) { return TRUE; } else { return FALSE; @@ -178,16 +180,45 @@ VarLibVariableRequestToLock ( { EFI_STATUS Status =3D EFI_UNSUPPORTED; =20 - if (mVariableWriteLibVariableLock !=3D NULL) { - Status =3D mVariableWriteLibVariableLock->RequestToLock ( - mVariableWriteLibVariableLoc= k, - VariableName, - VendorGuid - ); + if (mVariableWriteLibVariablePolicy !=3D NULL) { + Status =3D RegisterBasicVariablePolicy ( + mVariableWriteLibVariablePolicy, + (CONST EFI_GUID*) VendorGuid, + (CONST CHAR16 *) VariableName, + VARIABLE_POLICY_NO_MIN_SIZE, + VARIABLE_POLICY_NO_MAX_SIZE, + VARIABLE_POLICY_NO_MUST_ATTR, + VARIABLE_POLICY_NO_CANT_ATTR, + VARIABLE_POLICY_TYPE_LOCK_NOW + ); } return Status; } =20 +/** + Close events when driver unloaded. + + @param[in] ImageHandle A handle for the image that is initializing this= driver + @param[in] SystemTable A pointer to the EFI system table + + @retval EFI_SUCCESS The initialization finished successfully. +**/ +EFI_STATUS +EFIAPI +DxeRuntimeVariableWriteLibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + if (mExitBootServiceEvent !=3D 0) { + gBS->CloseEvent (mExitBootServiceEvent); + } + if (mLegacyBootEvent !=3D 0) { + gBS->CloseEvent (mLegacyBootEvent); + } + return EFI_SUCCESS; +} + /** Exit Boot Services Event notification handler. =20 @@ -202,7 +233,7 @@ DxeRuntimeVariableWriteLibOnExitBootServices ( IN VOID *Context ) { - mVariableWriteLibVariableLock =3D NULL; + mVariableWriteLibVariablePolicy =3D NULL; } =20 /** @@ -227,13 +258,11 @@ DxeRuntimeVariableWriteLibConstructor ( ) { EFI_STATUS Status; - EFI_EVENT ExitBootServiceEvent; - EFI_EVENT LegacyBootEvent; =20 // // Locate VariableLockProtocol. // - Status =3D gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (= VOID **)&mVariableWriteLibVariableLock); + Status =3D gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL,= (VOID **)&mVariableWriteLibVariablePolicy); ASSERT_EFI_ERROR (Status); =20 // @@ -245,7 +274,7 @@ DxeRuntimeVariableWriteLibConstructor ( DxeRuntimeVariableWriteLibOnExitBootServices, NULL, &gEfiEventExitBootServicesGuid, - &ExitBootServiceEvent + &mExitBootServiceEvent ); ASSERT_EFI_ERROR (Status); =20 @@ -257,7 +286,7 @@ DxeRuntimeVariableWriteLibConstructor ( TPL_NOTIFY, DxeRuntimeVariableWriteLibOnExitBootServices, NULL, - &LegacyBootEvent + &mLegacyBootEvent ); ASSERT_EFI_ERROR (Status); =20 diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/Save= MemoryConfig.inf b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfi= g/SaveMemoryConfig.inf index e2dbd2fb49..61e85a6586 100644 --- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC= onfig.inf +++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC= onfig.inf @@ -1,7 +1,7 @@ ### @file # Component information file for SaveMemoryConfig module # -# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -25,6 +25,7 @@ BaseMemoryLib LargeVariableReadLib LargeVariableWriteLib + BaseLib =20 [Packages] MdePkg/MdePkg.dec diff --git a/Platform/Intel/MinPlatformPkg/Include/Library/LargeVariableWri= teLib.h b/Platform/Intel/MinPlatformPkg/Include/Library/LargeVariableWriteL= ib.h index c847d7f152..64b0090c2c 100644 --- a/Platform/Intel/MinPlatformPkg/Include/Library/LargeVariableWriteLib.h +++ b/Platform/Intel/MinPlatformPkg/Include/Library/LargeVariableWriteLib.h @@ -16,7 +16,7 @@ is possible, adjusting the value of PcdMaxVariableSize may provide a sim= pler solution to this problem. =20 - Copyright (c) 2021, Intel Corporation. All rights reserved.
+ Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -52,7 +52,7 @@ @retval EFI_DEVICE_ERROR The variable could not be retrieved due t= o a hardware error. @retval EFI_WRITE_PROTECTED The variable in question is read-only. @retval EFI_WRITE_PROTECTED The variable in question cannot be delete= d. - + @retval EFI_ABORTED LockVariable was requested but failed. @retval EFI_NOT_FOUND The variable trying to be updated or dele= ted was not found. =20 **/ @@ -66,4 +66,25 @@ SetLargeVariable ( IN VOID *Data ); =20 +/** + Locks the existing large variable. + + @param[in] VariableName A Null-terminated string that is the name= of the vendor's variable. + Each VariableName is unique for each Vend= orGuid. VariableName must + contain 1 or more characters. If Variable= Name is an empty string, + then EFI_INVALID_PARAMETER is returned. + @param[in] VendorGuid A unique identifier for the vendor. + @retval EFI_SUCCESS The firmware has successfully locked the = variable. + @retval EFI_INVALID_PARAMETER An invalid combination of variable name a= nd GUID was supplied + @retval EFI_UNSUPPORTED The service for locking variable is not r= eady. + @retval EFI_NOT_FOUND The targeting variable for locking is not= present. + @retval EFI_ABORTED Fail to lock variable. +**/ +EFI_STATUS +EFIAPI +LockLargeVariable ( + IN CHAR16 *VariableName, + IN EFI_GUID *VendorGuid + ); + #endif // _LARGE_VARIABLE_WRITE_LIB_H_ diff --git a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteL= ib/DxeRuntimeVariableWriteLib.inf b/Platform/Intel/MinPlatformPkg/Library/D= xeRuntimeVariableWriteLib/DxeRuntimeVariableWriteLib.inf index 704a8ac7cc..f83090c847 100644 --- a/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeR= untimeVariableWriteLib.inf +++ b/Platform/Intel/MinPlatformPkg/Library/DxeRuntimeVariableWriteLib/DxeR= untimeVariableWriteLib.inf @@ -10,7 +10,7 @@ # Using this library allows code to be written in a generic manner that ca= n be # used in DXE or SMM without modification. # -# Copyright (c) 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2021 - 2022, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -24,6 +24,7 @@ MODULE_TYPE =3D DXE_RUNTIME_DRIVER LIBRARY_CLASS =3D VariableWriteLib|DXE_CORE DXE_DRIVER = DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER CONSTRUCTOR =3D DxeRuntimeVariableWriteLibConstructor + DESTRUCTOR =3D DxeRuntimeVariableWriteLibDestructor =20 [Packages] MdePkg/MdePkg.dec @@ -37,13 +38,14 @@ UefiLib UefiBootServicesTableLib UefiRuntimeServicesTableLib + VariablePolicyHelperLib =20 [Guids] gEfiEventExitBootServicesGuid ## CONSUMES ## Event =20 [Protocols] gEfiVariableWriteArchProtocolGuid ## CONSUMES - gEdkiiVariableLockProtocolGuid ## CONSUMES + gEdkiiVariablePolicyProtocolGuid ## CONSUMES =20 [Depex] - gEfiVariableWriteArchProtocolGuid AND gEdkiiVariableLockProtocolGuid + gEfiVariableWriteArchProtocolGuid AND gEdkiiVariablePolicyProtocolGuid --=20 2.28.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 (#86614): https://edk2.groups.io/g/devel/message/86614 Mute This Topic: https://groups.io/mt/89067146/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-