From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web08.3282.1632369718863159010 for ; Wed, 22 Sep 2021 21:01:58 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: hao.shi@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="203256338" X-IronPort-AV: E=Sophos;i="5.85,315,1624345200"; d="scan'208";a="203256338" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 21:01:58 -0700 X-IronPort-AV: E=Sophos;i="5.85,315,1624345200"; d="scan'208";a="557967498" Received: from hshi1-mobl.ccr.corp.intel.com ([10.238.8.237]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2021 21:01:56 -0700 From: hao.shi@intel.com To: devel@edk2.groups.io Cc: Hao Shi , Dandan Bi Subject: [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS Date: Thu, 23 Sep 2021 12:01:38 +0800 Message-Id: <20210923040138.1960-1-hao.shi@intel.com> X-Mailer: git-send-email 2.33.0.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- .../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