Blame SOURCES/rh1495527-0004-Prevent-installation-of-an-all-zero-TK.patch

41389a
From 8f82bc94e8697a9d47fa8774dfdaaede1084912c Mon Sep 17 00:00:00 2001
41389a
From: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
41389a
Date: Fri, 29 Sep 2017 04:22:51 +0200
41389a
Subject: [PATCH 4/8] Prevent installation of an all-zero TK
41389a
41389a
Properly track whether a PTK has already been installed to the driver
41389a
and the TK part cleared from memory. This prevents an attacker from
41389a
trying to trick the client into installing an all-zero TK.
41389a
41389a
This fixes the earlier fix in commit
41389a
ad00d64e7d8827b3cebd665a0ceb08adabf15e1e ('Fix TK configuration to the
41389a
driver in EAPOL-Key 3/4 retry case') which did not take into account
41389a
possibility of an extra message 1/4 showing up between retries of
41389a
message 3/4.
41389a
41389a
Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@cs.kuleuven.be>
41389a
---
41389a
 src/common/wpa_common.h | 1 +
41389a
 src/rsn_supp/wpa.c      | 5 ++---
41389a
 src/rsn_supp/wpa_i.h    | 1 -
41389a
 3 files changed, 3 insertions(+), 4 deletions(-)
41389a
41389a
diff --git a/src/common/wpa_common.h b/src/common/wpa_common.h
41389a
index d200285..1021ccb 100644
41389a
--- a/src/common/wpa_common.h
41389a
+++ b/src/common/wpa_common.h
41389a
@@ -215,6 +215,7 @@ struct wpa_ptk {
41389a
 	size_t kck_len;
41389a
 	size_t kek_len;
41389a
 	size_t tk_len;
41389a
+	int installed; /* 1 if key has already been installed to driver */
41389a
 };
41389a
 
41389a
 struct wpa_gtk {
41389a
diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
41389a
index 7a2c68d..0550a41 100644
41389a
--- a/src/rsn_supp/wpa.c
41389a
+++ b/src/rsn_supp/wpa.c
41389a
@@ -510,7 +510,6 @@ static void wpa_supplicant_process_1_of_4(struct wpa_sm *sm,
41389a
 		os_memset(buf, 0, sizeof(buf));
41389a
 	}
41389a
 	sm->tptk_set = 1;
41389a
-	sm->tk_to_set = 1;
41389a
 
41389a
 	kde = sm->assoc_wpa_ie;
41389a
 	kde_len = sm->assoc_wpa_ie_len;
41389a
@@ -615,7 +614,7 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm,
41389a
 	enum wpa_alg alg;
41389a
 	const u8 *key_rsc;
41389a
 
41389a
-	if (!sm->tk_to_set) {
41389a
+	if (sm->ptk.installed) {
41389a
 		wpa_dbg(sm->ctx->msg_ctx, MSG_DEBUG,
41389a
 			"WPA: Do not re-install same PTK to the driver");
41389a
 		return 0;
41389a
@@ -659,7 +658,7 @@ static int wpa_supplicant_install_ptk(struct wpa_sm *sm,
41389a
 
41389a
 	/* TK is not needed anymore in supplicant */
41389a
 	os_memset(sm->ptk.tk, 0, WPA_TK_MAX_LEN);
41389a
-	sm->tk_to_set = 0;
41389a
+	sm->ptk.installed = 1;
41389a
 
41389a
 	if (sm->wpa_ptk_rekey) {
41389a
 		eloop_cancel_timeout(wpa_sm_rekey_ptk, sm, NULL);
41389a
diff --git a/src/rsn_supp/wpa_i.h b/src/rsn_supp/wpa_i.h
41389a
index 9a54631..41f371f 100644
41389a
--- a/src/rsn_supp/wpa_i.h
41389a
+++ b/src/rsn_supp/wpa_i.h
41389a
@@ -24,7 +24,6 @@ struct wpa_sm {
41389a
 	struct wpa_ptk ptk, tptk;
41389a
 	int ptk_set, tptk_set;
41389a
 	unsigned int msg_3_of_4_ok:1;
41389a
-	unsigned int tk_to_set:1;
41389a
 	u8 snonce[WPA_NONCE_LEN];
41389a
 	u8 anonce[WPA_NONCE_LEN]; /* ANonce from the last 1/4 msg */
41389a
 	int renew_snonce;
41389a
-- 
41389a
2.7.4
41389a