From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D6EAF21A0483B for ; Wed, 19 Apr 2017 23:15:20 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Apr 2017 23:15:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,224,1488873600"; d="scan'208";a="1121615362" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga001.jf.intel.com with ESMTP; 19 Apr 2017 23:15:20 -0700 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 19 Apr 2017 23:15:19 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 19 Apr 2017 23:15:19 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.246]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0319.002; Thu, 20 Apr 2017 14:15:17 +0800 From: "Fan, Jeff" To: "Ni, Ruiyu" CC: "edk2-devel@lists.01.org" , "Tian, Feng" , "Dong, Eric" Thread-Topic: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: Avoid buggy USB short-form expanding Thread-Index: AQHSuO3GZ2gRitR5EUOXb2fZXcmeOKHNBh6AgADCi5A= Date: Thu, 20 Apr 2017 06:15:16 +0000 Message-ID: <542CF652F8836A4AB8DBFAAD40ED192A4C5A9A8D@shsmsx102.ccr.corp.intel.com> References: <20170419091720.25936-1-ruiyu.ni@intel.com> <734D49CCEBEEF84792F5B80ED585239D5B9361D4@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5B9361D4@SHSMSX104.ccr.corp.intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTAzZTNhYjEtZmUxZi00YjcxLTg1NTItYmJlZGI1MjI5NzRkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IjhUbkZiZW9PbGdYTjhVazN4MTlHVXRNejFUOGhNKzZPT0pPTGs0NFk2VEk9In0= x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg/UefiBootManagerLib: Avoid buggy USB short-form expanding X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Apr 2017 06:15:21 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jeff Fan > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of=20 > Ruiyu Ni > Sent: Wednesday, April 19, 2017 5:17 PM > To: edk2-devel@lists.01.org > Cc: Tian, Feng ; Michael Turner=20 > ; Fan, Jeff ; Dong,=20 > Eric > Subject: [edk2] [PATCH] MdeModulePkg/UefiBootManagerLib: Avoid buggy=20 > USB short-form expanding >=20 > When a load option points to a physical UsbIo controller, whose device=20 > path contains UsbClass or UsbWwid node, old logic unconditionally=20 > treats it as a short-form device path and expands it. But the=20 > expanding gets the exactly same device path, and the device path is=20 > passed to > BmGetNextLoadOptionDevicePath() which then passes this device path to > BmExpandUsbDevicePath() again. > This causes a infinite recursion. >=20 > The patch avoids the USB short-form expanding when the device path=20 > points to a physical UsbIo controller. >=20 > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ruiyu Ni > Cc: Feng Tian > Cc: Jeff Fan > Cc: Eric Dong > Cc: Michael Turner > --- > MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 43 > ++++++++++++++---------- > 1 file changed, 26 insertions(+), 17 deletions(-) >=20 > diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c > b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c > index aa79c90..d684482 100644 > --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c > +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c > @@ -1546,26 +1546,35 @@ BmGetNextLoadOptionDevicePath ( > // > return BmExpandUriDevicePath (FilePath, FullPath); > } else { > - for (Node =3D FilePath; !IsDevicePathEnd (Node); Node =3D > NextDevicePathNode (Node)) { > - if ((DevicePathType (Node) =3D=3D MESSAGING_DEVICE_PATH) && > - ((DevicePathSubType (Node) =3D=3D MSG_USB_CLASS_DP) || > (DevicePathSubType (Node) =3D=3D MSG_USB_WWID_DP))) { > - break; > + Node =3D FilePath; > + Status =3D gBS->LocateDevicePath (&gEfiUsbIoProtocolGuid, &Node, > &Handle); > + if (EFI_ERROR (Status)) { > + // > + // Only expand the USB WWID/Class device path > + // when FilePath doesn't point to a physical UsbIo controller. > + // Otherwise, infinite recursion will happen. > + // > + for (Node =3D FilePath; !IsDevicePathEnd (Node); Node =3D > NextDevicePathNode (Node)) { > + if ((DevicePathType (Node) =3D=3D MESSAGING_DEVICE_PATH) && > + ((DevicePathSubType (Node) =3D=3D MSG_USB_CLASS_DP) || > (DevicePathSubType (Node) =3D=3D MSG_USB_WWID_DP))) { > + break; > + } > } > - } >=20 > - // > - // Expand the USB WWID/Class device path > - // > - if (!IsDevicePathEnd (Node)) { > - if (FilePath =3D=3D Node) { > - // > - // Boot Option device path starts with USB Class or USB WWID dev= ice > path. > - // For Boot Option device path which doesn't begin with the USB = Class > or > - // USB WWID device path, it's not needed to connect again here. > - // > - BmConnectUsbShortFormDevicePath (FilePath); > + // > + // Expand the USB WWID/Class device path > + // > + if (!IsDevicePathEnd (Node)) { > + if (FilePath =3D=3D Node) { > + // > + // Boot Option device path starts with USB Class or USB=20 > + WWID device > path. > + // For Boot Option device path which doesn't begin with the=20 > + USB Class > or > + // USB WWID device path, it's not needed to connect again here= . > + // > + BmConnectUsbShortFormDevicePath (FilePath); > + } > + return BmExpandUsbDevicePath (FilePath, FullPath, Node); > } > - return BmExpandUsbDevicePath (FilePath, FullPath, Node); > } > } >=20 > -- > 2.9.0.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel