From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.9894.1681207275097308526 for ; Tue, 11 Apr 2023 03:01:15 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=XbM69sGs; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: linus.liu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681207275; x=1712743275; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LgAS5yBQsTX4mz/CfDEqYr94WBQAyHhWrCS6x2YEU2g=; b=XbM69sGswwZIUvW1pBiackW+WEiOh/G10IwRe00JTlD5To07/0fvg7ZJ y64fABdBQsKTLK0YbT6fRWfW140r/YT4XqpICTOeYNS7zWZiKfgK/OUc/ QBSmi7zVdErLM01tkMvGznVs61Se62vjz6JhByRJ9TOtRuZD7hIfxvNgi 66zb5OtaTjVqKFjTUKt6RsTN0vmciH3su0sqJmx7vzb8DGDG4JCgk4SNG 0Fx3ntpo7aE9nOlbqC3hNdONx5NZFcp/MbmIwUkBG4Rttm/yga67ajQOr O/coJh23nyjqhKCEEjEOoWGJNkwM8LQ+pQldT1RjidlEpBOE/xI0YmGTh g==; X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="332260407" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="332260407" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2023 03:01:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="1018313708" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="1018313708" Received: from linusliu-desk1.gar.corp.intel.com ([10.5.215.134]) by fmsmga005.fm.intel.com with ESMTP; 11 Apr 2023 03:01:13 -0700 From: "Linus Liu" To: devel@edk2.groups.io Cc: Jiewen Yao , FST-FIR-PRC , FST FIR Server C , Maggie Chu Subject: [PATCH v1] Securitypkg/hddpassword: Update HddPasswordDxeInit to use Variable Policy Date: Tue, 11 Apr 2023 03:01:07 -0700 Message-Id: <20230411100107.1727-1-linus.liu@intel.com> X-Mailer: git-send-email 2.33.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4408 Change-Id: I3c4b466ef318766d6d70c9f73e36b94b5f10832c Cc: Jiewen Yao Cc: FST-FIR-PRC Cc: FST FIR Server C Cc: Maggie Chu Signed-off-by: Linus Liu --- SecurityPkg/HddPassword/HddPasswordDxe.c | 16 +++++++++++----- SecurityPkg/HddPassword/HddPasswordDxe.h | 1 - SecurityPkg/HddPassword/HddPasswordDxe.inf | 3 ++- SecurityPkg/SecurityPkg.dsc | 1 + 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/SecurityPkg/HddPassword/HddPasswordDxe.c b/SecurityPkg/HddPass= word/HddPasswordDxe.c index a1a63b67a4..c20fdbe83f 100644 --- a/SecurityPkg/HddPassword/HddPasswordDxe.c +++ b/SecurityPkg/HddPassword/HddPasswordDxe.c @@ -9,6 +9,7 @@ **/=0D =0D #include "HddPasswordDxe.h"=0D +#include =0D =0D EFI_GUID mHddPasswordVendorGuid =3D HDD_PASSWORD_CONFIG_GUID;= =0D CHAR16 mHddPasswordVendorStorageName[] =3D L"HDD_PASSWORD_CONFIG";=0D @@ -2822,7 +2823,7 @@ HddPasswordDxeInit ( HDD_PASSWORD_DXE_PRIVATE_DATA *Private;=0D VOID *Registration;=0D EFI_EVENT EndOfDxeEvent;=0D - EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;=0D + EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy;=0D =0D Private =3D NULL;=0D =0D @@ -2858,12 +2859,17 @@ HddPasswordDxeInit ( //=0D // Make HDD_PASSWORD_VARIABLE_NAME variable read-only.=0D //=0D - Status =3D gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (= VOID **)&VariableLock);=0D + Status =3D gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL,= (VOID **)&VariablePolicy);=0D if (!EFI_ERROR (Status)) {=0D - Status =3D VariableLock->RequestToLock (=0D - VariableLock,=0D + Status =3D RegisterBasicVariablePolicy (=0D + VariablePolicy,=0D + &mHddPasswordVendorGuid,=0D HDD_PASSWORD_VARIABLE_NAME,=0D - &mHddPasswordVendorGuid=0D + VARIABLE_POLICY_NO_MIN_SIZE,=0D + VARIABLE_POLICY_NO_MAX_SIZE,=0D + VARIABLE_POLICY_NO_MUST_ATTR,=0D + VARIABLE_POLICY_NO_CANT_ATTR,=0D + VARIABLE_POLICY_TYPE_LOCK_NOW=0D );=0D DEBUG ((DEBUG_INFO, "%a(): Lock %s variable (%r)\n", __FUNCTION__, HDD= _PASSWORD_VARIABLE_NAME, Status));=0D ASSERT_EFI_ERROR (Status);=0D diff --git a/SecurityPkg/HddPassword/HddPasswordDxe.h b/SecurityPkg/HddPass= word/HddPasswordDxe.h index 231533e737..049a208794 100644 --- a/SecurityPkg/HddPassword/HddPasswordDxe.h +++ b/SecurityPkg/HddPassword/HddPasswordDxe.h @@ -17,7 +17,6 @@ #include =0D #include =0D #include =0D -#include =0D =0D #include =0D #include =0D diff --git a/SecurityPkg/HddPassword/HddPasswordDxe.inf b/SecurityPkg/HddPa= ssword/HddPasswordDxe.inf index 06e8755ffc..2c0ebbcc78 100644 --- a/SecurityPkg/HddPassword/HddPasswordDxe.inf +++ b/SecurityPkg/HddPassword/HddPasswordDxe.inf @@ -50,6 +50,7 @@ PrintLib=0D UefiLib=0D LockBoxLib=0D + VariablePolicyHelperLib=0D S3BootScriptLib=0D PciLib=0D BaseCryptLib=0D @@ -63,7 +64,7 @@ gEfiHiiConfigAccessProtocolGuid ## PRODUCES=0D gEfiAtaPassThruProtocolGuid ## CONSUMES=0D gEfiPciIoProtocolGuid ## CONSUMES=0D - gEdkiiVariableLockProtocolGuid ## CONSUMES=0D + gEdkiiVariablePolicyProtocolGuid ## CONSUMES=0D =0D [Pcd]=0D gEfiSecurityPkgTokenSpaceGuid.PcdSkipHddPasswordPrompt ## CONSUMES=0D diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc index 3bad5375c0..3c62205162 100644 --- a/SecurityPkg/SecurityPkg.dsc +++ b/SecurityPkg/SecurityPkg.dsc @@ -74,6 +74,7 @@ PlatformPKProtectionLib|SecurityPkg/Library/PlatformPKProtectionLibVarPo= licy/PlatformPKProtectionLibVarPolicy.inf=0D SecureBootVariableProvisionLib|SecurityPkg/Library/SecureBootVariablePro= visionLib/SecureBootVariableProvisionLib.inf=0D TdxLib|MdePkg/Library/TdxLib/TdxLib.inf=0D + VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Var= iablePolicyHelperLib.inf=0D =0D [LibraryClasses.ARM, LibraryClasses.AARCH64]=0D #=0D --=20 2.33.1.windows.1