From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 BE03921DFA901 for ; Thu, 30 Mar 2017 01:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490862754; x=1522398754; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=PYsS0d9PIFMIRvnODBZMSES1RjDJ5rrSX/9X3l549yU=; b=S3wQ0fTC2Z7fw5VeC/ob8dpDrsQ7FQoHGf88chwNLOAuodkpgS2bWemc y/9toJQFCjPF+SflREGTSETDSoB+5g==; Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Mar 2017 01:32:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,245,1486454400"; d="scan'208";a="1148731713" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 30 Mar 2017 01:32:34 -0700 Received: from fmsmsx122.amr.corp.intel.com (10.18.125.37) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 30 Mar 2017 01:32:33 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx122.amr.corp.intel.com (10.18.125.37) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 30 Mar 2017 01:32:33 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.253]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.82]) with mapi id 14.03.0248.002; Thu, 30 Mar 2017 16:32:30 +0800 From: "Ye, Ting" To: "Zhang, Lubo" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" , "Wu, Jiaxin" Thread-Topic: [edk2] [patch] NetworkPkg: Fix some bugs related to iSCSI keyword configuration. Thread-Index: AQHSpHqwj6HWZy7imEuWrK5uaXyBO6GtF0+Q Date: Thu, 30 Mar 2017 08:32:29 +0000 Message-ID: References: <1490344984-28132-1-git-send-email-lubo.zhang@intel.com> In-Reply-To: <1490344984-28132-1-git-send-email-lubo.zhang@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] NetworkPkg: Fix some bugs related to iSCSI keyword configuration. 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, 30 Mar 2017 08:32:34 -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: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Zhan= g Lubo Sent: Friday, March 24, 2017 4:43 PM To: edk2-devel@lists.01.org Cc: Ye, Ting ; Fu, Siyuan ; Wu, Jia= xin Subject: [edk2] [patch] NetworkPkg: Fix some bugs related to iSCSI keyword = configuration. Add check logic and error message for some keywords validity. show target address in URL format and MAC address correctly. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo Cc: Ye Ting Cc: Fu Siyuan Cc: Wu Jiaxin --- NetworkPkg/IScsiDxe/IScsiConfig.c | 78 +++++++++++++++++++++++++++--------= ---- 1 file changed, 54 insertions(+), 24 deletions(-) diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c b/NetworkPkg/IScsiDxe/IScsiC= onfig.c index 1fe279e..56a8685 100644 --- a/NetworkPkg/IScsiDxe/IScsiConfig.c +++ b/NetworkPkg/IScsiDxe/IScsiConfig.c @@ -626,14 +626,17 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( LIST_ENTRY *Entry; ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt; ISCSI_SESSION_CONFIG_NVDATA *SessionConfigData; ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfigData; CHAR16 AttemptNameList[ATTEMPT_NAME_LIST_SIZE]; + ISCSI_NIC_INFO *NicInfo; + CHAR16 MacString[ISCSI_MAX_MAC_STRING_LEN]; EFI_IP_ADDRESS Ip; UINTN Index; UINTN StringLen; =20 + NicInfo =3D NULL; ZeroMem (AttemptNameList, sizeof (AttemptNameList)); =20 if ((mPrivate !=3D NULL) && (mPrivate->AttemptCount !=3D 0)) { NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) { Attempt =3D NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA= , Link); @@ -700,12 +703,12 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKe= yword ( ); =20 if (SessionConfigData->DnsMode) { AsciiStrToUnicodeStrS ( SessionConfigData->TargetUrl, - IfrNvData->TargetIp, - sizeof (IfrNvData->TargetIp) / sizeof (IfrNvData->TargetIp[0]) + IfrNvData->Keyword[Index].ISCSITargetIpAddress, + sizeof (IfrNvData->Keyword[Index].ISCSITargetIpAddress) /=20 + sizeof (IfrNvData->Keyword[Index].ISCSITargetIpAddress[0]) ); } =20 IScsiLunToUnicodeStr (SessionConfigData->BootLun, IfrNvData->Keyword= [Index].ISCSILun); IScsiConvertIsIdToString (IfrNvData->Keyword[Index].ISCSIIsId, Sessi= onConfigData->IsId); @@ -738,13 +741,29 @@ IScsiConvertAttemptConfigDataToI= frNvDataByKeyword ( IfrNvData->Keyword[Index].ISCSIReverseChapSecret, ISCSI_CHAP_SECRET_STORAGE ); } } - CopyMem(IfrNvData->ISCSIDisplayAttemptList, AttemptNameList, ATTEMPT_N= AME_LIST_SIZE); } + + NET_LIST_FOR_EACH (Entry, &mPrivate->NicInfoList) { + NicInfo =3D NET_LIST_USER_STRUCT (Entry, ISCSI_NIC_INFO, Link); + IScsiMacAddrToStr ( + &NicInfo->PermanentAddress, + NicInfo->HwAddressSize, + NicInfo->VlanId, + MacString + ); + CopyMem ( + IfrNvData->ISCSIMacAddr + StrLen (IfrNvData->ISCSIMacAddr), + MacString, + StrLen (MacString) * sizeof (CHAR16) + ); + + *(IfrNvData->ISCSIMacAddr + StrLen (IfrNvData->ISCSIMacAddr)) =3D L'/'= ; + } } =20 /** Convert the IFR data to iSCSI configuration data. =20 @@ -1193,10 +1212,12 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( ) { ISCSI_ATTEMPT_CONFIG_NVDATA *Attempt; UINT8 AttemptIndex; UINT8 Index; + UINT8 ChapSecretLen; + UINT8 ReverseChapSecretLen; CHAR16 *AttemptName1; CHAR16 *AttemptName2; ISCSI_ATTEMPT_CONFIG_NVDATA *SameNicAttempt; CHAR8 LunString[ISCSI_LUN_STR_MAX_LEN]; CHAR8 IScsiName[ISCSI_NAME_MAX_SIZE]; @@ -1342,38 +1363,45 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( AttemptIndex =3D (UINT8) ((OffSet - ATTEMPT_CONNECT_RETRY_VAR_OFFSET) = + 1); Attempt =3D IScsiConfigGetAttemptByConfigIndex (AttemptIndex); if (Attempt =3D=3D NULL) { return EFI_INVALID_PARAMETER; } - Attempt->SessionConfigData.ConnectRetryCount =3D IfrNvData->ISCSIConne= ctRetry[AttemptIndex - 1]; - if (Attempt->SessionConfigData.ConnectRetryCount =3D=3D 0) { - Attempt->SessionConfigData.ConnectRetryCount =3D CONNECT_MIN_RETRY; + + if (IfrNvData->ISCSIConnectRetry[AttemptIndex - 1] > CONNECT_MAX_RETRY= ) { + CreatePopUp ( + EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, + &Key, + L"The minimum value is 0 and the maximum is 16. 0 means no retry= .", + NULL + ); + return EFI_INVALID_PARAMETER; } + Attempt->SessionConfigData.ConnectRetryCount =3D=20 + IfrNvData->ISCSIConnectRetry[AttemptIndex - 1]; =20 } else if ((OffSet >=3D ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET) && (OffSet <= ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET)) { AttemptIndex =3D (UINT8) ((OffSet - ATTEMPT_CONNECT_TIMEOUT_VAR_OFFSET= ) / 2 + 1); Attempt =3D IScsiConfigGetAttemptByConfigIndex (AttemptIndex); if (Attempt =3D=3D NULL) { return EFI_INVALID_PARAMETER; } + + if ((IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] < CONNECT_MIN_TI= MEOUT) || + (IfrNvData->ISCSIConnectTimeout[AttemptIndex - 1] > CONNECT_MAX_TI= MEOUT)) { + CreatePopUp ( + EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, + &Key, + L"The minimum value is 100 milliseconds and the maximum is 20 seco= nds.", + NULL + ); + return EFI_INVALID_PARAMETER; + } + Attempt->SessionConfigData.ConnectTimeout =3D IfrNvData->ISCSIConnectT= imeout[AttemptIndex - 1]; if (Attempt->SessionConfigData.ConnectTimeout =3D=3D 0) { Attempt->SessionConfigData.ConnectTimeout =3D CONNECT_DEFAULT_TIMEOU= T; } =20 - if (Attempt->SessionConfigData.Enabled !=3D ISCSI_DISABLED) { - if (Attempt->SessionConfigData.ConnectTimeout < CONNECT_MIN_TIMEOUT)= { - CreatePopUp ( - EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, - &Key, - L"Connection Establishing Timeout is less than minimum value 100= ms.", - NULL - ); - return EFI_INVALID_PARAMETER; - } - } - } else if ((OffSet >=3D ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFFSET) && (OffSe= t < ATTEMPT_TARGET_VIA_DHCP_VAR_OFFSET)) { AttemptIndex =3D (UINT8) ((OffSet - ATTEMPT_INITIATOR_VIA_DHCP_VAR_OFF= SET) + 1); Attempt =3D IScsiConfigGetAttemptByConfigIndex (AttemptIndex); if (Attempt =3D=3D NULL) { return EFI_INVALID_PARAMETER; @@ -1621,11 +1649,11 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( Attempt->AuthConfigData.CHAP.CHAPName, ISCSI_CHAP_NAME_STORAGE ); =20 if (Attempt->SessionConfigData.Enabled !=3D ISCSI_DISABLED) { - if (IfrNvData->CHAPName[0] =3D=3D L'\0') { + if (IfrNvData->Keyword[Index].ISCSIChapUsername[0] =3D=3D L'\0')= =20 + { CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"CHAP Name is invalid!", NULL @@ -1643,22 +1671,23 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( return EFI_INVALID_PARAMETER; } =20 } else if ((OffSet >=3D ATTEMPT_CHAR_SECRET_VAR_OFFSET) && (OffSet < A= TTEMPT_CHAR_REVERSE_USER_NAME_VAR_OFFSET)) { if (Attempt->AuthenticationType =3D=3D ISCSI_AUTH_TYPE_CHAP) { + ChapSecretLen =3D (UINT8)StrLen=20 + (IfrNvData->Keyword[Index].ISCSIChapSecret); UnicodeStrToAsciiStrS ( IfrNvData->Keyword[Index].ISCSIChapSecret, Attempt->AuthConfigData.CHAP.CHAPSecret, ISCSI_CHAP_SECRET_STORAGE ); =20 if (Attempt->SessionConfigData.Enabled !=3D ISCSI_DISABLED) { - if (IfrNvData->CHAPSecret[0] =3D=3D L'\0') { + if ((ChapSecretLen < ISCSI_CHAP_SECRET_MIN_LEN) ||=20 + (ChapSecretLen > ISCSI_CHAP_SECRET_MAX_LEN)) { CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, - L"CHAP Secret is invalid!", + L"The Chap Secret minimum length is 12 bytes and the=20 + maximum length is 16 bytes.", NULL ); return EFI_INVALID_PARAMETER; } } @@ -1678,11 +1707,11 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( IfrNvData->Keyword[Index].ISCSIReverseChapUsername, Attempt->AuthConfigData.CHAP.ReverseCHAPName, ISCSI_CHAP_NAME_STORAGE ); if (Attempt->SessionConfigData.Enabled !=3D ISCSI_DISABLED) { - if (IfrNvData->ReverseCHAPName[0] =3D=3D L'\0') { + if (IfrNvData->Keyword[Index].ISCSIReverseChapUsername[0] =3D=3D= =20 + L'\0') { CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Reverse CHAP Name is invalid!", NULL @@ -1700,22 +1729,23 @@ IScsiConvertlfrNvDataToAttemptConfigDataByKeyword ( return EFI_INVALID_PARAMETER; } =20 } else if (OffSet >=3D ATTEMPT_CHAR_REVERSE_SECRET_VAR_OFFSET) { if (Attempt->AuthConfigData.CHAP.CHAPType =3D=3D ISCSI_CHAP_MUTUAL) = { + ReverseChapSecretLen =3D (UINT8)StrLen=20 + (IfrNvData->Keyword[Index].ISCSIReverseChapSecret); UnicodeStrToAsciiStrS ( IfrNvData->Keyword[Index].ISCSIReverseChapSecret, Attempt->AuthConfigData.CHAP.ReverseCHAPSecret, ISCSI_CHAP_SECRET_STORAGE ); =20 if (Attempt->SessionConfigData.Enabled !=3D ISCSI_DISABLED) { - if (IfrNvData->ReverseCHAPSecret[0] =3D=3D L'\0') { + if ((ReverseChapSecretLen < ISCSI_CHAP_SECRET_MIN_LEN) ||=20 + (ReverseChapSecretLen > ISCSI_CHAP_SECRET_MAX_LEN)) { CreatePopUp ( EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, - L"Reverse CHAP Secret is invalid!", + L"The Reverse CHAP Secret minimum length is 12 bytes and=20 + the maximum length is 16 bytes.", NULL ); return EFI_INVALID_PARAMETER; } } -- 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel