From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 3C62E9413CF for ; Fri, 1 Mar 2024 12:18:14 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=nOV4MA9/d2IjzUFIMpv88IqZvXHErhISWQXFFX7VziI=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1709295492; v=1; b=xHH1m/68Kmb4cCYHitL47d3DV/DtQaDkUtdzGq1UlEK29KpEu/4uYVH11o37r7Vlfm6TuvG9 JN4YbpFKjAvgvecD9PmVuSnmJmXJCDHpI6U9jj+79jJtU1tvBjcJ52kyQUqOkSKzzT0Gq2Q+a/3 ZpcYFu+kr2Pc89p5NavVPghU= X-Received: by 127.0.0.2 with SMTP id 62x3YY7687511x81iTWX6Sa3; Fri, 01 Mar 2024 04:18:12 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.21304.1709295492155368405 for ; Fri, 01 Mar 2024 04:18:12 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-651-o5M1mAd1MVem4QzCCcINsw-1; Fri, 01 Mar 2024 07:18:08 -0500 X-MC-Unique: o5M1mAd1MVem4QzCCcINsw-1 X-Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A17AB3CBD4E0; Fri, 1 Mar 2024 12:18:07 +0000 (UTC) X-Received: from [10.39.194.215] (unknown [10.39.194.215]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9502D492BC6; Fri, 1 Mar 2024 12:18:06 +0000 (UTC) Message-ID: <19af642d-acad-280e-aa2e-9a3bf657b2a6@redhat.com> Date: Fri, 1 Mar 2024 13:18:05 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v3 4/4] StandaloneMmPkg: Disallow unregister MMI handler in other MMI handler To: devel@edk2.groups.io, zhiguang.liu@intel.com Cc: Liming Gao , Jiaxin Wu , Ray Ni , Ard Biesheuvel , Sami Mujawar References: <20240301030133.628-1-zhiguang.liu@intel.com> <20240301030133.628-5-zhiguang.liu@intel.com> From: "Laszlo Ersek" In-Reply-To: <20240301030133.628-5-zhiguang.liu@intel.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk 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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: V6ySHtlEUHa5dyPyHY0d2BFDx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="xHH1m/68"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 3/1/24 04:01, Zhiguang Liu wrote: > In last patch, we add code support to unregister MMI handler inside > itself. However, the code doesn't support unregister MMI handler > insider other MMI handler. While this is not a must-have usage. > So add check to disallow unregister MMI handler in other MMI handler. >=20 > Cc: Liming Gao > Cc: Jiaxin Wu > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Cc: Sami Mujawar > Cc: Ray Ni > Signed-off-by: Zhiguang Liu > --- > StandaloneMmPkg/Core/Mmi.c | 32 +++++++++++++++++++++++--------- > 1 file changed, 23 insertions(+), 9 deletions(-) >=20 > diff --git a/StandaloneMmPkg/Core/Mmi.c b/StandaloneMmPkg/Core/Mmi.c > index c1a1d76e85..9e52072bf7 100644 > --- a/StandaloneMmPkg/Core/Mmi.c > +++ b/StandaloneMmPkg/Core/Mmi.c > @@ -36,8 +36,9 @@ typedef struct { > MMI_ENTRY *MmiEntry; > } MMI_HANDLER; > =20 > -LIST_ENTRY mRootMmiHandlerList =3D INITIALIZE_LIST_HEAD_VARIABLE (mRoot= MmiHandlerList); > -LIST_ENTRY mMmiEntryList =3D INITIALIZE_LIST_HEAD_VARIABLE (mMmiE= ntryList); > +LIST_ENTRY mRootMmiHandlerList =3D INITIALIZE_LIST_HEAD_VARIABLE (mRoo= tMmiHandlerList); > +LIST_ENTRY mMmiEntryList =3D INITIALIZE_LIST_HEAD_VARIABLE (mMmi= EntryList); > +MMI_HANDLER *mCurrentMmiHandler =3D NULL; > =20 > /** > Finds the MMI entry for the requested handler type. > @@ -161,13 +162,19 @@ MmiManage ( > // get next node before handler is executed, since LIST_ENTRY that > // Link points to may be freed if unregister MMI handler. > // > - Link =3D Link->ForwardLink; > - Status =3D MmiHandler->Handler ( > - (EFI_HANDLE)MmiHandler, > - Context, > - CommBuffer, > - CommBufferSize > - ); > + Link =3D Link->ForwardLink; > + // > + // Assign gCurrentMmiHandle before calling the MMI handler and > + // set to NULL when it returns. > + // > + mCurrentMmiHandler =3D MmiHandler; > + Status =3D MmiHandler->Handler ( > + (EFI_HANDLE)MmiHandler, > + Context, > + CommBuffer, > + CommBufferSize > + ); > + mCurrentMmiHandler =3D NULL; > =20 > switch (Status) { > case EFI_INTERRUPT_PENDING: > @@ -314,6 +321,13 @@ MmiHandlerUnRegister ( > return EFI_INVALID_PARAMETER; > } > =20 > + // > + // Do not allow to unregister MMI Handler inside other MMI Handler > + // > + if ((mCurrentMmiHandler !=3D NULL) && (mCurrentMmiHandler !=3D MmiHand= ler)) { > + return EFI_INVALID_PARAMETER; > + } > + > MmiEntry =3D MmiHandler->MmiEntry; > =20 > RemoveEntryList (&MmiHandler->Link); Reviewed-by: Laszlo Ersek -=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 (#116241): https://edk2.groups.io/g/devel/message/116241 Mute This Topic: https://groups.io/mt/104657669/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-