From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 75A2A203569B4 for ; Thu, 26 Apr 2018 00:09:06 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2018 00:09:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,330,1520924400"; d="scan'208";a="50938372" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 26 Apr 2018 00:09:05 -0700 Received: from fmsmsx123.amr.corp.intel.com (10.18.125.38) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 26 Apr 2018 00:09:04 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx123.amr.corp.intel.com (10.18.125.38) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 26 Apr 2018 00:09:04 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.79]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.240]) with mapi id 14.03.0319.002; Thu, 26 Apr 2018 15:07:31 +0800 From: "Zeng, Star" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" CC: "Zhang, Chao B" , "Zeng, Star" Thread-Topic: [PATCH] MdeModulePkg/Bds: Validate the device path stored in Boot#### Thread-Index: AQHT3Fl3h7sT7C/VhEStkr36+3GuzaQSoTiA Date: Thu, 26 Apr 2018 07:07:30 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BAE41A8@shsmsx102.ccr.corp.intel.com> References: <20180425055114.40052-1-ruiyu.ni@intel.com> In-Reply-To: <20180425055114.40052-1-ruiyu.ni@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg/Bds: Validate the device path stored in Boot#### X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Apr 2018 07:09:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable VarCheckUefiLib InternalVarCheckLoadOption() can make sure the device path = in load option Variable Data is valid. If we do not assume VarCheckUefiLib will be always linked, I am ok with thi= s patch. Reviewed-by: Star Zeng Thanks, Star -----Original Message----- From: Ni, Ruiyu=20 Sent: Wednesday, April 25, 2018 1:51 PM To: edk2-devel@lists.01.org Cc: Zeng, Star ; Zhang, Chao B Subject: [PATCH] MdeModulePkg/Bds: Validate the device path stored in Boot#= ### The patch adds additional check to the device path when loading the Boot###= #/Driver#### variable data. If the device path is invalid, InvalidParameter is returned. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng Cc: Chao B Zhang --- MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c b/MdeMo= dulePkg/Library/UefiBootManagerLib/BmLoadOption.c index 32918caf32..b48a3cbd37 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmLoadOption.c @@ -1,7 +1,7 @@ /** @file Load option library functions which relate with creating and processing = load options. =20 -Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
Thi= s program and the accompanying materials are licensed and made available u= nder the terms and conditions of the BSD License @@ -922,10 +922,14 @@ EfiB= ootManagerVariableToLoadOptionEx ( VariablePtr +=3D StrSize ((CHAR16 *) VariablePtr); =20 // - // Get the option's device path + // Get the option's device path and validate it. // FilePath =3D (EFI_DEVICE_PATH_PROTOCOL *) VariablePtr; VariablePtr +=3D FilePathSize; + if (!IsDevicePathValid (FilePath, FilePathSize)) { + FreePool (Variable); + return EFI_INVALID_PARAMETER; + } =20 OptionalDataSize =3D (UINT32) (VariableSize - ((UINTN) VariablePtr - (UI= NTN) Variable)); if (OptionalDataSize =3D=3D 0) { -- 2.16.1.windows.1