From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web08.5027.1634111226447302286 for ; Wed, 13 Oct 2021 00:47:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=KZFdBrEU; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: hua.ma@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10135"; a="288244875" X-IronPort-AV: E=Sophos;i="5.85,369,1624345200"; d="scan'208";a="288244875" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2021 00:47:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,369,1624345200"; d="scan'208";a="460686328" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga002.jf.intel.com with ESMTP; 13 Oct 2021 00:47:04 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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.2242.12; Wed, 13 Oct 2021 00:47:04 -0700 Received: from fmsmsx604.amr.corp.intel.com (10.18.126.84) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Wed, 13 Oct 2021 00:47:04 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Wed, 13 Oct 2021 00:47:04 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.169) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Wed, 13 Oct 2021 00:47:03 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JClwBMndiqPa7gBLSwKWYzs12SBzemlAbliD+0oEtF5kwLA1zD0zKcvNW+PVn3RPaNc2f9m4XZtGCBdiz6IJTG5sjulHPLqyy1b6HsW0XU49we6/rQbexzoJBJIBpdZ5YEkYuNwrHSSHWiz4YnfALaBhoJYUfxYRkFrW2/4VD6Cq3si1obf2u23a8cR4aaPX3g60uNog0lQz3qRg481kDoHg0UnkkfqAOcJ6vaUUBOL7SoKqebjFh+H399JUooO0ZhoW/hX0kL6t9xLsS1UYkGtbY5GZS6qdwG6BSU8ui+TdvzJeLZhOyWyEpUwvbFPfXOii0sy4iN+ghcajKzo9Ow== 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=qpNWPUDbOW7BeD2x46aTW2JVap4MbcKEQy4GxPuDvH4=; b=ikuOeBU9oFNXYQo3pp4oo3ByJhIRGtUw38bh/bvz9Iccnr4wJhK0pOHYkau848eXkJDAmApwqufr4spiaTgjO3gjLwhPXwAQS7c9beScjwFV46e3nhw4EBMApAd54M7+kp5IU0TsVL2oVCtVgdwGE1ex9muhKNiC4VHrL65snV0VPcTJCVn1e+iHy+XXRiwqCorx0uCoFKu5YUaGbKg5fl2eBkeV3PeoxW4RDQ5Vss0YymvtvETKkI1cVq0lU1Y4wn+bI9GeYhIehvAy5PdWGxtcjWAn4bTzbLfuR9KSRYNwpKi3Ut5Xm4VbwvHhfmOmAshj6k0mJQ0HLKm7KLg2Cw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qpNWPUDbOW7BeD2x46aTW2JVap4MbcKEQy4GxPuDvH4=; b=KZFdBrEUxpORhBHtBohZ5bQYi1XqouVGuUMm5hkZdhpxAJpjM/XNmJJXO09eZOXPJR7l6XFFLx2sl4GSjWyIIlkpfswGRdgKlKoTj1l6IBYRbFJ30cBKhav7VezzIBQE+Vq3OfjUkBubINCae15DMGYwSqZfKQaSveWZ56eTcKI= Received: from SJ0PR11MB4974.namprd11.prod.outlook.com (2603:10b6:a03:2d6::13) by SJ0PR11MB5134.namprd11.prod.outlook.com (2603:10b6:a03:2de::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.22; Wed, 13 Oct 2021 07:47:02 +0000 Received: from SJ0PR11MB4974.namprd11.prod.outlook.com ([fe80::7820:b346:edd1:f07]) by SJ0PR11MB4974.namprd11.prod.outlook.com ([fe80::7820:b346:edd1:f07%3]) with mapi id 15.20.4608.016; Wed, 13 Oct 2021 07:47:02 +0000 From: "Ma, Hua" To: "Wang, Jian J" , "devel@edk2.groups.io" CC: Liming Gao , "Bi, Dandan" , "Ni, Ray" Subject: Re: [PATCH v2] MdeModulePkg/Core/Dxe: Acquire a lock when iterating gHandleList Thread-Topic: [PATCH v2] MdeModulePkg/Core/Dxe: Acquire a lock when iterating gHandleList Thread-Index: AQHXv0QFav9THczUWUyR/AhFQMgMSavQVi0AgAA4KLA= Date: Wed, 13 Oct 2021 07:47:02 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.6.200.16 dlp-product: dlpe-windows authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1e89212f-51b5-4a0d-742a-08d98e1da524 x-ms-traffictypediagnostic: SJ0PR11MB5134: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /bGTRcZ+qsqHA3FvV17jyPMB6/3ptfZDP8WlhqwNkhXJubMcZT4sGYFGzDck4J4hXAe9kjai7oyLLXZQm+DENPXYJvYPQZfu2nIMkYIB0PiZNTOVPn+aiIaQY32xhGWoKcpXPjE+4wJUeYUS/rYr6blNUh+0MVDQzgVxHhzqMvImy3ZUdlvlCAGqZy4F6amWYjo6GI2jKRh+CFSETfUESYAyrhzGlWLpuhzutIwTeASjp0pygSJuMYmFwvD89vMPZvaJ2OwJzLvLx9VeJyT/H/2ELPdvSZccrlXltuhIF/P6EIyFYPNfBO0sEzYVpm/xPKDYJP5wn0k8FH08ekZ2V8DFZSdEnmFAG2RHQJn2rR32p9TWyzVYkg5ti/Q0mYb2oVHmGccKTfXDZO1pa0R+a4YTLDIvD47iDdav47Sl5PZeUgcPDAu+5R2/RQE02kEQOVqtN1YMK4da5C2ePgq7Fy0+9Pc9nJMCUPnaKdvDgdgpDwnHauTkFtghx5YGf23rZezN7Rx4SQ7Q78p+IZvRJCxX0OYkzwYoGAaP6wvIWhwQxG/1iOE9kFfvxk0ZLJUJFbTTqnef9w7ZkosGqEJ5LC7+1qW2/BAyhCDAQymf+REvUwWjOmLb6h8FZd1AYdvVfSKpMAdQcsD/ovqJ72FUsXN5v9gHsaK/lIYm08fousg7Nm/zIZ65AO1OIg81bzSpH0ReFjlCEHZiJKv9DhsYYDKee3Fc3J48q3kRttMbNRqgxRTImG0tdYgo5dSg2tBToA8NlNT5R6xkbfHXOoV3EEM2z33t3WL45StQSpb0TWWkAY5YmMAwHaE6tXO/hwX8OyumZy7D0qFB0+3edWayPA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR11MB4974.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(5660300002)(6506007)(7696005)(54906003)(82960400001)(66556008)(55016002)(8676002)(30864003)(110136005)(122000001)(66446008)(316002)(52536014)(53546011)(8936002)(107886003)(26005)(9686003)(83380400001)(86362001)(38070700005)(38100700002)(186003)(2906002)(71200400001)(508600001)(64756008)(966005)(66946007)(66476007)(76116006)(4326008)(33656002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?84iJkZVsanD/lPPSEmd1NO2heKkbn86DvmeEyglOhSgRRr1PdI0AQh9y5yk+?= =?us-ascii?Q?yhtyMF53mojf5rO+vMsuPIkZG82vPckbUGr733jyDKWAZgK2Nw6Z73hraNvb?= =?us-ascii?Q?NTxnRyk4mFkzfmLaRd1FjzFTSwW7up++CkPMq+c5Tbwd2UNrrivbBbp/FfTR?= =?us-ascii?Q?xan75bw9rX/oQxE9g4Ig+o6o3An42cV65afrdjLtrkfVmZBLNwVCQ8QiA0Wy?= =?us-ascii?Q?g/7Rr4rV/j527KB/JzDr77qlIuNTZGuSew9eLqowPfR5E25WHklZ9rN8qy9h?= =?us-ascii?Q?l2GhjzCG9KFuWwPa91R1x4QaLg73WK6UGixzClCpxBFUF2bEl7O7J+1LpapE?= =?us-ascii?Q?p5qvR7Z6UUIVaGMSF9XEFGSkfeFLjzCaGofL1yfpDDgveX36NxrlBUP2rzmx?= =?us-ascii?Q?eWDDeoVTwpKb+o9juH7QOPEm7xKfOnCin0MspHcsuMRM+XVylq/01Y5S0BfT?= =?us-ascii?Q?IFKQD7NmwEevBNsYHeWSnLEeA+puJk5es8fxiZL7BA7bsswvMDvrrDLaDiai?= =?us-ascii?Q?reKkKJ4Es7Oiqc9kKaqp9JG2TUaiLvl/BOrnvPhfMHpfTLcw7sT3vHH7T+kM?= =?us-ascii?Q?JgQDqCRuNNI5L6x2onMaMhbw+vl8CzgH33kCaM+1sgD8Bu/J541CnjjVNkHU?= =?us-ascii?Q?x/Mjh1dSKXrZAnJ5WLE4TbEsOB9HwYlO+hbwsqOWuMleZYivIJFHa8gJEG4O?= =?us-ascii?Q?J9YioqIIipMj9b72LNp5u9NwxdN/OmUWBEcnsj7PXQ5paPPFNYiOFcKI8WmB?= =?us-ascii?Q?bDb3Dac5FCUzIMutp19fdcnNC0Iy5ZkgmKGmJxvVlQnJXtLNpGr4ssqJAHD2?= =?us-ascii?Q?jsdoqvu4dgq0z9roIjB+RGG4JuZ/SCEl8UmI71/Pm+zbGiyw15YSP+WqMy/8?= =?us-ascii?Q?lF8mLYGdTi/dN2cBLHKiWtqPuG6Q8Hcx8H8we/Ev6DaqbLLvlmZJ5ynu3Gh1?= =?us-ascii?Q?5pSZpqHwzRJYJbYapuEPVgUWta9Aj+VapVjt8fXkxoBDkKkvVng1MYsk9uex?= =?us-ascii?Q?a8xDmjQCyr0e3LkBx1SP9IxDKqPS7Y8hwz2J0p4UsJn53e3xY5kNnZw117o4?= =?us-ascii?Q?m+6Adt/d6xongI6GdYXBmyQqFvwrXRuq7mFKth4VBALpohElTTzP7n20lsA0?= =?us-ascii?Q?QC1xxGSX7DiEVWxoDXVFs2mwJmHdwZCyX/+yKyxc/wa77O5A67H0EOOv5MRO?= =?us-ascii?Q?Qq+TXIYIs83jNr7PNyvx1dTQqT7OBMc4eqVthV/PiqbzMF/7ToVSNU1BeT2C?= =?us-ascii?Q?X9P19hiFnfQp+Kfqrm0qywyVRee8JRzt97AaMaFlG+tDE91IGNcbng7sEyru?= =?us-ascii?Q?YocVBkthq8xBo29Dk+Y24+rE?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SJ0PR11MB4974.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e89212f-51b5-4a0d-742a-08d98e1da524 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Oct 2021 07:47:02.4127 (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: hRbtz5sjVJvTE/vMp6w8aroFRe4YPKOZIbkOx8wsv7fjGXJXZPICy2XH0sbnNRoH7FnQH/m5H3nLzeexEiS2Zw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5134 Return-Path: hua.ma@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Jian, Thanks for the comment. Patch v3 is just sent with the update. Please help to review. Thank you, Ma Hua > -----Original Message----- > From: Wang, Jian J > Sent: Wednesday, October 13, 2021 12:26 PM > To: Ma, Hua ; devel@edk2.groups.io > Cc: Liming Gao ; Bi, Dandan > ; Ni, Ray > Subject: RE: [PATCH v2] MdeModulePkg/Core/Dxe: Acquire a lock when > iterating gHandleList >=20 > Hi Hua, >=20 > It looks a bit odd to me to add 'IsLocked' parameter and acquire lock ins= ide > CoreValidateHandle() if it's FALSE. Maybe we can keep the function > prototype as-is but do something like below: >=20 > a) Just keep ASSERT_LOCKED(&gProtocolDatabaseLock) in > CoreValidateHandle() > b) Call CoreAcquireProtocolLock() before any calling of > CoreValidateHandle() > and CoreReleaseProtocolLock() afterwards. >=20 > Actually, CoreAcquireProtocolLock() is always called wherever > CoreValidateHandle() is called. The problem is that, in many cases, > CoreAcquireProtocolLock() is called after CoreValidateHandle(). We can > simply move the calling of CoreAcquireProtocolLock() before > CoreValidateHandle() to fix this problem. >=20 > For those cases CoreAcquireProtocolLock() is not called at all, just simp= ly add > it. >=20 > Regards, > Jian >=20 > > -----Original Message----- > > From: Ma, Hua > > Sent: Tuesday, October 12, 2021 4:34 PM > > To: devel@edk2.groups.io > > Cc: Ma, Hua ; Wang, Jian J ; > > Liming Gao ; Bi, Dandan > > ; Ni, Ray > > Subject: [PATCH v2] MdeModulePkg/Core/Dxe: Acquire a lock when > > iterating gHandleList > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3680 > > > > This patch fixes the following issue: > > > > The global variable gHandleList is a linked list. > > This list is locked when a entry is added or removed from the list, > > but there is no lock when iterating this list in function > > CoreValidateHandle(). > > It can lead to "Handle.c (76): CR has Bad Signature" assertion if the > > iterated entry in the list is just removed by other task during iterati= ng. > > Locking the list when iterating can fix this issue. > > > > v2 changes: > > - Add lock check and comments in CoreGetProtocolInterface() before > > calling CoreValidateHandle() > > - Update the comments in CoreValidateHandle() header file > > > > v1: https://edk2.groups.io/g/devel/topic/86233569 > > > > Cc: Jian J Wang > > Cc: Liming Gao > > Cc: Dandan Bi > > Cc: Ray Ni > > Signed-off-by: Hua Ma > > --- > > MdeModulePkg/Core/Dxe/Hand/DriverSupport.c | 10 ++-- > > MdeModulePkg/Core/Dxe/Hand/Handle.c | 56 +++++++++++++++---- > --- > > MdeModulePkg/Core/Dxe/Hand/Handle.h | 5 +- > > MdeModulePkg/Core/Dxe/Hand/Notify.c | 2 +- > > 4 files changed, 50 insertions(+), 23 deletions(-) > > > > diff --git a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c > > b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c > > index feabf12faf..eb8a765d2c 100644 > > --- a/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c > > +++ b/MdeModulePkg/Core/Dxe/Hand/DriverSupport.c > > @@ -68,7 +68,7 @@ CoreConnectController ( > > // > > // Make sure ControllerHandle is valid > > // > > - Status =3D CoreValidateHandle (ControllerHandle); > > + Status =3D CoreValidateHandle (ControllerHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > @@ -154,7 +154,7 @@ CoreConnectController ( > > // > > // Make sure the DriverBindingHandle is valid > > // > > - Status =3D CoreValidateHandle (ControllerHandle); > > + Status =3D CoreValidateHandle (ControllerHandle, TRUE); > > if (EFI_ERROR (Status)) { > > // > > // Release the protocol lock on the handle database @@ -268,7 > > +268,7 @@ AddSortedDriverBindingProtocol ( > > // > > // Make sure the DriverBindingHandle is valid > > // > > - Status =3D CoreValidateHandle (DriverBindingHandle); > > + Status =3D CoreValidateHandle (DriverBindingHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return; > > } > > @@ -746,7 +746,7 @@ CoreDisconnectController ( > > // > > // Make sure ControllerHandle is valid > > // > > - Status =3D CoreValidateHandle (ControllerHandle); > > + Status =3D CoreValidateHandle (ControllerHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > @@ -755,7 +755,7 @@ CoreDisconnectController ( > > // Make sure ChildHandle is valid if it is not NULL > > // > > if (ChildHandle !=3D NULL) { > > - Status =3D CoreValidateHandle (ChildHandle); > > + Status =3D CoreValidateHandle (ChildHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c > > b/MdeModulePkg/Core/Dxe/Hand/Handle.c > > index 6eccb41ecb..46f67d3d6a 100644 > > --- a/MdeModulePkg/Core/Dxe/Hand/Handle.c > > +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c > > @@ -55,31 +55,46 @@ CoreReleaseProtocolLock ( > > Check whether a handle is a valid EFI_HANDLE > > > > @param UserHandle The handle to check > > + @param IsLocked The protocol lock is acquried or not > > > > @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid > > EFI_HANDLE. > > + @retval EFI_NOT_FOUND The handle is not found in the handle > database. > > @retval EFI_SUCCESS The handle is valid EFI_HANDLE. > > > > **/ > > EFI_STATUS > > CoreValidateHandle ( > > - IN EFI_HANDLE UserHandle > > + IN EFI_HANDLE UserHandle, > > + IN BOOLEAN IsLocked > > ) > > { > > IHANDLE *Handle; > > LIST_ENTRY *Link; > > + EFI_STATUS Status; > > > > if (UserHandle =3D=3D NULL) { > > return EFI_INVALID_PARAMETER; > > } > > > > + if (IsLocked) { > > + ASSERT_LOCKED(&gProtocolDatabaseLock); > > + } else { > > + CoreAcquireProtocolLock (); > > + } > > + > > + Status =3D EFI_NOT_FOUND; > > for (Link =3D gHandleList.BackLink; Link !=3D &gHandleList; Link =3D= Link- > >BackLink) { > > Handle =3D CR (Link, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE); > > if (Handle =3D=3D (IHANDLE *) UserHandle) { > > - return EFI_SUCCESS; > > + Status =3D EFI_SUCCESS; > > + break; > > } > > } > > > > - return EFI_INVALID_PARAMETER; > > + if (!IsLocked) { > > + CoreReleaseProtocolLock (); > > + } > > + return Status; > > } > > > > > > @@ -428,7 +443,7 @@ CoreInstallProtocolInterfaceNotify ( > > // > > InsertTailList (&gHandleList, &Handle->AllHandles); > > } else { > > - Status =3D CoreValidateHandle (Handle); > > + Status =3D CoreValidateHandle (Handle, TRUE); > > if (EFI_ERROR (Status)) { > > DEBUG((DEBUG_ERROR, "InstallProtocolInterface: input handle at > > 0x%x is invalid\n", Handle)); > > goto Done; > > @@ -723,7 +738,7 @@ CoreUninstallProtocolInterface ( > > // > > // Check that UserHandle is a valid handle > > // > > - Status =3D CoreValidateHandle (UserHandle); > > + Status =3D CoreValidateHandle (UserHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > @@ -899,7 +914,16 @@ CoreGetProtocolInterface ( > > IHANDLE *Handle; > > LIST_ENTRY *Link; > > > > - Status =3D CoreValidateHandle (UserHandle); > > + // > > + // The gProtocolDatabaseLock must be owned // > > + ASSERT_LOCKED(&gProtocolDatabaseLock); > > + > > + // > > + // The gProtocolDatabaseLock is owned // Call CoreValidateHandle > > + () with IsLocked =3D=3D TRUE // Status =3D CoreValidateHandle > > + (UserHandle, TRUE); > > if (EFI_ERROR (Status)) { > > return NULL; > > } > > @@ -1013,7 +1037,7 @@ CoreOpenProtocol ( > > // > > // Check for invalid UserHandle > > // > > - Status =3D CoreValidateHandle (UserHandle); > > + Status =3D CoreValidateHandle (UserHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > @@ -1023,11 +1047,11 @@ CoreOpenProtocol ( > > // > > switch (Attributes) { > > case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER : > > - Status =3D CoreValidateHandle (ImageHandle); > > + Status =3D CoreValidateHandle (ImageHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > - Status =3D CoreValidateHandle (ControllerHandle); > > + Status =3D CoreValidateHandle (ControllerHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > @@ -1037,17 +1061,17 @@ CoreOpenProtocol ( > > break; > > case EFI_OPEN_PROTOCOL_BY_DRIVER : > > case EFI_OPEN_PROTOCOL_BY_DRIVER | > EFI_OPEN_PROTOCOL_EXCLUSIVE : > > - Status =3D CoreValidateHandle (ImageHandle); > > + Status =3D CoreValidateHandle (ImageHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > - Status =3D CoreValidateHandle (ControllerHandle); > > + Status =3D CoreValidateHandle (ControllerHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > break; > > case EFI_OPEN_PROTOCOL_EXCLUSIVE : > > - Status =3D CoreValidateHandle (ImageHandle); > > + Status =3D CoreValidateHandle (ImageHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > @@ -1249,16 +1273,16 @@ CoreCloseProtocol ( > > // > > // Check for invalid parameters > > // > > - Status =3D CoreValidateHandle (UserHandle); > > + Status =3D CoreValidateHandle (UserHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > - Status =3D CoreValidateHandle (AgentHandle); > > + Status =3D CoreValidateHandle (AgentHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > if (ControllerHandle !=3D NULL) { > > - Status =3D CoreValidateHandle (ControllerHandle); > > + Status =3D CoreValidateHandle (ControllerHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > @@ -1443,7 +1467,7 @@ CoreProtocolsPerHandle ( > > UINTN ProtocolCount; > > EFI_GUID **Buffer; > > > > - Status =3D CoreValidateHandle (UserHandle); > > + Status =3D CoreValidateHandle (UserHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.h > > b/MdeModulePkg/Core/Dxe/Hand/Handle.h > > index 83eb2b9f3a..20d886beca 100644 > > --- a/MdeModulePkg/Core/Dxe/Hand/Handle.h > > +++ b/MdeModulePkg/Core/Dxe/Hand/Handle.h > > @@ -244,14 +244,17 @@ CoreReleaseProtocolLock ( > > Check whether a handle is a valid EFI_HANDLE > > > > @param UserHandle The handle to check > > + @param IsLocked The protocol lock is acquried or not > > > > @retval EFI_INVALID_PARAMETER The handle is NULL or not a valid > > EFI_HANDLE. > > + @retval EFI_NOT_FOUND The handle is not found in the handle > database. > > @retval EFI_SUCCESS The handle is valid EFI_HANDLE. > > > > **/ > > EFI_STATUS > > CoreValidateHandle ( > > - IN EFI_HANDLE UserHandle > > + IN EFI_HANDLE UserHandle, > > + IN BOOLEAN IsLocked > > ); > > > > // > > diff --git a/MdeModulePkg/Core/Dxe/Hand/Notify.c > > b/MdeModulePkg/Core/Dxe/Hand/Notify.c > > index 553413a350..f4e7c01e96 100644 > > --- a/MdeModulePkg/Core/Dxe/Hand/Notify.c > > +++ b/MdeModulePkg/Core/Dxe/Hand/Notify.c > > @@ -188,7 +188,7 @@ CoreReinstallProtocolInterface ( > > PROTOCOL_INTERFACE *Prot; > > PROTOCOL_ENTRY *ProtEntry; > > > > - Status =3D CoreValidateHandle (UserHandle); > > + Status =3D CoreValidateHandle (UserHandle, FALSE); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > -- > > 2.32.0.windows.2