From nobody Sat May 18 21:26:57 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+81190+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+81190+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1632794989; cv=none; d=zohomail.com; s=zohoarc; b=GIsYtq+NzXtdoqyL3MSAdqK6iV3nfPYiFnOZA1ZCZ/FdcmGZjCVOUsYc+52j0ToVDQe10O87StiGZ1Z0W0zO705cUgJkymog0yjOWU9MsWZKl3AMwhsrh90trtrUe0+82h7TJWNjoyzAgM33l4FgWZrhsu3J0/6PPjzr8EQEamw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632794989; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=7MH2mbaXm+oVm1mmf99eWKj9cdi3D9c5FMvbVm4O76g=; b=VgINQ2Jp+GfpnoLQCmfCk+BeJ7KGoRDawiJaE+60ysSuBUtxJ8izgMh5AatjmwKsrwwmcgDVxRYS6Bx9GDWz5J4+/HQwkNcXAYlx/VAljZ0QguRgHMAfb5WXtFHjWyO7HlKKKFaS/z6YHo6GpSQg+mLRMSvM0dHN8NW/mjJd4hw= 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+81190+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 1632794989008283.75497261213206; Mon, 27 Sep 2021 19:09:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aO6TYY1788612xJoZqbFN1Ci; Mon, 27 Sep 2021 19:09:48 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.8538.1632794987813496793 for ; Mon, 27 Sep 2021 19:09:48 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10120"; a="310150986" X-IronPort-AV: E=Sophos;i="5.85,328,1624345200"; d="scan'208";a="310150986" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2021 19:09:46 -0700 X-IronPort-AV: E=Sophos;i="5.85,328,1624345200"; d="scan'208";a="553725591" X-Received: from hshi1-mobl.ccr.corp.intel.com ([10.238.8.237]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2021 19:09:45 -0700 From: "Shi, Hao" To: devel@edk2.groups.io Cc: Hao Shi , Dandan Bi , Liming Gao Subject: [edk2-devel] [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS Date: Tue, 28 Sep 2021 10:09:15 +0800 Message-Id: <20210928020915.790-1-hao.shi@intel.com> MIME-Version: 1.0 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: ec8v7uWGoxy3hDsYEEyXaFPIx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1632794988; bh=NC4ZG2sYh1yE5tLDMdgMseGd8XkFMA/dtVKyOkF7s9A=; h=Cc:Date:From:Reply-To:Subject:To; b=LhEKrA79RdZZeIbMsctET0HTEZWF2g1z4lvqifnGwf4loOcQL2nb9QiYaB1ZNyk+TUU IkQpLd2PZdswSO98wdNwBRBhxpTUggdVFal2md0zpfgJl+lkpdXt/xlChcZs76qu/e/t7 fXX4b7LnTxi+xtGPc03vxdfnLUt3VnDdgKw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1632794990620100002 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Dandan Bi --- .../UserAuthenticationSmm.c | 39 +++++++++++++++++-- .../UserAuthenticationSmm.inf | 2 + 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentica= tionDxeSmm/UserAuthenticationSmm.c b/Features/Intel/UserInterface/UserAuthF= eaturePkg/UserAuthenticationDxeSmm/UserAuthenticationSmm.c index 07e834eb..3d66010b 100644 --- a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxe= Smm/UserAuthenticationSmm.c +++ b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDxe= Smm/UserAuthenticationSmm.c @@ -13,6 +13,7 @@ UINTN mAdminPasswordTryCount = =3D 0; =20 BOOLEAN mNeedReVerify =3D TRUE; BOOLEAN mPasswordVerified =3D FALSE; +EFI_HANDLE mSmmHandle =3D NULL; =20 /** Verify if the password is correct. @@ -612,6 +613,30 @@ EXIT: return EFI_SUCCESS; } =20 +/** + 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. =20 @@ -629,10 +654,11 @@ PasswordSmmInit ( ) { EFI_STATUS Status; - EFI_HANDLE SmmHandle; EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock; CHAR16 PasswordHistoryName[sizeof(USER_AU= THENTICATION_VAR_NAME)/sizeof(CHAR16) + 5]; UINTN Index; + EFI_EVENT ExitBootServicesEvent; + EFI_EVENT LegacyBootEvent; =20 ASSERT (PASSWORD_HASH_SIZE =3D=3D SHA256_DIGEST_SIZE); ASSERT (PASSWORD_HISTORY_CHECK_COUNT < 0xFFFF); @@ -657,13 +683,20 @@ PasswordSmmInit ( ASSERT_EFI_ERROR (Status); } =20 - SmmHandle =3D NULL; - Status =3D gSmst->SmiHandlerRegister (SmmPasswordHandler, &gUserAuthe= nticationGuid, &SmmHandle); + Status =3D gSmst->SmiHandlerRegister (SmmPasswordHandler, &gUserAuthenti= cationGuid, &mSmmHandle); ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { return Status; } =20 + // + // Register for SmmExitBootServices and SmmLegacyBoot notification. + // + Status =3D gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmExitBootServicesP= rotocolGuid, UaExitBootServices, &ExitBootServicesEvent); + ASSERT_EFI_ERROR (Status); + Status =3D gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmLegacyBootProtoco= lGuid, UaExitBootServices, &LegacyBootEvent); + ASSERT_EFI_ERROR (Status); + if (IsPasswordCleared()) { DEBUG ((DEBUG_INFO, "IsPasswordCleared\n")); SavePasswordToVariable (&gUserAuthenticationGuid, NULL, 0); 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 ## CONSUMES gEfiSmmVariableProtocolGuid ## CONSUMES + gEdkiiSmmExitBootServicesProtocolGuid ## CONSUMES + gEdkiiSmmLegacyBootProtocolGuid ## CONSUMES =20 [Depex] gEfiSmmVariableProtocolGuid AND gEfiVariableWriteArchProtocolGuid --=20 2.31.1.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 (#81190): https://edk2.groups.io/g/devel/message/81190 Mute This Topic: https://groups.io/mt/85815441/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-