From nobody Sat Nov 2 10:19:10 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 1490344989557641.9329623561574; Fri, 24 Mar 2017 01:43:09 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B64A28044E; Fri, 24 Mar 2017 01:43:07 -0700 (PDT) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 014D18044D for ; Fri, 24 Mar 2017 01:43:06 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Mar 2017 01:43:06 -0700 Received: from shwdeopenpsi116.ccr.corp.intel.com ([10.239.9.16]) by orsmga002.jf.intel.com with ESMTP; 24 Mar 2017 01:43:05 -0700 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490344987; x=1521880987; h=from:to:cc:subject:date:message-id; bh=85PXUIIYmbbWdI4mah11LZKfl2rIb9Dss6RQXhrvheA=; b=cjNj+8UP7qDmh7pnkIZal1agfxJ6NLaZj1c4RPDJrRCrb83Ci+Jx4PCO O1uj56iFmZJUhKp+m7aS2/xsZSZiJw==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,214,1486454400"; d="scan'208";a="64457972" From: Zhang Lubo To: edk2-devel@lists.01.org Date: Fri, 24 Mar 2017 16:43:04 +0800 Message-Id: <1490344984-28132-1-git-send-email-lubo.zhang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 Subject: [edk2] [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: , Cc: Ye Ting , Fu Siyuan , Wu Jiaxin 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" 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 Reviewed-by: Ye Ting =20 --- 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 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( ); =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) / 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 @@ IScsiConvertAttemptConfigDataToIfrNvDataByKeyword ( 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 IfrNvData->ISCSIConne= ctRetry[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')= { 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 (IfrNvData->Keyword[Index].ISCSICh= apSecret); 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) || (ChapSecretLe= n > 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 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= 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 (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) || (Rever= seChapSecretLen > 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 the= maximum length is 16 bytes.", NULL ); return EFI_INVALID_PARAMETER; } } --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel