public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS
@ 2021-09-23  3:52 Shi, Hao
  0 siblings, 0 replies; 7+ messages in thread
From: Shi, Hao @ 2021-09-23  3:52 UTC (permalink / raw)
  To: devel@edk2.groups.io

[-- Attachment #1: Type: text/plain, Size: 3966 bytes --]

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



Register SmmExitBootServices and SmmLegacyBoot callback function to unregister this handler.



Signed-off-by: Hao Shi <hao.shi@intel.com<mailto:hao.shi@intel.com>>



---

.../UserAuthenticationSmm.c                   | 34 +++++++++++++++++++

.../UserAuthenticationSmm.inf                 |  2 ++

2 files changed, 36 insertions(+)



diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c

index 07e834eb..30f889dd 100644

--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c

+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentication

+++ DxeSmm/UserAuthenticationSmm.c

@@ -13,6 +13,7 @@ UINTN                           mAdminPasswordTryCount = 0;

 BOOLEAN                         mNeedReVerify = TRUE;

BOOLEAN                         mPasswordVerified = FALSE;

+EFI_HANDLE                      mSmmHandle = 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 unique identifier.

+  @param[in] Interface  Points to the interface instance.

+  @param[in] Handle     The handle on which the interface 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"));

+

+  gSmst->SmiHandlerUnRegister(mSmmHandle);

+

+  return EFI_SUCCESS;

+}

+

/**

   Main entry for this driver.

@@ -633,6 +658,7 @@ PasswordSmmInit (

   EDKII_VARIABLE_LOCK_PROTOCOL          *VariableLock;

   CHAR16                                PasswordHistoryName[sizeof(USER_AUTHENTICATION_VAR_NAME)/sizeof(CHAR16) + 5];

   UINTN                                 Index;

+  EFI_EVENT                           ExitBootServicesEvent;

   ASSERT (PASSWORD_HASH_SIZE == SHA256_DIGEST_SIZE);

   ASSERT (PASSWORD_HISTORY_CHECK_COUNT < 0xFFFF); @@ -663,6 +689,14 @@ PasswordSmmInit (

   if (EFI_ERROR (Status)) {

     return Status;

   }

+  mSmmHandle = SmmHandle;

+  //

+  // Register for SmmExitBootServices and SmmLegacyBoot notification.

+  //

+  Status = gSmst->SmmRegisterProtocolNotify

+ (&gEdkiiSmmExitBootServicesProtocolGuid, UaExitBootServices,

+ &ExitBootServicesEvent);  ASSERT_EFI_ERROR (Status);  Status =

+ gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmLegacyBootProtocolGuid,

+ UaExitBootServices, &ExitBootServicesEvent);  ASSERT_EFI_ERROR

+ (Status);

   if (IsPasswordCleared()) {

     DEBUG ((DEBUG_INFO, "IsPasswordCleared\n")); diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf

index 0b33b194..d73a2fe2 100644

--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf

+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentication

+++ DxeSmm/UserAuthenticationSmm.inf

@@ -48,6 +48,8 @@

[Protocols]

   gEdkiiVariableLockProtocolGuid                ## CONSUMES

   gEfiSmmVariableProtocolGuid                   ## CONSUMES

+  gEdkiiSmmExitBootServicesProtocolGuid         ## CONSUMES

+  gEdkiiSmmLegacyBootProtocolGuid               ## CONSUMES

 [Depex]

   gEfiSmmVariableProtocolGuid AND gEfiVariableWriteArchProtocolGuid

--

2.26.2.windows.1




[-- Attachment #2: Type: text/html, Size: 11554 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS
@ 2021-09-23  4:01 hao.shi
  2021-09-27 11:58 ` Dandan Bi
  0 siblings, 1 reply; 7+ messages in thread
From: hao.shi @ 2021-09-23  4:01 UTC (permalink / raw)
  To: devel; +Cc: Hao Shi, Dandan Bi

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

Register SmmExitBootServices and SmmLegacyBoot callback function to unregister this handler.

Signed-off-by: Hao Shi <hao.shi@intel.com>

---
 .../UserAuthenticationSmm.c                   | 34 +++++++++++++++++++
 .../UserAuthenticationSmm.inf                 |  2 ++
 2 files changed, 36 insertions(+)

diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
index 07e834eb..30f889dd 100644
--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
@@ -13,6 +13,7 @@ UINTN                           mAdminPasswordTryCount = 0;
 
 BOOLEAN                         mNeedReVerify = TRUE;
 BOOLEAN                         mPasswordVerified = FALSE;
+EFI_HANDLE                      mSmmHandle = 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 unique identifier.
+  @param[in] Interface  Points to the interface instance.
+  @param[in] Handle     The handle on which the interface 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"));
+
+  gSmst->SmiHandlerUnRegister(mSmmHandle);
+
+  return EFI_SUCCESS;
+}
+
 /**
   Main entry for this driver.
 
@@ -633,6 +658,7 @@ PasswordSmmInit (
   EDKII_VARIABLE_LOCK_PROTOCOL          *VariableLock;
   CHAR16                                PasswordHistoryName[sizeof(USER_AUTHENTICATION_VAR_NAME)/sizeof(CHAR16) + 5];
   UINTN                                 Index;
+  EFI_EVENT                           ExitBootServicesEvent;
 
   ASSERT (PASSWORD_HASH_SIZE == SHA256_DIGEST_SIZE);
   ASSERT (PASSWORD_HISTORY_CHECK_COUNT < 0xFFFF);
@@ -663,6 +689,14 @@ PasswordSmmInit (
   if (EFI_ERROR (Status)) {
     return Status;
   }
+  mSmmHandle = SmmHandle;
+  //
+  // Register for SmmExitBootServices and SmmLegacyBoot notification.
+  //
+  Status = gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmExitBootServicesProtocolGuid, UaExitBootServices, &ExitBootServicesEvent);
+  ASSERT_EFI_ERROR (Status);
+  Status = gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmLegacyBootProtocolGuid, UaExitBootServices, &ExitBootServicesEvent);
+  ASSERT_EFI_ERROR (Status);
 
   if (IsPasswordCleared()) {
     DEBUG ((DEBUG_INFO, "IsPasswordCleared\n"));
diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf
index 0b33b194..d73a2fe2 100644
--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf
+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf
@@ -48,6 +48,8 @@
 [Protocols]
   gEdkiiVariableLockProtocolGuid                ## CONSUMES
   gEfiSmmVariableProtocolGuid                   ## CONSUMES
+  gEdkiiSmmExitBootServicesProtocolGuid         ## CONSUMES
+  gEdkiiSmmLegacyBootProtocolGuid               ## CONSUMES
 
 [Depex]
   gEfiSmmVariableProtocolGuid AND gEfiVariableWriteArchProtocolGuid
-- 
2.26.2.windows.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS
@ 2021-09-23  4:42 Shi, Hao
  0 siblings, 0 replies; 7+ messages in thread
From: Shi, Hao @ 2021-09-23  4:42 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 3985 bytes --]

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

Register SmmExitBootServices and SmmLegacyBoot callback function to unregister 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                   | 34 +++++++++++++++++++
.../UserAuthenticationSmm.inf                 |  2 ++
2 files changed, 36 insertions(+)

diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
index 07e834eb..30f889dd 100644
--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
@@ -13,6 +13,7 @@ UINTN                           mAdminPasswordTryCount = 0;

BOOLEAN                         mNeedReVerify = TRUE;
BOOLEAN                         mPasswordVerified = FALSE;
+EFI_HANDLE                      mSmmHandle = 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 unique identifier.
+  @param[in] Interface  Points to the interface instance.
+  @param[in] Handle     The handle on which the interface 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"));
+
+  gSmst->SmiHandlerUnRegister(mSmmHandle);
+
+  return EFI_SUCCESS;
+}
+
/**
Main entry for this driver.

@@ -633,6 +658,7 @@ PasswordSmmInit (
EDKII_VARIABLE_LOCK_PROTOCOL          *VariableLock;
CHAR16                                PasswordHistoryName[sizeof(USER_AUTHENTICATION_VAR_NAME)/sizeof(CHAR16) + 5];
UINTN                                 Index;
+  EFI_EVENT                           ExitBootServicesEvent;

ASSERT (PASSWORD_HASH_SIZE == SHA256_DIGEST_SIZE);
ASSERT (PASSWORD_HISTORY_CHECK_COUNT < 0xFFFF);
@@ -663,6 +689,14 @@ PasswordSmmInit (
if (EFI_ERROR (Status)) {
return Status;
}
+  mSmmHandle = SmmHandle;
+  //
+  // Register for SmmExitBootServices and SmmLegacyBoot notification.
+  //
+  Status = gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmExitBootServicesProtocolGuid, UaExitBootServices, &ExitBootServicesEvent);
+  ASSERT_EFI_ERROR (Status);
+  Status = gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmLegacyBootProtocolGuid, UaExitBootServices, &ExitBootServicesEvent);
+  ASSERT_EFI_ERROR (Status);

if (IsPasswordCleared()) {
DEBUG ((DEBUG_INFO, "IsPasswordCleared\n"));
diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf
index 0b33b194..d73a2fe2 100644
--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf
+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf
@@ -48,6 +48,8 @@
[Protocols]
gEdkiiVariableLockProtocolGuid                ## CONSUMES
gEfiSmmVariableProtocolGuid                   ## CONSUMES
+  gEdkiiSmmExitBootServicesProtocolGuid         ## CONSUMES
+  gEdkiiSmmLegacyBootProtocolGuid               ## CONSUMES

[Depex]
gEfiSmmVariableProtocolGuid AND gEfiVariableWriteArchProtocolGuid
--
2.26.2.windows.1

[-- Attachment #2: Type: text/html, Size: 6244 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS
  2021-09-23  4:01 hao.shi
@ 2021-09-27 11:58 ` Dandan Bi
  0 siblings, 0 replies; 7+ messages in thread
From: Dandan Bi @ 2021-09-27 11:58 UTC (permalink / raw)
  To: Shi, Hao, devel@edk2.groups.io; +Cc: Liming Gao

Hi Hao,


Some minor comments below. Please check inline.



Thanks,
Dandan

> -----Original Message-----
> From: Shi, Hao <hao.shi@intel.com>
> Sent: Thursday, September 23, 2021 12:02 PM
> To: devel@edk2.groups.io
> Cc: Shi, Hao <hao.shi@intel.com>; Bi, Dandan <dandan.bi@intel.com>
> Subject: [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The
> SMI to handle the user authentication should be unregister before booting
> to OS
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3648
> 
> Register SmmExitBootServices and SmmLegacyBoot callback function to
> unregister this handler.
> 
> Signed-off-by: Hao Shi <hao.shi@intel.com>
> 
> ---
>  .../UserAuthenticationSmm.c                   | 34 +++++++++++++++++++
>  .../UserAuthenticationSmm.inf                 |  2 ++
>  2 files changed, 36 insertions(+)
> 
> diff --git
> a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.c
> b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.c
> index 07e834eb..30f889dd 100644
> ---
> a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.c
> +++
> b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentication
> +++ DxeSmm/UserAuthenticationSmm.c
> @@ -13,6 +13,7 @@ UINTN                           mAdminPasswordTryCount = 0;
> 
>  BOOLEAN                         mNeedReVerify = TRUE;
>  BOOLEAN                         mPasswordVerified = FALSE;
> +EFI_HANDLE                      mSmmHandle = 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 unique identifier.
> +  @param[in] Interface  Points to the interface instance.
> +  @param[in] Handle     The handle on which the interface 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"));
> +
> +  gSmst->SmiHandlerUnRegister(mSmmHandle);
> +
> +  return EFI_SUCCESS;
> +}
> +
>  /**
>    Main entry for this driver.
> 
> @@ -633,6 +658,7 @@ PasswordSmmInit (
>    EDKII_VARIABLE_LOCK_PROTOCOL          *VariableLock;
>    CHAR16
> PasswordHistoryName[sizeof(USER_AUTHENTICATION_VAR_NAME)/sizeof(
> CHAR16) + 5];
>    UINTN                                 Index;
> +  EFI_EVENT                           ExitBootServicesEvent;
Please take care the alignment between new added code and old ones.

> 
>    ASSERT (PASSWORD_HASH_SIZE == SHA256_DIGEST_SIZE);
>    ASSERT (PASSWORD_HISTORY_CHECK_COUNT < 0xFFFF); @@ -663,6
> +689,14 @@ PasswordSmmInit (
>    if (EFI_ERROR (Status)) {
>      return Status;
>    }
> +  mSmmHandle = SmmHandle;
Could we only use one global variable for register and unregister? Then can remove this statement.

> +  //
> +  // Register for SmmExitBootServices and SmmLegacyBoot notification.
> +  //
> +  Status = gSmst->SmmRegisterProtocolNotify
> + (&gEdkiiSmmExitBootServicesProtocolGuid, UaExitBootServices,
> + &ExitBootServicesEvent);  ASSERT_EFI_ERROR (Status);  Status =
> + gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmLegacyBootProtocolGuid,
> + UaExitBootServices, &ExitBootServicesEvent);  ASSERT_EFI_ERROR
> + (Status);

Could we not use &ExitBootServicesEvent for these two RegisterProtocolNotify? One generic name for both or two specific names for each?

> 
>    if (IsPasswordCleared()) {
>      DEBUG ((DEBUG_INFO, "IsPasswordCleared\n")); diff --git
> a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.inf
> b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.inf
> index 0b33b194..d73a2fe2 100644
> ---
> a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.inf
> +++
> b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentication
> +++ DxeSmm/UserAuthenticationSmm.inf
> @@ -48,6 +48,8 @@
>  [Protocols]
>    gEdkiiVariableLockProtocolGuid                ## CONSUMES
>    gEfiSmmVariableProtocolGuid                   ## CONSUMES
> +  gEdkiiSmmExitBootServicesProtocolGuid         ## CONSUMES
> +  gEdkiiSmmLegacyBootProtocolGuid               ## CONSUMES
> 
>  [Depex]
>    gEfiSmmVariableProtocolGuid AND gEfiVariableWriteArchProtocolGuid
> --
> 2.26.2.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS
@ 2021-09-28  2:09 Shi, Hao
  2021-10-08  1:43 ` Dandan Bi
  0 siblings, 1 reply; 7+ messages in thread
From: Shi, Hao @ 2021-09-28  2:09 UTC (permalink / raw)
  To: devel; +Cc: Hao Shi, Dandan Bi, Liming Gao

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

Register SmmExitBootServices and SmmLegacyBoot callback function to unregister 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                   | 39 +++++++++++++++++--
 .../UserAuthenticationSmm.inf                 |  2 +
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
index 07e834eb..3d66010b 100644
--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c
@@ -13,6 +13,7 @@ UINTN                           mAdminPasswordTryCount = 0;
 
 BOOLEAN                         mNeedReVerify = TRUE;
 BOOLEAN                         mPasswordVerified = FALSE;
+EFI_HANDLE                      mSmmHandle = 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 unique identifier.
+  @param[in] Interface  Points to the interface instance.
+  @param[in] Handle     The handle on which the interface 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"));
+
+  gSmst->SmiHandlerUnRegister(mSmmHandle);
+
+  return EFI_SUCCESS;
+}
+
 /**
   Main entry for this driver.
 
@@ -629,10 +654,11 @@ PasswordSmmInit (
   )
 {
   EFI_STATUS                            Status;
-  EFI_HANDLE                            SmmHandle;
   EDKII_VARIABLE_LOCK_PROTOCOL          *VariableLock;
   CHAR16                                PasswordHistoryName[sizeof(USER_AUTHENTICATION_VAR_NAME)/sizeof(CHAR16) + 5];
   UINTN                                 Index;
+  EFI_EVENT                             ExitBootServicesEvent;
+  EFI_EVENT                             LegacyBootEvent;
 
   ASSERT (PASSWORD_HASH_SIZE == SHA256_DIGEST_SIZE);
   ASSERT (PASSWORD_HISTORY_CHECK_COUNT < 0xFFFF);
@@ -657,13 +683,20 @@ PasswordSmmInit (
     ASSERT_EFI_ERROR (Status);
   }
 
-  SmmHandle = NULL;
-  Status    = gSmst->SmiHandlerRegister (SmmPasswordHandler, &gUserAuthenticationGuid, &SmmHandle);
+  Status = gSmst->SmiHandlerRegister (SmmPasswordHandler, &gUserAuthenticationGuid, &mSmmHandle);
   ASSERT_EFI_ERROR (Status);
   if (EFI_ERROR (Status)) {
     return Status;
   }
 
+  //
+  // Register for SmmExitBootServices and SmmLegacyBoot notification.
+  //
+  Status = gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmExitBootServicesProtocolGuid, UaExitBootServices, &ExitBootServicesEvent);
+  ASSERT_EFI_ERROR (Status);
+  Status = gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmLegacyBootProtocolGuid, UaExitBootServices, &LegacyBootEvent);
+  ASSERT_EFI_ERROR (Status);
+
   if (IsPasswordCleared()) {
     DEBUG ((DEBUG_INFO, "IsPasswordCleared\n"));
     SavePasswordToVariable (&gUserAuthenticationGuid, NULL, 0);
diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf
index 0b33b194..d73a2fe2 100644
--- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf
+++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.inf
@@ -48,6 +48,8 @@
 [Protocols]
   gEdkiiVariableLockProtocolGuid                ## CONSUMES
   gEfiSmmVariableProtocolGuid                   ## CONSUMES
+  gEdkiiSmmExitBootServicesProtocolGuid         ## CONSUMES
+  gEdkiiSmmLegacyBootProtocolGuid               ## CONSUMES
 
 [Depex]
   gEfiSmmVariableProtocolGuid AND gEfiVariableWriteArchProtocolGuid
-- 
2.31.1.windows.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS
  2021-09-28  2:09 [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS Shi, Hao
@ 2021-10-08  1:43 ` Dandan Bi
  2021-10-13  2:39   ` Dandan Bi
  0 siblings, 1 reply; 7+ messages in thread
From: Dandan Bi @ 2021-10-08  1:43 UTC (permalink / raw)
  To: Shi, Hao, devel@edk2.groups.io; +Cc: Liming Gao

Reviewed-by: Dandan Bi <dandan.bi@intel.com>



Thanks,
Dandan

> -----Original Message-----
> From: Shi, Hao <hao.shi@intel.com>
> Sent: Tuesday, September 28, 2021 10:09 AM
> To: devel@edk2.groups.io
> Cc: Shi, Hao <hao.shi@intel.com>; Bi, Dandan <dandan.bi@intel.com>;
> Liming Gao <gaoliming@byosoft.com.cn>
> Subject: [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The
> SMI to handle the user authentication should be unregister before booting
> to OS
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3648
> 
> Register SmmExitBootServices and SmmLegacyBoot callback function to
> unregister 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                   | 39 +++++++++++++++++--
>  .../UserAuthenticationSmm.inf                 |  2 +
>  2 files changed, 38 insertions(+), 3 deletions(-)
> 
> diff --git
> a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.c
> b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.c
> index 07e834eb..3d66010b 100644
> ---
> a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.c
> +++
> b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentication
> +++ DxeSmm/UserAuthenticationSmm.c
> @@ -13,6 +13,7 @@ UINTN                           mAdminPasswordTryCount = 0;
> 
>  BOOLEAN                         mNeedReVerify = TRUE;
>  BOOLEAN                         mPasswordVerified = FALSE;
> +EFI_HANDLE                      mSmmHandle = 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 unique identifier.
> +  @param[in] Interface  Points to the interface instance.
> +  @param[in] Handle     The handle on which the interface 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"));
> +
> +  gSmst->SmiHandlerUnRegister(mSmmHandle);
> +
> +  return EFI_SUCCESS;
> +}
> +
>  /**
>    Main entry for this driver.
> 
> @@ -629,10 +654,11 @@ PasswordSmmInit (
>    )
>  {
>    EFI_STATUS                            Status;
> -  EFI_HANDLE                            SmmHandle;
>    EDKII_VARIABLE_LOCK_PROTOCOL          *VariableLock;
>    CHAR16
> PasswordHistoryName[sizeof(USER_AUTHENTICATION_VAR_NAME)/sizeof(
> CHAR16) + 5];
>    UINTN                                 Index;
> +  EFI_EVENT                             ExitBootServicesEvent;
> +  EFI_EVENT                             LegacyBootEvent;
> 
>    ASSERT (PASSWORD_HASH_SIZE == SHA256_DIGEST_SIZE);
>    ASSERT (PASSWORD_HISTORY_CHECK_COUNT < 0xFFFF); @@ -657,13
> +683,20 @@ PasswordSmmInit (
>      ASSERT_EFI_ERROR (Status);
>    }
> 
> -  SmmHandle = NULL;
> -  Status    = gSmst->SmiHandlerRegister (SmmPasswordHandler,
> &gUserAuthenticationGuid, &SmmHandle);
> +  Status = gSmst->SmiHandlerRegister (SmmPasswordHandler,
> + &gUserAuthenticationGuid, &mSmmHandle);
>    ASSERT_EFI_ERROR (Status);
>    if (EFI_ERROR (Status)) {
>      return Status;
>    }
> 
> +  //
> +  // Register for SmmExitBootServices and SmmLegacyBoot notification.
> +  //
> +  Status = gSmst->SmmRegisterProtocolNotify
> + (&gEdkiiSmmExitBootServicesProtocolGuid, UaExitBootServices,
> + &ExitBootServicesEvent);  ASSERT_EFI_ERROR (Status);  Status =
> + gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmLegacyBootProtocolGuid,
> + UaExitBootServices, &LegacyBootEvent);  ASSERT_EFI_ERROR (Status);
> +
>    if (IsPasswordCleared()) {
>      DEBUG ((DEBUG_INFO, "IsPasswordCleared\n"));
>      SavePasswordToVariable (&gUserAuthenticationGuid, NULL, 0); diff --git
> a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.inf
> b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.inf
> index 0b33b194..d73a2fe2 100644
> ---
> a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> eSmm/UserAuthenticationSmm.inf
> +++
> b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentication
> +++ DxeSmm/UserAuthenticationSmm.inf
> @@ -48,6 +48,8 @@
>  [Protocols]
>    gEdkiiVariableLockProtocolGuid                ## CONSUMES
>    gEfiSmmVariableProtocolGuid                   ## CONSUMES
> +  gEdkiiSmmExitBootServicesProtocolGuid         ## CONSUMES
> +  gEdkiiSmmLegacyBootProtocolGuid               ## CONSUMES
> 
>  [Depex]
>    gEfiSmmVariableProtocolGuid AND gEfiVariableWriteArchProtocolGuid
> --
> 2.31.1.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS
  2021-10-08  1:43 ` Dandan Bi
@ 2021-10-13  2:39   ` Dandan Bi
  0 siblings, 0 replies; 7+ messages in thread
From: Dandan Bi @ 2021-10-13  2:39 UTC (permalink / raw)
  To: Shi, Hao, devel@edk2.groups.io; +Cc: Liming Gao

Patch is submitted via commit 23ca68c23dd600973e961de4368abacf4db8c5c0
https://github.com/tianocore/edk2-platforms/commit/23ca68c23dd600973e961de4368abacf4db8c5c0



Thanks,
Dandan

> -----Original Message-----
> From: Bi, Dandan
> Sent: Friday, October 8, 2021 9:44 AM
> To: Shi, Hao <hao.shi@intel.com>; devel@edk2.groups.io
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Subject: RE: [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The
> SMI to handle the user authentication should be unregister before booting to OS
> 
> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
> 
> 
> 
> Thanks,
> Dandan
> 
> > -----Original Message-----
> > From: Shi, Hao <hao.shi@intel.com>
> > Sent: Tuesday, September 28, 2021 10:09 AM
> > To: devel@edk2.groups.io
> > Cc: Shi, Hao <hao.shi@intel.com>; Bi, Dandan <dandan.bi@intel.com>;
> > Liming Gao <gaoliming@byosoft.com.cn>
> > Subject: [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI
> > to handle the user authentication should be unregister before booting
> > to OS
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3648
> >
> > Register SmmExitBootServices and SmmLegacyBoot callback function to
> > unregister 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                   | 39 +++++++++++++++++--
> >  .../UserAuthenticationSmm.inf                 |  2 +
> >  2 files changed, 38 insertions(+), 3 deletions(-)
> >
> > diff --git
> > a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> > eSmm/UserAuthenticationSmm.c
> > b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> > eSmm/UserAuthenticationSmm.c
> > index 07e834eb..3d66010b 100644
> > ---
> > a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> > eSmm/UserAuthenticationSmm.c
> > +++
> > b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentication
> > +++ DxeSmm/UserAuthenticationSmm.c
> > @@ -13,6 +13,7 @@ UINTN                           mAdminPasswordTryCount = 0;
> >
> >  BOOLEAN                         mNeedReVerify = TRUE;
> >  BOOLEAN                         mPasswordVerified = FALSE;
> > +EFI_HANDLE                      mSmmHandle = 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 unique identifier.
> > +  @param[in] Interface  Points to the interface instance.
> > +  @param[in] Handle     The handle on which the interface 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"));
> > +
> > +  gSmst->SmiHandlerUnRegister(mSmmHandle);
> > +
> > +  return EFI_SUCCESS;
> > +}
> > +
> >  /**
> >    Main entry for this driver.
> >
> > @@ -629,10 +654,11 @@ PasswordSmmInit (
> >    )
> >  {
> >    EFI_STATUS                            Status;
> > -  EFI_HANDLE                            SmmHandle;
> >    EDKII_VARIABLE_LOCK_PROTOCOL          *VariableLock;
> >    CHAR16
> > PasswordHistoryName[sizeof(USER_AUTHENTICATION_VAR_NAME)/sizeof(
> > CHAR16) + 5];
> >    UINTN                                 Index;
> > +  EFI_EVENT                             ExitBootServicesEvent;
> > +  EFI_EVENT                             LegacyBootEvent;
> >
> >    ASSERT (PASSWORD_HASH_SIZE == SHA256_DIGEST_SIZE);
> >    ASSERT (PASSWORD_HISTORY_CHECK_COUNT < 0xFFFF); @@ -657,13
> > +683,20 @@ PasswordSmmInit (
> >      ASSERT_EFI_ERROR (Status);
> >    }
> >
> > -  SmmHandle = NULL;
> > -  Status    = gSmst->SmiHandlerRegister (SmmPasswordHandler,
> > &gUserAuthenticationGuid, &SmmHandle);
> > +  Status = gSmst->SmiHandlerRegister (SmmPasswordHandler,
> > + &gUserAuthenticationGuid, &mSmmHandle);
> >    ASSERT_EFI_ERROR (Status);
> >    if (EFI_ERROR (Status)) {
> >      return Status;
> >    }
> >
> > +  //
> > +  // Register for SmmExitBootServices and SmmLegacyBoot notification.
> > +  //
> > +  Status = gSmst->SmmRegisterProtocolNotify
> > + (&gEdkiiSmmExitBootServicesProtocolGuid, UaExitBootServices,
> > + &ExitBootServicesEvent);  ASSERT_EFI_ERROR (Status);  Status =
> > + gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmLegacyBootProtocolGuid,
> > + UaExitBootServices, &LegacyBootEvent);  ASSERT_EFI_ERROR (Status);
> > +
> >    if (IsPasswordCleared()) {
> >      DEBUG ((DEBUG_INFO, "IsPasswordCleared\n"));
> >      SavePasswordToVariable (&gUserAuthenticationGuid, NULL, 0); diff
> > --git
> > a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> > eSmm/UserAuthenticationSmm.inf
> > b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> > eSmm/UserAuthenticationSmm.inf
> > index 0b33b194..d73a2fe2 100644
> > ---
> > a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
> > eSmm/UserAuthenticationSmm.inf
> > +++
> > b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentication
> > +++ DxeSmm/UserAuthenticationSmm.inf
> > @@ -48,6 +48,8 @@
> >  [Protocols]
> >    gEdkiiVariableLockProtocolGuid                ## CONSUMES
> >    gEfiSmmVariableProtocolGuid                   ## CONSUMES
> > +  gEdkiiSmmExitBootServicesProtocolGuid         ## CONSUMES
> > +  gEdkiiSmmLegacyBootProtocolGuid               ## CONSUMES
> >
> >  [Depex]
> >    gEfiSmmVariableProtocolGuid AND gEfiVariableWriteArchProtocolGuid
> > --
> > 2.31.1.windows.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-10-13  2:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-28  2:09 [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS Shi, Hao
2021-10-08  1:43 ` Dandan Bi
2021-10-13  2:39   ` Dandan Bi
  -- strict thread matches above, loose matches on Subject: below --
2021-09-23  4:42 Shi, Hao
2021-09-23  4:01 hao.shi
2021-09-27 11:58 ` Dandan Bi
2021-09-23  3:52 Shi, Hao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox