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 74D17AC1B8F for ; Tue, 23 Jan 2024 22:22:23 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=dj1c8YoSEOCkABzjYxzWMYlHBWJuwm/MoWl3Bf/MwD0=; 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=1706048542; v=1; b=r/am8Khtn3rdo+BUy0XzIAe5I1eluDoY9yPAhIuPn6Hm7pI4Bsf+lpFqDfMxKOpB2YdFjo+J x4OQJXrw8fRsciAS3fgTn4cEPdz9NWjdQ16BGcfDW+9yk2vtB2UaiCLGVWNiRWw/7kv9NlXmsm9 xsBQNiiOPL/k4uLfotVSH/NI= X-Received: by 127.0.0.2 with SMTP id 6cuPYY7687511xEpdsqRes6j; Tue, 23 Jan 2024 14:22:22 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web10.8094.1706048541249090163 for ; Tue, 23 Jan 2024 14:22:21 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10962"; a="20225036" X-IronPort-AV: E=Sophos;i="6.05,215,1701158400"; d="scan'208";a="20225036" X-Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2024 14:22:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,215,1701158400"; d="scan'208";a="1765237" X-Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmviesa003.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 23 Jan 2024 14:22:21 -0800 X-Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Jan 2024 14:22:19 -0800 X-Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Jan 2024 14:22:18 -0800 X-Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx602.amr.corp.intel.com (10.22.229.15) 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, 23 Jan 2024 14:22:18 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.169) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 23 Jan 2024 14:22:18 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GU//7FFgy7HCj7hOUGDeqUpxR31jErKnffiyQRpCa1u47WLsgCGtbmEaamzLbxpA1U/qkgxH6JUFOwwORK1XHOPc9lzTKlrP3ugZPWKwz61M1rjshKd08ldTtEUVeKarlGW+R9NqDWGZVkHSjSloMjXiESHUwG134YPn8pQ6LM3qM0AplWjVWCdK2u3raRVkD7XWTdK77dSPy3/7rMVudC/NmLmuMi1Zs5kqd1dvmdqy+9UtZfYpF+Nq/yqCb2fd3divb5W9FZgQPLAyFnpbvbDvE2DLAmhM2KIf4zy3+egyjC5hF6v9Kca+q6MhenNX9hH0rW/c5oUxgDBJqCm+PA== 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=eDvorogUSf5WL7ikF28s55gGfHahSXuBlCK72Ia84PM=; b=F7epYCEGPuVIR6tBWDFOvGeTUTfcqJguCyiIXkmNq5asUuLnNn+U4z7xuyIRBJWY74YGcGadfw8wHDChnuWrUmcl3Ey6iSbvQTUSEn75LqmRLAY5/CoOL8a+pz7PPlrc+JhZNmQa2eCKxkJEtQ3pWo6CpXQgwx8wFfB1ci3OrBo7TybaaoyO71FWnK/HHgncA3DXirFPdphNvorrKEqIdYkCbWxrvnCx+MLSiCKPcRhDXfB9z3b/Skac+R1MyUpir28MvGL8tvpcI7oDFAyiGdzrIG3RNiwllxmJeQGSs+QWllhR2NvymM2srEei93n7Y+0ITRHTS/PN+AHD+s9+9w== 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 CO1PR11MB4929.namprd11.prod.outlook.com (2603:10b6:303:6d::19) by CY5PR11MB6260.namprd11.prod.outlook.com (2603:10b6:930:23::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.34; Tue, 23 Jan 2024 22:22:15 +0000 X-Received: from CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::7e42:1633:d0a6:9c00]) by CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::7e42:1633:d0a6:9c00%6]) with mapi id 15.20.7202.035; Tue, 23 Jan 2024 22:22:13 +0000 From: "Michael D Kinney" To: "Jin, Zhi" , "devel@edk2.groups.io" CC: Liming Gao , "Ni, Ray" , "Kinney, Michael D" 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: AQHaTRjKvadqeszZ8k6+yCs8aJ4y+rDn+qAg Date: Tue, 23 Jan 2024 22:22:12 +0000 Message-ID: References: <20240122095323.1824627-1-zhi.jin@intel.com> In-Reply-To: <20240122095323.1824627-1-zhi.jin@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO1PR11MB4929:EE_|CY5PR11MB6260:EE_ x-ms-office365-filtering-correlation-id: 60c9d55d-3ac1-4449-8568-08dc1c61bf72 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 7v/C1vODlrb1VsDnkux8mmabMqcxjvPzgiV67lCynUDKGfZUY2IarYX2xP5XkkPhR7XwAcmyhuWGjl0Ov+5D2Cnoy4KlthHanLRBphs83hoYJUh5ePF9Rg8UTi35Gu+UECIz/CE/0myD0QQ7reyNzP3NiKHiXc0o+/j0xxUeSQefUPiEyIGd3BRmiJotvWd65+b4r58QHLmSlBWrOIN+iwZ/ueqrjK0sfrJ020dVxUnUZM8buoeMQ3z4+GEXkZyB+hjXMapLB4gFVFrLWFCADiIPPBUMHdwnU2nvLDY0ccZOHdcnHGtMb5neoLwIb0IBtgl9fh7JEDWGFLgn/nZeXF4O3mDY5ep7zSOR5XCMfkyF4AGzb+bBVuptvSlxmdsAxau/BBqfP4+qSs6RiwBDbmFsCDyKPnRp5MWQYlwF7G4zIm2gLlIpbChyfh4JRzy4kJfowlr+gJrQUUmnCR+YZjuIVO21q3jhS5v/o53AeLDQnWSchizZkhckvx1SqJKJQ+0Kx2KtWGZectFZqBObTgJsNn1C3hZAQCbn+W2g4zPY6lv+XSDIlvE95nLcIbVu97PuDrYu4i1TJCBLCCSTmyeG0DRg4B5AGUt4lgMvmFElt3osY9CiVzBQIsmKNW3n x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Zzxe2dq9YxpR13ZSzxi2EPhwVll/lrzQOOMUIiRNwhwHfPo9hmVMXEx6kKXk?= =?us-ascii?Q?uJbhMs9sRTkO/BdwbYuE4blEadupNiFwiMXb7+iXt/807WT5SNdk1Mur05mE?= =?us-ascii?Q?Rr4+8+Z2RhW5bm6GDTq5+Aq6PCbiyT3V/a7aENqScK2t5C680FVYS6tDTlM5?= =?us-ascii?Q?T0niAr2KxSRnAL7vwoHvp+nlyP1mlUL19ez3kZJYgA3oAAWpW1LqYhS36VR7?= =?us-ascii?Q?nsumeOgRvEAVmGITkYTipOrnKyPhbjGtasg4Qm7PBc4RE1qqkIEBEOK2lqLZ?= =?us-ascii?Q?CB1bY70/ogNHtdwEl01+4qDchbP1h9SYGGB44e6tIeCQUu2uSWxP17WeC5Io?= =?us-ascii?Q?J6xeTEp0rvpWMnJTz1dLroVcSYERMUOoYcREJOHBHashjycRXfkEcvQZDDam?= =?us-ascii?Q?vxl8WTs1V9c8T5CV0OLeaj8J7xy0kqMoD+DlOJhUnzOrYh9NvuDqHCGhddLo?= =?us-ascii?Q?Q66yZQXgYBGYU9NyhwnHvSJyEj3FIzGcSKwDKTWaDwCQnKJY3EhX0fTSmsDT?= =?us-ascii?Q?dZiR6cGER7L6wCeZ+q+h7zU909pgMJ2AnhlHCDUDiQnQjP2lNzsQWucDZcLt?= =?us-ascii?Q?22Ph5KrC368bg5rnZsDSxX7DVIB797CIkNeHx3BOXS8RHyT4I1w9FDo1vstd?= =?us-ascii?Q?XmQNBW62cs8uRmv+CHolw9CPZqLePeBLEop7tPJVJydpM74IhNaqLQlF5pIo?= =?us-ascii?Q?6cfnzTXL59IeZy2eKdeZaLH0uCJ0PhduVcSy1WskhuZ8pmiTf0AsgIWGSfYs?= =?us-ascii?Q?NBkuUOuv1G7/OUk6NtTLeyNq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CrossTenant-AuthSource: CO1PR11MB4929.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 60c9d55d-3ac1-4449-8568-08dc1c61bf72 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Jan 2024 22:22:12.8629 (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: NnoUQZI/q2hJx3zNjzJVjea7D6tqAB28YJvcOxt6Tc2DK3M4d/JiidYOzNXMx2uwiy5ytKsTghvVtg4D0mtONZkBQ0x9KVY2JsMBxxHU+Eo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6260 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,michael.d.kinney@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: BW2pHRjQdaGWih97SSLtUM2lx7686176AA= 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="r/am8Kht"; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.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 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 (#114234): https://edk2.groups.io/g/devel/message/114234 Mute This Topic: https://groups.io/mt/103883257/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-