|
|
b6c182 |
From fca7e61fa3ba21cbf6e89d75b23fea03af5d517e Mon Sep 17 00:00:00 2001
|
|
|
b6c182 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
b6c182 |
Date: Tue, 8 Jun 2021 14:12:52 +0200
|
|
|
b6c182 |
Subject: [PATCH 03/10] NetworkPkg/IScsiDxe: clean up
|
|
|
b6c182 |
"ISCSI_CHAP_AUTH_DATA.OutChallengeLength"
|
|
|
b6c182 |
MIME-Version: 1.0
|
|
|
b6c182 |
Content-Type: text/plain; charset=UTF-8
|
|
|
b6c182 |
Content-Transfer-Encoding: 8bit
|
|
|
b6c182 |
|
|
|
b6c182 |
RH-Author: Laszlo Ersek <lersek@redhat.com>
|
|
|
b6c182 |
RH-MergeRequest: 5: NetworkPkg/IScsiDxe: fix IScsiHexToBin() security and functionality bugs [rhel-8.5.0, post-rebase]
|
|
|
b6c182 |
RH-Commit: [3/10] cc7118399f64979f2d81fe9fc381ed22c3815f9e
|
|
|
b6c182 |
RH-Bugzilla: 1956408
|
|
|
b6c182 |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
b6c182 |
|
|
|
b6c182 |
The "ISCSI_CHAP_AUTH_DATA.OutChallenge" field is declared as a UINT8 array
|
|
|
b6c182 |
with ISCSI_CHAP_AUTH_MAX_LEN (1024) elements. However, when the challenge
|
|
|
b6c182 |
is generated and formatted, only ISCSI_CHAP_RSP_LEN (16) octets are used
|
|
|
b6c182 |
in the array.
|
|
|
b6c182 |
|
|
|
b6c182 |
Change the array size to ISCSI_CHAP_RSP_LEN, and remove the (now unused)
|
|
|
b6c182 |
ISCSI_CHAP_AUTH_MAX_LEN macro.
|
|
|
b6c182 |
|
|
|
b6c182 |
Remove the "ISCSI_CHAP_AUTH_DATA.OutChallengeLength" field, which is
|
|
|
b6c182 |
superfluous too.
|
|
|
b6c182 |
|
|
|
b6c182 |
Most importantly, explain in a new comment *why* tying the challenge size
|
|
|
b6c182 |
to the digest size (ISCSI_CHAP_RSP_LEN) has always made sense. (See also
|
|
|
b6c182 |
Linux kernel commit 19f5f88ed779, "scsi: target: iscsi: tie the challenge
|
|
|
b6c182 |
length to the hash digest size", 2019-11-06.) For sure, the motivation
|
|
|
b6c182 |
that the new comment now explains has always been there, and has always
|
|
|
b6c182 |
been the same, for IScsiDxe; it's just that now we spell it out too.
|
|
|
b6c182 |
|
|
|
b6c182 |
No change in peer-visible behavior.
|
|
|
b6c182 |
|
|
|
b6c182 |
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
|
|
|
b6c182 |
Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
|
|
|
b6c182 |
Cc: Philippe Mathieu-Daud <philmd@redhat.com>
|
|
|
b6c182 |
Cc: Siyuan Fu <siyuan.fu@intel.com>
|
|
|
b6c182 |
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3356
|
|
|
b6c182 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
b6c182 |
Reviewed-by: Philippe Mathieu-Daud <philmd@redhat.com>
|
|
|
b6c182 |
Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
|
|
|
b6c182 |
Message-Id: <20210608121259.32451-4-lersek@redhat.com>
|
|
|
b6c182 |
(cherry picked from commit 95616b866187b00355042953efa5c198df07250f)
|
|
|
b6c182 |
---
|
|
|
b6c182 |
NetworkPkg/IScsiDxe/IScsiCHAP.c | 3 +--
|
|
|
b6c182 |
NetworkPkg/IScsiDxe/IScsiCHAP.h | 9 ++++++---
|
|
|
b6c182 |
2 files changed, 7 insertions(+), 5 deletions(-)
|
|
|
b6c182 |
|
|
|
b6c182 |
diff --git a/NetworkPkg/IScsiDxe/IScsiCHAP.c b/NetworkPkg/IScsiDxe/IScsiCHAP.c
|
|
|
b6c182 |
index df3c2eb120..9e192ce292 100644
|
|
|
b6c182 |
--- a/NetworkPkg/IScsiDxe/IScsiCHAP.c
|
|
|
b6c182 |
+++ b/NetworkPkg/IScsiDxe/IScsiCHAP.c
|
|
|
b6c182 |
@@ -122,7 +122,7 @@ IScsiCHAPAuthTarget (
|
|
|
b6c182 |
AuthData->AuthConfig->ReverseCHAPSecret,
|
|
|
b6c182 |
SecretSize,
|
|
|
b6c182 |
AuthData->OutChallenge,
|
|
|
b6c182 |
- AuthData->OutChallengeLength,
|
|
|
b6c182 |
+ ISCSI_CHAP_RSP_LEN, // ChallengeLength
|
|
|
b6c182 |
VerifyRsp
|
|
|
b6c182 |
);
|
|
|
b6c182 |
|
|
|
b6c182 |
@@ -490,7 +490,6 @@ IScsiCHAPToSendReq (
|
|
|
b6c182 |
// CHAP_C=<C>
|
|
|
b6c182 |
//
|
|
|
b6c182 |
IScsiGenRandom ((UINT8 *) AuthData->OutChallenge, ISCSI_CHAP_RSP_LEN);
|
|
|
b6c182 |
- AuthData->OutChallengeLength = ISCSI_CHAP_RSP_LEN;
|
|
|
b6c182 |
IScsiBinToHex (
|
|
|
b6c182 |
(UINT8 *) AuthData->OutChallenge,
|
|
|
b6c182 |
ISCSI_CHAP_RSP_LEN,
|
|
|
b6c182 |
diff --git a/NetworkPkg/IScsiDxe/IScsiCHAP.h b/NetworkPkg/IScsiDxe/IScsiCHAP.h
|
|
|
b6c182 |
index 1fc1d96ea3..35d5d6ec29 100644
|
|
|
b6c182 |
--- a/NetworkPkg/IScsiDxe/IScsiCHAP.h
|
|
|
b6c182 |
+++ b/NetworkPkg/IScsiDxe/IScsiCHAP.h
|
|
|
b6c182 |
@@ -19,7 +19,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
b6c182 |
|
|
|
b6c182 |
#define ISCSI_CHAP_ALGORITHM_MD5 5
|
|
|
b6c182 |
|
|
|
b6c182 |
-#define ISCSI_CHAP_AUTH_MAX_LEN 1024
|
|
|
b6c182 |
///
|
|
|
b6c182 |
/// MD5_HASHSIZE
|
|
|
b6c182 |
///
|
|
|
b6c182 |
@@ -59,9 +58,13 @@ typedef struct _ISCSI_CHAP_AUTH_DATA {
|
|
|
b6c182 |
//
|
|
|
b6c182 |
// Auth-data to be sent out for mutual authentication.
|
|
|
b6c182 |
//
|
|
|
b6c182 |
+ // While the challenge size is technically independent of the hashing
|
|
|
b6c182 |
+ // algorithm, it is good practice to avoid hashing *fewer bytes* than the
|
|
|
b6c182 |
+ // digest size. In other words, it's good practice to feed *at least as many
|
|
|
b6c182 |
+ // bytes* to the hashing algorithm as the hashing algorithm will output.
|
|
|
b6c182 |
+ //
|
|
|
b6c182 |
UINT32 OutIdentifier;
|
|
|
b6c182 |
- UINT8 OutChallenge[ISCSI_CHAP_AUTH_MAX_LEN];
|
|
|
b6c182 |
- UINT32 OutChallengeLength;
|
|
|
b6c182 |
+ UINT8 OutChallenge[ISCSI_CHAP_RSP_LEN];
|
|
|
b6c182 |
} ISCSI_CHAP_AUTH_DATA;
|
|
|
b6c182 |
|
|
|
b6c182 |
/**
|
|
|
b6c182 |
--
|
|
|
b6c182 |
2.27.0
|
|
|
b6c182 |
|