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

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