From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web10.10061.1681208034364154482 for ; Tue, 11 Apr 2023 03:13:54 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Uz4EfF7N; spf=pass (domain: intel.com, ip: 192.55.52.93, 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=1681208034; x=1712744034; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=a0J4FjWCj1q7V3H5GKALLcjwkpjsgKGKfKgZIdpljoM=; b=Uz4EfF7NkUu0+5kW2RWmPlFMlQToFBzgpv5X15UDZbNNKFv/rk0fzefE 44qrJGm3yXRCmVrD+ftTUJaH9JoU8kdl88ye//Q9lPXWZ5rH2/ajxP9I/ c+R/E7dSoL06Q+Yg+Fs8rkwoTBqMINK1B4w4U3mRPe7CCu/6V8HHhSb6d qUXAbyLG/ljC8sXAejiYFJdq/XphYApwrJdHf/vBhSkPA/lQVmQp5PMNC XmJGXFK7cJDOGKJ+Z3ssQvGmuqFdBJqtu50ungAYoh3kbD8EUQ2EOWyfh pp5rdhdNUkKtoO7YscqhGEJ51rXoNtQGLnRSps/QdpCkg3TmKlfAX4/+P Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="341070616" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="341070616" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2023 03:13:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="721156513" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="721156513" Received: from linusliu-desk1.gar.corp.intel.com ([10.5.215.134]) by orsmga001.jf.intel.com with ESMTP; 11 Apr 2023 03:13:52 -0700 From: "Linus Liu" To: devel@edk2.groups.io Cc: Linus Liu , Jiewen Yao , Maggie Chu Subject: [PATCH v1] Securitypkg/hddpassword: Update HddPasswordDxeInit to use Variable Policy Date: Tue, 11 Apr 2023 03:13:40 -0700 Message-Id: <20230411101340.1799-1-linus.liu@intel.com> X-Mailer: git-send-email 2.33.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Linus Liu REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4408 Change-Id: I3c4b466ef318766d6d70c9f73e36b94b5f10832c Cc: Jiewen Yao 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