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 6E2DBD811C5 for ; Tue, 30 Jan 2024 09:13:49 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=+ax0xDuuwwGaF8twF4HhtNBZr8ANUUUYq6AqniGNPpc=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version: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=1706606028; v=1; b=up3z3wTrApD7gBm+3GeZ0jIemwzb6v8v62EgFW6Lc5YWpOfrpOjDb5fSw1URVv7oRQl8kLPH sIDosBbNTNmOA8wmzAVsIzZNGy/8++y1XaDoCZPTnJqwKz2hV/Aq7QTPmHsxHLV+800joFZI9HM xcmt9UyIzy/eqQfATAp0qjZY= X-Received: by 127.0.0.2 with SMTP id NShRYY7687511xFym1H6DopQ; Tue, 30 Jan 2024 01:13:48 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mx.groups.io with SMTP id smtpd.web10.14467.1706606027018498110 for ; Tue, 30 Jan 2024 01:13:47 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10968"; a="9858173" X-IronPort-AV: E=Sophos;i="6.05,707,1701158400"; d="scan'208";a="9858173" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2024 01:13:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10968"; a="878375109" X-IronPort-AV: E=Sophos;i="6.05,707,1701158400"; d="scan'208";a="878375109" X-Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by FMSMGA003.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 30 Jan 2024 01:13:44 -0800 X-Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 30 Jan 2024 01:13:43 -0800 X-Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Tue, 30 Jan 2024 01:13:43 -0800 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.101) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 30 Jan 2024 01:13:43 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m3lWWa45wJ99xbkwYyx8KESpqixfkDgQ2W4iwV42UAMb+yp6qr0bs2I+an+e83xdadFBMGRWGM5zKFbIsm/z/aRwgYBMwQgiQt1urWWxpStfWpbQsHZlyivDniSw40KLkLDjB0P7kRn29XWsdJGHhucJcBRBJCU3pH+DqGFNgctVCf7VbwX8BVjTbFLJ0CWF5ee3aHBkUdqIpproiiZzuiQPjZYiYf3eGcvB2cyEvgz+dNV+0nHx3tQiT+X88GxU2La19kFSGWk4VlsusoPGHBrfl60BoncF9a93mauYwy2rX0kIyXlYvNgBPwdzrNPV6dtzKEYCEdRWVSHbGX6DgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WcuZFJTHPsltcoLhfDDPKuZyvvJOai8k8Q3RLPO+a3g=; b=caLXjehVikHQP9F3nRwYmmnMjFZrFD6JueCeLQ6vmpyO0v3WvSDDNwN6kaYkJLgWLWd0hjrJj3FMrZtNv09KKm7WbDwkSokwbVDgBlgRVwWGXiVqStJnjKIQS8U+vEV2Kn2eyEgI9BmbJg34YkgiQrJ8GhfyTtnNFq/ynEfc6wBC6fgbMzIR6IN/vS5HBW/1Lot6704me+aAHn+QPVq1rq97Oa2N6FSaoIp0Jk0hQESAXQ9+92GPhjOQIS06FmZNSUIjynZ1GplhIQKYB7HdGjecqIBEa2lsCGW4g/cGYV1rKFNllZ52PhgFK6FA+lSCpcRRRHwBkt6HA2fr6E+aOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from CO1PR11MB5185.namprd11.prod.outlook.com (2603:10b6:303:6e::11) by PH0PR11MB5783.namprd11.prod.outlook.com (2603:10b6:510:128::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.22; Tue, 30 Jan 2024 09:13:41 +0000 X-Received: from CO1PR11MB5185.namprd11.prod.outlook.com ([fe80::4e82:ea54:a498:575a]) by CO1PR11MB5185.namprd11.prod.outlook.com ([fe80::4e82:ea54:a498:575a%6]) with mapi id 15.20.7228.029; Tue, 30 Jan 2024 09:13:41 +0000 From: "Zhi Jin" To: "Kinney, Michael D" , "devel@edk2.groups.io" CC: Liming Gao , "Ni, Ray" Subject: Re: [edk2-devel] [PATCH v2 1/2] MdeModulePkg: Remove the handle validation check in CoreGetProtocolInterface Thread-Topic: [PATCH v2 1/2] MdeModulePkg: Remove the handle validation check in CoreGetProtocolInterface Thread-Index: AQHaTRjKGgBAkf/DOUuxg2YuHVou+LDn+wcAgAof55A= Date: Tue, 30 Jan 2024 09:13:40 +0000 Message-ID: References: <20240122095323.1824627-1-zhi.jin@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO1PR11MB5185:EE_|PH0PR11MB5783:EE_ x-ms-office365-filtering-correlation-id: 9d970cf5-2ab7-4fc1-1aef-08dc2173c037 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: ZboD6FoCOm3vo1iFVShnvtgj+O9Q7tLMOE6TmCidNpkz52gkPQ786tMiwFYlCbwWwU+JIDpT82fVZJDVTlf71kOnXnL0aZy6T375Xj2lQXOol0VgvhkDDaF9WH5dexD97N7ek2z/jvJ3QWrPoLugrAiH7CHOgF1VqzUnKkeNCefDlyhCdSJCz23V+5HjeQsykYTac7XyDxPaQ2WP2kiUdvGXRSjBolVuhfLTajG76KfyjDV9Dbm4yJuU/c1ZjX++D2Xnz3OczxuGJIQtpVkGjeDaDOWhvLukd9mkpyzhD9G3s/5T9hA5OIFj3Pb6p7kJQBp2heEF3dnH5kffKbbxd+Kwm4mkmiTjmuzk8iPvi86R6iPjjkRuHZy7rfLwfehFqgWUxXge9jHsw7IjtVYDxoCJNxbsmobMOSkIp/LK1OBs7uvF8PAFMUuNKu8WU2k0OUgMwlz8Mqcg+Fd1QCZDt2XIfz3NuENPbQ72U9ZC5SaJOZgAP1mLfZfj7HPk+MLrncP00voOa2BPoxK6+IxsSFFDJzvfXIE2iIQXIPB+MMrGu/XLSdRcga7EDp8Nyv9prXnF9yfxWyda1Z3pUHzy5X5tc6/wQXhDq5ff+Q4OIKPi8nyTyrKy6ynK9PriDQSx x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?mPxceUAmPiTa1iLGOIqUfhG/MRFXjpsdlQRtLOW/L928nqGsr3peToSc7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zjY99CCAfWavTqBdgnrJeatwv/AO1ub50hKJo4b?= =?us-ascii?Q?lxC1fYi1P8BApBmYwJQ6shMgiD77WYdGvWmkT47PAQLr/AZMJ4anBvpxNn5t?= =?us-ascii?Q?yNzPC2aV7uc8ca0PBewWP7Vu7ULVa8wbqiIq0cCv8rh2JpwGmfff+FRkVOek?= =?us-ascii?Q?KFcZmqOSvfgVyADklpVDlGcSxEDi08wdz4S4+G1pDsuJLcRwGHA1JIaUAYi0?= =?us-ascii?Q?HryLHehsrEAyXUGnRLBQ+9dLhNKY5EYDepVNg+GwiqjlPHmD97Fr0jl/JFIL?= =?us-ascii?Q?TVz1S22WPMYs/n9tlFLKlFNC4HTsZIN/2JR0Vec8e8AJ4PIy6nmjVSN+lLTd?= =?us-ascii?Q?waHffcXDE/3muLDHTG+Ob9vHVIDnOuC71aqZHF+wy34binW9gNV6VKCiws4D?= =?us-ascii?Q?XdqFAzIG12zklzcdviA/Yw1L2RdoVnw2Jrl8clLphV00Ms78xcLQIScyimbm?= =?us-ascii?Q?F/59zKklkO+sv963fbkWxeKqWyH1eSowjxlNjo7NlMAARD7vOpT2LrqRb5u3?= =?us-ascii?Q?YwIRbZUG3UNjJ6vXx+AmPhRjOIaQsJ0cgnfTx2kxtRJVbw/IxlVkhQE4CZ2f?= =?us-ascii?Q?H3eXqTN5Y6dFIb0TCbS2UZ9TY9FhGjg3zDIjqp6ccoWuAyAGGaI6QiwSjdi7?= =?us-ascii?Q?KUmVHpY+1q8q7SK0Pus=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB5185.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d970cf5-2ab7-4fc1-1aef-08dc2173c037 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jan 2024 09:13:40.9180 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ID6IV4pbOWIKUxiLQP5pagjzXqK1mxa3Dbgs4xUDcSYW4AtDXE8PJzLjwdCs4y+UeiRWUG6jA3w4n3rpOP0qzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5783 X-OriginatorOrg: intel.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,zhi.jin@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 7aHmF1nwf9qgxftAOhGk6ZXxx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" 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=up3z3wTr; 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=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") Hi Mike, After changing 'STATIC' to 'static', I hit an error from the EccCheck Test= as below: ERROR - EFI coding style error ERROR - *Error code: 5001 ERROR - *Return type of a function should exist and in the first line ERROR - *file: /.../Build/.pytool/Plugin/EccCheck/MdeModulePkg/Core/Dxe/H= and/Handle.c ERROR - *Line number: 928 ERROR - *[CoreGetProtocolInterface] Return Type should appear at the star= t of line Looks like 'STATIC' is treated as a modifier by EccCheck, while 'static' i= s not. In BaseTools/Source/Python/Ecc/config.ini: ModifierList =3D IN, OUT, OPTIONAL, UNALIGNED, EFI_RUNTIMESERVICE, EFI_BO= OTSERVICE, EFIAPI, TPMINTERNALAPI, STATIC Should we add 'static' to ModifierList to fix this? BRs Zhi Jin -----Original Message----- From: Kinney, Michael D =20 Sent: Wednesday, January 24, 2024 6:22 AM To: Jin, Zhi ; devel@edk2.groups.io Cc: Liming Gao ; Ni, Ray ; Kinn= ey, Michael D Subject: RE: [PATCH v2 1/2] MdeModulePkg: Remove the handle validation chec= k in CoreGetProtocolInterface Hi Zhi, Thanks for the update. One minor comment on 'STATIC' should be 'static'. We no longer depend on macros to redefine 'STATIC' and it is better to just used the standard C 'static' form. With that change: Reviewed-by: Michael D Kinney Mike > -----Original Message----- > From: Jin, Zhi > Sent: Monday, January 22, 2024 1:53 AM > To: devel@edk2.groups.io > Cc: Jin, Zhi ; Liming Gao ; > Ni, Ray ; Kinney, Michael D > > Subject: [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 -=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 (#114766): https://edk2.groups.io/g/devel/message/114766 Mute This Topic: https://groups.io/mt/103883257/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-