From nobody Sun May 19 06:23:03 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+81045+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+81045+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1632408576; cv=none; d=zohomail.com; s=zohoarc; b=ZR/lxslv6wuPaP42dQswbLp/9F14t+JB12T5YABj52MdDTcLAOr3ohISvqmKyqJkx26Kpk/kUitvfQGNI9Ijhx2Et5ibB54SyvIQPhT0ICpjqFVvh2VV4o6LJ0KGopZcWS4RbKdrj6QpEWZhn+6LfrVtiY7lscVUWi6rc0tD2FU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632408576; h=Content-Type:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=xrm75B/Ky7P4zIVvE8NEmYU0XMdyw1J5Cv/CAoEOqeo=; b=kctp9JZ6rvyUETWjxWJb03X8MnWEo5z/BJ3qzimBMRmf1+YXJZPujG/uq9mtkm+DHXNuctgvrY3s5LOk8HofKUbvgPgMRWcGov6cbA7/mxSKIoKooBwjrJkFPfGrjneYl/HNc4zZWP7eqMjwqeJpacLti5taE00ZnI0JjBgGPlU= 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+81045+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 1632408576245895.9266861274937; Thu, 23 Sep 2021 07:49:36 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id VzA6YY1788612xlqcpm3MxeY; Thu, 23 Sep 2021 07:49:35 -0700 Subject: [edk2-devel] [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS To: devel@edk2.groups.io From: "Shi, Hao" X-Originating-Location: CN (192.55.46.54) X-Originating-Platform: Windows Chrome 93 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Wed, 22 Sep 2021 21:42:51 -0700 Message-ID: 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,hao.shi@intel.com X-Gm-Message-State: FbrJXVXZfXbXXti4Js959TOVx1787277AA= Content-Type: multipart/alternative; boundary="OC0sRpE5vFGt0sFNhPkx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632408575; bh=RSTeokjydToJQQwhnKC5XhUJdGJvBVdql5FENuqBiR4=; h=Content-Type:Date:From:Reply-To:Subject:To; b=BsnUZ+G2EqPv7QJVdko0qqlHJaFVrpCfnzmeRazb2j1/8FO43Jco+pzX0/Hw6ZMFTWX l70MkrIKChyfZFsM0rt1Yqth8+sq9/n8rKvi1dpMDYM/CeRtlTydSQDm1mPhgR9QvSqEc mtSep2zCWBC4nEUCZ7Eo4NM1oa+2ucg+SMg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632408577276100001 --OC0sRpE5vFGt0sFNhPkx Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3648 Register SmmExitBootServices and SmmLegacyBoot callback function to unregis= ter this handler. Signed-off-by: Hao Shi Cc: Dandan Bi Cc: Liming Gao --- .../UserAuthenticationSmm.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0| 34 +++++++++++++++++++ .../UserAuthenticationSmm.inf=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0|=C2=A0 2 ++ 2 files changed, 36 insertions(+) diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentica= tionDxeSmm/UserAuthenticationSmm.c b/Features/Intel/UserInterface/UserAuthF= eaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c index 07e834eb..30f889dd 100644 --- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxe= Smm/UserAuthenticationSmm.c +++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxe= Smm/UserAuthenticationSmm.c @@ -13,6 +13,7 @@ UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0mAdminPasswordTryCount =3D 0; BOOLEAN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0mNeedReVerify =3D TRUE; BOOLEAN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0mPasswordVerified =3D FALSE; +EFI_HANDLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 mSmmHandle =3D NULL; /** Verify if the password is correct. @@ -612,6 +613,30 @@ EXIT: return EFI_SUCCESS; } +/** +=C2=A0 Performs Exit Boot Services UserAuthentication actions + +=C2=A0 @param[in] Protocol=C2=A0 =C2=A0Points to the protocol's unique ide= ntifier. +=C2=A0 @param[in] Interface=C2=A0 Points to the interface instance. +=C2=A0 @param[in] Handle=C2=A0 =C2=A0 =C2=A0The handle on which the interf= ace was installed. + +=C2=A0 @retval EFI_SUCCESS=C2=A0 =C2=A0Notification runs successfully. +**/ +EFI_STATUS +EFIAPI +UaExitBootServices ( +=C2=A0 IN CONST EFI_GUID=C2=A0 =C2=A0 =C2=A0*Protocol, +=C2=A0 IN VOID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*Inte= rface, +=C2=A0 IN EFI_HANDLE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Handle +=C2=A0 ) +{ +=C2=A0 DEBUG ((DEBUG_INFO, "Unregister User Authentication Smi\n")); + +=C2=A0 gSmst->SmiHandlerUnRegister(mSmmHandle); + +=C2=A0 return EFI_SUCCESS; +} + /** Main entry for this driver. @@ -633,6 +658,7 @@ PasswordSmmInit ( EDKII_VARIABLE_LOCK_PROTOCOL=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *VariableLoc= k; CHAR16=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 PasswordHistoryName[sizeof(USER_= AUTHENTICATION_VAR_NAME)/sizeof(CHAR16) + 5]; UINTN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Index; +=C2=A0 EFI_EVENT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ExitBootServicesEvent; ASSERT (PASSWORD_HASH_SIZE =3D=3D SHA256_DIGEST_SIZE); ASSERT (PASSWORD_HISTORY_CHECK_COUNT < 0xFFFF); @@ -663,6 +689,14 @@ PasswordSmmInit ( if (EFI_ERROR (Status)) { return Status; } +=C2=A0 mSmmHandle =3D SmmHandle; +=C2=A0 // +=C2=A0 // Register for SmmExitBootServices and SmmLegacyBoot notification. +=C2=A0 // +=C2=A0 Status =3D gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmExitBootServ= icesProtocolGuid, UaExitBootServices, &ExitBootServicesEvent); +=C2=A0 ASSERT_EFI_ERROR (Status); +=C2=A0 Status =3D gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmLegacyBootPr= otocolGuid, UaExitBootServices, &ExitBootServicesEvent); +=C2=A0 ASSERT_EFI_ERROR (Status); if (IsPasswordCleared()) { DEBUG ((DEBUG_INFO, "IsPasswordCleared\n")); diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentica= tionDxeSmm/UserAuthenticationSmm.inf b/Features/Intel/UserInterface/UserAut= hFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf index 0b33b194..d73a2fe2 100644 --- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxe= Smm/UserAuthenticationSmm.inf +++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxe= Smm/UserAuthenticationSmm.inf @@ -48,6 +48,8 @@ [Protocols] gEdkiiVariableLockProtocolGuid=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 ## CONSUMES gEfiSmmVariableProtocolGuid=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0## CONSUMES +=C2=A0 gEdkiiSmmExitBootServicesProtocolGuid=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0## CONSUMES +=C2=A0 gEdkiiSmmLegacyBootProtocolGuid=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0## CONSUMES [Depex] gEfiSmmVariableProtocolGuid AND gEfiVariableWriteArchProtocolGuid -- 2.26.2.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 (#81045): https://edk2.groups.io/g/devel/message/81045 Mute This Topic: https://groups.io/mt/85815442/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- --OC0sRpE5vFGt0sFNhPkx Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
 
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3648
 
Register SmmExitBootServices and SmmLegacyBoot callback function to un= register this handler.
 
Signed-off-by: Hao Shi <hao.shi@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
 .../UserAuthenticationSmm.c          &n= bsp;        | 34 +++++++++++++++++++
 .../UserAuthenticationSmm.inf          =        |  2 ++
 2 files changed, 36 insertions(+)
 
diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthe= nticationDxeSmm/UserAuthenticationSmm.c b/Features/Intel/UserInterface/User= AuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
index 07e834eb..30f889dd 100644
--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticati= onDxeSmm/UserAuthenticationSmm.c
+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticati= onDxeSmm/UserAuthenticationSmm.c
@@ -13,6 +13,7 @@ UINTN             = ;              mAdminPasswordTryCount = =3D 0;
 
 BOOLEAN                &= nbsp;        mNeedReVerify =3D TRUE;
 BOOLEAN                &= nbsp;        mPasswordVerified =3D FALSE;
+EFI_HANDLE                &nb= sp;     mSmmHandle =3D NULL;
 
 /**
   Verify if the password is correct.
@@ -612,6 +613,30 @@ EXIT:
   return EFI_SUCCESS;
 }
 
+/**
+  Performs Exit Boot Services UserAuthentication actions
+
+  @param[in] Protocol   Points to the protocol's uniqu= e identifier.
+  @param[in] Interface  Points to the interface instance.
+  @param[in] Handle     The handle on which the i= nterface was installed.
+
+  @retval EFI_SUCCESS   Notification runs successfully= .
+**/
+EFI_STATUS
+EFIAPI
+UaExitBootServices (
+  IN CONST EFI_GUID     *Protocol,
+  IN VOID               = *Interface,
+  IN EFI_HANDLE         Handle
+  )
+{
+  DEBUG ((DEBUG_INFO, "Unregister User Authentication Smi\n"));<= /div>
+
+  gSmst->SmiHandlerUnRegister(mSmmHandle);
+
+  return EFI_SUCCESS;
+}
+
 /**
   Main entry for this driver.
 
@@ -633,6 +658,7 @@ PasswordSmmInit (
   EDKII_VARIABLE_LOCK_PROTOCOL        &= nbsp; *VariableLock;
   CHAR16              &n= bsp;                 PasswordHistor= yName[sizeof(USER_AUTHENTICATION_VAR_NAME)/sizeof(CHAR16) + 5];
   UINTN              &nb= sp;                  Index;
+  EFI_EVENT              &nbs= p;            ExitBootServicesEvent;
 
   ASSERT (PASSWORD_HASH_SIZE =3D=3D SHA256_DIGEST_SIZE);
   ASSERT (PASSWORD_HISTORY_CHECK_COUNT < 0xFFFF);
@@ -663,6 +689,14 @@ PasswordSmmInit (
   if (EFI_ERROR (Status)) {
     return Status;
   }
+  mSmmHandle =3D SmmHandle;
+  //
+  // Register for SmmExitBootServices and SmmLegacyBoot notifica= tion.
+  //
+  Status =3D gSmst->SmmRegisterProtocolNotify (&gEdkiiSmm= ExitBootServicesProtocolGuid, UaExitBootServices, &ExitBootServicesEven= t);
+  ASSERT_EFI_ERROR (Status);
+  Status =3D gSmst->SmmRegisterProtocolNotify (&gEdkiiSmm= LegacyBootProtocolGuid, UaExitBootServices, &ExitBootServicesEvent);
+  ASSERT_EFI_ERROR (Status);
 
   if (IsPasswordCleared()) {
     DEBUG ((DEBUG_INFO, "IsPasswordCleared\n"));
diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthe= nticationDxeSmm/UserAuthenticationSmm.inf b/Features/Intel/UserInterface/Us= erAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf
index 0b33b194..d73a2fe2 100644
--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticati= onDxeSmm/UserAuthenticationSmm.inf
+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticati= onDxeSmm/UserAuthenticationSmm.inf
@@ -48,6 +48,8 @@
 [Protocols]
   gEdkiiVariableLockProtocolGuid       =         ## CONSUMES
   gEfiSmmVariableProtocolGuid        &n= bsp;          ## CONSUMES
+  gEdkiiSmmExitBootServicesProtocolGuid      &nbs= p;  ## CONSUMES
+  gEdkiiSmmLegacyBootProtocolGuid        &nb= sp;      ## CONSUMES
 
 [Depex]
   gEfiSmmVariableProtocolGuid AND gEfiVariableWriteArchProt= ocolGuid
-- 
2.26.2.windows.1
 
_._,_._,_

G= roups.io Links:

You receive all messages sent to this group.

Vi= ew/Reply Online (#81045) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [importer@patchew.org]
_._,_._,_

=20 --OC0sRpE5vFGt0sFNhPkx--