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 0EE7E740046 for ; Wed, 17 Jan 2024 06:44:35 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=2jKkQ5GiesFkjn/OkIEtPMDZ4dwe1MiEv2DxGPSvTj8=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1705473874; v=1; b=u2X/Mvksb6dpn1+DZ8dYi9eHn9vNhaCvY+UGL8mC+YHerFekPT2GLDBTDml1imD6q1JXTsyw GKYG4BiKzh4lbdKHve+DVaEDme7+WJ52kA94OG8XmBT6xZeH7PQEaRJRdKDzvNXwTbQCIXMgLJZ JgD9Mse7wNdsilzOG6rFaSig= X-Received: by 127.0.0.2 with SMTP id 4zCTYY7687511xFfnlWg22Iq; Tue, 16 Jan 2024 22:44:34 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web10.3520.1705473873921396654 for ; Tue, 16 Jan 2024 22:44:34 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10955"; a="18680895" X-IronPort-AV: E=Sophos;i="6.05,200,1701158400"; d="scan'208";a="18680895" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 22:44:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10955"; a="903435722" X-IronPort-AV: E=Sophos;i="6.05,200,1701158400"; d="scan'208";a="903435722" X-Received: from zjin7-devs.sh.intel.com ([10.239.154.113]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2024 22:44:31 -0800 From: "Zhi Jin" To: devel@edk2.groups.io Cc: Zhi Jin , Liming Gao , Ray Ni Subject: [edk2-devel] [PATCH 1/2] MdeModulePkg: Remove the handle validation check in CoreGetProtocolInterface Date: Wed, 17 Jan 2024 14:45:09 +0800 Message-Id: <20240117064510.390499-1-zhi.jin@intel.com> MIME-Version: 1.0 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: 6ZgLMshRecJuioeqYnfe9wGyx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="u2X/Mvks"; 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 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. Meanwhile, need to make it the caller's responsibility to check the parameters, and add the check in CoreOpenProtocolInformation(). Cc: Liming Gao Cc: Ray Ni Signed-off-by: Zhi Jin --- MdeModulePkg/Core/Dxe/Hand/Handle.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Hand/Handle.c index 51e5b5d3b3..a0d2d03267 100644 --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c @@ -916,6 +916,8 @@ CoreUninstallMultipleProtocolInterfaces ( /** Locate a certain GUID protocol interface in a Handle's protocols. + Note: This function doesn't do parameters checking, it's caller's responsibility + to pass in valid parameters. @param UserHandle The handle to obtain the protocol interface on @param Protocol The GUID of the protocol @@ -929,17 +931,11 @@ CoreGetProtocolInterface ( IN EFI_GUID *Protocol ) { - EFI_STATUS Status; PROTOCOL_ENTRY *ProtEntry; PROTOCOL_INTERFACE *Prot; IHANDLE *Handle; LIST_ENTRY *Link; - Status = CoreValidateHandle (UserHandle); - if (EFI_ERROR (Status)) { - return NULL; - } - Handle = (IHANDLE *)UserHandle; // @@ -1392,6 +1388,15 @@ CoreOpenProtocolInformation ( // CoreAcquireProtocolLock (); + // + // Check for invalid UserHandle + // + Status = CoreValidateHandle (UserHandle); + if (EFI_ERROR (Status)) { + Status = EFI_NOT_FOUND; + goto Done; + } + // // Look at each protocol interface for a match // -- 2.39.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113930): https://edk2.groups.io/g/devel/message/113930 Mute This Topic: https://groups.io/mt/103781273/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-