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 CC81FD802F3 for ; Wed, 31 Jan 2024 05:06:15 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=31rIaW8UNap5YYkyq6t0g/dGERafsYI1bCz2tUNc7V8=; c=relaxed/simple; d=groups.io; h=From:To:Cc:References:In-Reply-To:Subject:Date:Message-ID:MIME-Version:Thread-Index:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding:Content-Language; s=20140610; t=1706677574; v=1; b=b2LQPedC9ulxSh2uHqzy+iNsiEHXiJioZLQF4M14g30bFd9XhUGxcjmjbXeGsGjzJaogqh9I yh9Yw3ZRvSI8E3RgbzZmuSAn1DfTvh1jsGSQqPs8ZuQO+kO5Bz31oKXcrU7OAD/6L190E/ZQvz1 l7xTDc8fFD9yWMV547mBIqqU= X-Received: by 127.0.0.2 with SMTP id xfVmYY7687511xSvPSUvBXiA; Tue, 30 Jan 2024 21:06:14 -0800 X-Received: from cxsh.intel-email.com (cxsh.intel-email.com [121.46.250.151]) by mx.groups.io with SMTP id smtpd.web10.7858.1706677573149616928 for ; Tue, 30 Jan 2024 21:06:13 -0800 X-Received: from cxsh.intel-email.com (localhost [127.0.0.1]) by cxsh.intel-email.com (Postfix) with ESMTP id E0E67DDA78D for ; Wed, 31 Jan 2024 13:06:10 +0800 (CST) X-Received: from localhost (localhost [127.0.0.1]) by cxsh.intel-email.com (Postfix) with ESMTP id DC799DDA78A for ; Wed, 31 Jan 2024 13:06:10 +0800 (CST) X-Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by cxsh.intel-email.com (Postfix) with SMTP id 3D30BDDA797 for ; Wed, 31 Jan 2024 13:06:07 +0800 (CST) X-Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP(SSL) for ; Wed, 31 Jan 2024 13:06:04 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 58.246.60.130 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming via groups.io" To: , Cc: "'Ray Ni'" , "'Michael D Kinney'" References: <20240122095323.1824627-1-zhi.jin@intel.com> In-Reply-To: <20240122095323.1824627-1-zhi.jin@intel.com> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF0gW1BBVENIIHYyIDEvMl0gTWRlTW9kdWxlUGtnOiBSZW1vdmUgdGhlIGhhbmRsZSB2YWxpZGF0aW9uIGNoZWNrIGluIENvcmVHZXRQcm90b2NvbEludGVyZmFjZQ==?= Date: Wed, 31 Jan 2024 13:06:06 +0800 Message-ID: <021301da5403$328fc950$97af5bf0$@byosoft.com.cn> MIME-Version: 1.0 Thread-Index: AQJVjJ3msac31u22jfgsddLALgMaVa/87Q7A 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,gaoliming@byosoft.com.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 7bhDkhNfE4wW7jkHng51zCh9x7686176AA= Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=b2LQPedC; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none Reviewed-by: Liming Gao > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: devel@edk2.groups.io =B4=FA=B1= =ED Zhi Jin > =B7=A2=CB=CD=CA=B1=BC=E4: 2024=C4=EA1=D4=C222=C8=D5 17:53 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Zhi Jin ; Liming Gao ; > Ray Ni ; Michael D Kinney > =D6=F7=CC=E2: [edk2-devel] [PATCH v2 1/2] MdeModulePkg: Remove the handle > validation check in CoreGetProtocolInterface >=20 > CoreGetProtocolInterface() is called by CoreOpenProtocol(), > CoreCloseProtocol() and CoreOpenProtocolInformation(). > Before CoreOpenProtocol() calls CoreGetProtocolInterface(), the input > parameter UserHandle has been already checked for validation. So does > CoreCloseProtocol(). > Removing the handle validation check in CoreGetProtocolInterface() > could improve the performance, as CoreOpenProtocol() is called very > frequently. > To ensure the assumption that the caller of CoreGetProtocolInterface() > must pass in a valid UserHandle that is checked with CoreValidateHandle()= , > add the parameter check in CoreOpenProtocolInformation(), and declare > CoreGetProtocolInterface() as static. >=20 > v1 -> v2: > 1. Update the description of UserHandle to state that the caller > must pass in a valid UserHandle that is checked with > CoreValidateHandle(). > 2. Declare CoreGetProtocolInterface() as static. >=20 > Cc: Liming Gao > Cc: Ray Ni > Cc: Michael D Kinney > Signed-off-by: Zhi Jin > --- > MdeModulePkg/Core/Dxe/Hand/Handle.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) >=20 > diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c > b/MdeModulePkg/Core/Dxe/Hand/Handle.c > index 51e5b5d3b3..24e4fbf5f3 100644 > --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c > +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c > @@ -918,28 +918,25 @@ CoreUninstallMultipleProtocolInterfaces ( > Locate a certain GUID protocol interface in a Handle's protocols. >=20 > @param UserHandle The handle to obtain the protocol > interface on > + The caller must pass in a valid > UserHandle that > + is checked with > CoreValidateHandle(). > @param Protocol The GUID of the protocol >=20 > @return The requested protocol interface for the handle >=20 > **/ > +STATIC > PROTOCOL_INTERFACE * > CoreGetProtocolInterface ( > IN EFI_HANDLE UserHandle, > IN EFI_GUID *Protocol > ) > { > - EFI_STATUS Status; > PROTOCOL_ENTRY *ProtEntry; > PROTOCOL_INTERFACE *Prot; > IHANDLE *Handle; > LIST_ENTRY *Link; >=20 > - Status =3D CoreValidateHandle (UserHandle); > - if (EFI_ERROR (Status)) { > - return NULL; > - } > - > Handle =3D (IHANDLE *)UserHandle; >=20 > // > @@ -1392,6 +1389,15 @@ CoreOpenProtocolInformation ( > // > CoreAcquireProtocolLock (); >=20 > + // > + // Check for invalid UserHandle > + // > + Status =3D CoreValidateHandle (UserHandle); > + if (EFI_ERROR (Status)) { > + Status =3D EFI_NOT_FOUND; > + goto Done; > + } > + > // > // Look at each protocol interface for a match > // > -- > 2.39.2 >=20 >=20 >=20 >=20 >=20 -=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 (#114857): https://edk2.groups.io/g/devel/message/114857 Mute This Topic: https://groups.io/mt/104069905/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-