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=ting.ye@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 E371821168207 for ; Fri, 19 Oct 2018 00:08:11 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Oct 2018 00:08:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,399,1534834800"; d="scan'208";a="96586411" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga002.fm.intel.com with ESMTP; 19 Oct 2018 00:08:11 -0700 Received: from fmsmsx101.amr.corp.intel.com (10.18.124.199) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 19 Oct 2018 00:08:11 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx101.amr.corp.intel.com (10.18.124.199) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 19 Oct 2018 00:08:10 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.111]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.183]) with mapi id 14.03.0319.002; Fri, 19 Oct 2018 15:08:08 +0800 From: "Ye, Ting" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" Thread-Topic: [PATCH v2] NetworkPkg/IpSecDxe: Fix issue to parse SA Payload. Thread-Index: AQHUZr7SzBrjIsfihEer8xCEYnHb2qUmJ0ig Date: Fri, 19 Oct 2018 07:08:07 +0000 Message-ID: References: <20181018084423.12388-1-Jiaxin.wu@intel.com> In-Reply-To: <20181018084423.12388-1-Jiaxin.wu@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 v2] NetworkPkg/IpSecDxe: Fix issue to parse SA Payload. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Oct 2018 07:08:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ye Ting =20 -----Original Message----- From: Wu, Jiaxin=20 Sent: Thursday, October 18, 2018 4:44 PM To: edk2-devel@lists.01.org Cc: Fu, Siyuan ; Ye, Ting ; Wu, Jia= xin Subject: [PATCH v2] NetworkPkg/IpSecDxe: Fix issue to parse SA Payload. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1251 *v2: Correct the type of parameters in Ikev2ParseProposalData(), and refine= d the corresponding description. IpSecDxe failed to create the Child SA during parsing SA Payload, the issue= was caused by the below commit: SHA-1: 1e0db7b11987d0ec93be7dfe26102a327860fdbd * MdeModulePkg/NetworkPkg: Checking for NULL pointer before use. In above commit, it changed the value of IsMatch in Ikev2ChildSaParseSaPayl= oad() to FALSE. That's correct but it exposed the potential bug in to match= the correct proposal Data, which will cause the issue happen. Cc: Fu Siyuan Cc: Ye Ting Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wu Jiaxin --- NetworkPkg/IpSecDxe/Ikev2/Utility.c | 64 ++++++++++++++++++----------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/NetworkPkg/IpSecDxe/Ikev2/Utility.c b/NetworkPkg/IpSecDxe/Ikev= 2/Utility.c index 0c9c929705..63de56f09e 100644 --- a/NetworkPkg/IpSecDxe/Ikev2/Utility.c +++ b/NetworkPkg/IpSecDxe/Ikev2/Utility.c @@ -1993,34 +1993,51 @@ Ikev2IsSupportAlg ( } =20 /** Get the preferred algorithm types from ProposalData. =20 - @param[in] ProposalData Pointer to related IKEV2_PROPOSAL_= DATA. - @param[out] PreferEncryptAlgorithm Output of preferred encrypt algori= thm. - @param[out] PreferIntegrityAlgorithm Output of preferred integrity algo= rithm. - @param[out] PreferPrfAlgorithm Output of preferred PRF algorithm.= Only - for IKE SA. - @param[out] PreferDhGroup Output of preferred DH group. Only= for - IKE SA. - @param[out] PreferEncryptKeylength Output of preferred encrypt key le= ngth - in bytes. - @param[out] IsSupportEsn Output of value about the Extented= Sequence - Number is support or not. Only for= Child SA. - @param[in] IsChildSa If it is ture, the ProposalData is= for IKE - SA. Otherwise the proposalData is = for Child SA. + @param[in] ProposalData Pointer to related IKEV2_PROPO= SAL_DATA. + @param[in, out] PreferEncryptAlgorithm Pointer to buffer which is use= d to store the + preferred encrypt algorithm. + Input value shall be initializ= ed to zero that + indicates to be parsed from Pr= oposalData. + Output of preferred encrypt al= gorithm. + @param[in, out] PreferIntegrityAlgorithm Pointer to buffer which is use= d to store the + preferred integrity algorithm. + Input value shall be initializ= ed to zero that + indicates to be parsed from Pr= oposalData. + Output of preferred integrity = algorithm. + @param[in, out] PreferPrfAlgorithm Pointer to buffer which is use= d to store the + preferred PRF algorithm. + Input value shall be initializ= ed to zero that + indicates to be parsed from Pr= oposalData. + Output of preferred PRF algori= thm. Only + for IKE SA. + @param[in, out] PreferDhGroup Pointer to buffer which is use= d to store the + preferred DH group. + Input value shall be initializ= ed to zero that + indicates to be parsed from Pr= oposalData. + Output of preferred DH group. = Only for + IKE SA. + @param[in, out] PreferEncryptKeylength Pointer to buffer which is use= d to store the + preferred encrypt key length i= n bytes. + @param[in, out] IsSupportEsn Pointer to buffer which is use= d to store the + value about the Extented Seque= nce Number is + support or not. Only for Child= SA. + @param[in] IsChildSa If it is ture, the ProposalDat= a is for IKE + SA. Otherwise the proposalData= is for Child SA. =20 **/ VOID Ikev2ParseProposalData ( IN IKEV2_PROPOSAL_DATA *ProposalData, - OUT UINT16 *PreferEncryptAlgorithm, - OUT UINT16 *PreferIntegrityAlgorithm, - OUT UINT16 *PreferPrfAlgorithm, - OUT UINT16 *PreferDhGroup, - OUT UINTN *PreferEncryptKeylength, - OUT BOOLEAN *IsSupportEsn, + IN OUT UINT16 *PreferEncryptAlgorithm, + IN OUT UINT16 *PreferIntegrityAlgorithm, + IN OUT UINT16 *PreferPrfAlgorithm, + IN OUT UINT16 *PreferDhGroup, + IN OUT UINTN *PreferEncryptKeylength, + IN OUT BOOLEAN *IsSupportEsn, IN BOOLEAN IsChildSa ) { IKEV2_TRANSFORM_DATA *TransformData; UINT8 TransformIndex; @@ -2502,15 +2519,16 @@ Ikev2ChildSaParseSaPayload ( IntegrityAlgorithm =3D=3D PreferIntegrityAlgorithm && IsSupportEsn =3D=3D PreferIsSupportEsn ) { IsMatch =3D TRUE; } else { - PreferEncryptAlgorithm =3D 0; - PreferIntegrityAlgorithm =3D 0; - IsSupportEsn =3D TRUE; + IntegrityAlgorithm =3D 0; + EncryptAlgorithm =3D 0; + EncryptKeylength =3D 0; + IsSupportEsn =3D FALSE; } - ProposalData =3D (IKEV2_PROPOSAL_DATA*)((UINT8*)(ProposalData + 1) = + + ProposalData =3D (IKEV2_PROPOSAL_DATA*)((UINT8*)(ProposalData + 1)=20 + + ProposalData->NumTransforms * sizeof (IKEV2_TRANSFORM= _DATA)); } =20 ProposalData =3D (IKEV2_PROPOSAL_DATA *)((IKEV2_SA_DATA *)SaPayload->= PayloadBuf + 1); if (IsMatch) { -- 2.17.1.windows.2