From nobody Sat Nov 2 08:26:48 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1492593448727135.90813750592906; Wed, 19 Apr 2017 02:17:28 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4B26F2050A7A5; Wed, 19 Apr 2017 02:17:26 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 BB92B2050A796 for ; Wed, 19 Apr 2017 02:17:25 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Apr 2017 02:17:25 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by orsmga003.jf.intel.com with ESMTP; 19 Apr 2017 02:17:23 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,220,1488873600"; d="scan'208";a="958647701" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 19 Apr 2017 17:17:20 +0800 Message-Id: <20170419091720.25936-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.9.0.windows.1 Subject: [edk2] [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: , Cc: Feng Tian , Michael Turner , Jeff Fan , Eric Dong MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When a load option points to a physical UsbIo controller, whose device path contains UsbClass or UsbWwid node, old logic unconditionally treats it as a short-form device path and expands it. But the expanding gets the exactly same device path, and the device path is passed to BmGetNextLoadOptionDevicePath() which then passes this device path to BmExpandUsbDevicePath() again. This causes a infinite recursion. The patch avoids the USB short-form expanding when the device path points to a physical UsbIo controller. 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(-) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePk= g/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 NextDevicePa= thNode (Node)) { - if ((DevicePathType (Node) =3D=3D MESSAGING_DEVICE_PATH) && - ((DevicePathSubType (Node) =3D=3D MSG_USB_CLASS_DP) || (DevicePa= thSubType (Node) =3D=3D MSG_USB_WWID_DP))) { - break; + Node =3D FilePath; + Status =3D gBS->LocateDevicePath (&gEfiUsbIoProtocolGuid, &Node, &Hand= le); + 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 NextDevice= PathNode (Node)) { + if ((DevicePathType (Node) =3D=3D MESSAGING_DEVICE_PATH) && + ((DevicePathSubType (Node) =3D=3D MSG_USB_CLASS_DP) || (Device= PathSubType (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 devic= e path. - // For Boot Option device path which doesn't begin with the USB Cl= ass 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 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); + } + return BmExpandUsbDevicePath (FilePath, FullPath, Node); } - return BmExpandUsbDevicePath (FilePath, FullPath, Node); } } =20 --=20 2.9.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel