Securitypkg/hddpassword: Update HddPasswordDxeInit to use Variable Policy

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4408

Cc: Jiewen Yao   <jiewen.yao@intel.com>
Cc: Maggie Chu   <maggie.chu@intel.com>
Cc: Kumar Rahul  <rahul.r.kumar@intel.com>
Signed-off-by: Linus Liu <linus.liu@intel.com>
Reviewed-by: Jiewen Yao   <jiewen.yao@intel.com>
This commit is contained in:
Linus Liu 2023-05-08 12:20:51 +08:00 committed by mergify[bot]
parent 8dbf868e02
commit d89492456f
4 changed files with 20 additions and 13 deletions

View File

@ -9,6 +9,7 @@
**/ **/
#include "HddPasswordDxe.h" #include "HddPasswordDxe.h"
#include <Library/VariablePolicyHelperLib.h>
EFI_GUID mHddPasswordVendorGuid = HDD_PASSWORD_CONFIG_GUID; EFI_GUID mHddPasswordVendorGuid = HDD_PASSWORD_CONFIG_GUID;
CHAR16 mHddPasswordVendorStorageName[] = L"HDD_PASSWORD_CONFIG"; CHAR16 mHddPasswordVendorStorageName[] = L"HDD_PASSWORD_CONFIG";
@ -2818,11 +2819,11 @@ HddPasswordDxeInit (
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
HDD_PASSWORD_DXE_PRIVATE_DATA *Private; HDD_PASSWORD_DXE_PRIVATE_DATA *Private;
VOID *Registration; VOID *Registration;
EFI_EVENT EndOfDxeEvent; EFI_EVENT EndOfDxeEvent;
EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock; EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy;
Private = NULL; Private = NULL;
@ -2858,13 +2859,18 @@ HddPasswordDxeInit (
// //
// Make HDD_PASSWORD_VARIABLE_NAME variable read-only. // Make HDD_PASSWORD_VARIABLE_NAME variable read-only.
// //
Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLock); Status = gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL, (VOID **)&VariablePolicy);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
Status = VariableLock->RequestToLock ( Status = RegisterBasicVariablePolicy (
VariableLock, VariablePolicy,
HDD_PASSWORD_VARIABLE_NAME, &mHddPasswordVendorGuid,
&mHddPasswordVendorGuid HDD_PASSWORD_VARIABLE_NAME,
); 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
);
DEBUG ((DEBUG_INFO, "%a(): Lock %s variable (%r)\n", __func__, HDD_PASSWORD_VARIABLE_NAME, Status)); DEBUG ((DEBUG_INFO, "%a(): Lock %s variable (%r)\n", __func__, HDD_PASSWORD_VARIABLE_NAME, Status));
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }

View File

@ -17,7 +17,6 @@
#include <Protocol/AtaPassThru.h> #include <Protocol/AtaPassThru.h>
#include <Protocol/PciIo.h> #include <Protocol/PciIo.h>
#include <Protocol/HiiConfigAccess.h> #include <Protocol/HiiConfigAccess.h>
#include <Protocol/VariableLock.h>
#include <Guid/MdeModuleHii.h> #include <Guid/MdeModuleHii.h>
#include <Guid/EventGroup.h> #include <Guid/EventGroup.h>

View File

@ -50,6 +50,7 @@
PrintLib PrintLib
UefiLib UefiLib
LockBoxLib LockBoxLib
VariablePolicyHelperLib
S3BootScriptLib S3BootScriptLib
PciLib PciLib
BaseCryptLib BaseCryptLib
@ -63,7 +64,7 @@
gEfiHiiConfigAccessProtocolGuid ## PRODUCES gEfiHiiConfigAccessProtocolGuid ## PRODUCES
gEfiAtaPassThruProtocolGuid ## CONSUMES gEfiAtaPassThruProtocolGuid ## CONSUMES
gEfiPciIoProtocolGuid ## CONSUMES gEfiPciIoProtocolGuid ## CONSUMES
gEdkiiVariableLockProtocolGuid ## CONSUMES gEdkiiVariablePolicyProtocolGuid ## CONSUMES
[Pcd] [Pcd]
gEfiSecurityPkgTokenSpaceGuid.PcdSkipHddPasswordPrompt ## CONSUMES gEfiSecurityPkgTokenSpaceGuid.PcdSkipHddPasswordPrompt ## CONSUMES

View File

@ -74,6 +74,7 @@
PlatformPKProtectionLib|SecurityPkg/Library/PlatformPKProtectionLibVarPolicy/PlatformPKProtectionLibVarPolicy.inf PlatformPKProtectionLib|SecurityPkg/Library/PlatformPKProtectionLibVarPolicy/PlatformPKProtectionLibVarPolicy.inf
SecureBootVariableProvisionLib|SecurityPkg/Library/SecureBootVariableProvisionLib/SecureBootVariableProvisionLib.inf SecureBootVariableProvisionLib|SecurityPkg/Library/SecureBootVariableProvisionLib/SecureBootVariableProvisionLib.inf
TdxLib|MdePkg/Library/TdxLib/TdxLib.inf TdxLib|MdePkg/Library/TdxLib/TdxLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
[LibraryClasses.ARM, LibraryClasses.AARCH64] [LibraryClasses.ARM, LibraryClasses.AARCH64]
# #