Blame SOURCES/0001-AP-Silently-ignore-management-frame-from-unexpected-.patch

919688
From 8c07fa9eda13e835f3f968b2e1c9a8be3a851ff9 Mon Sep 17 00:00:00 2001
919688
From: Jouni Malinen <j@w1.fi>
919688
Date: Thu, 29 Aug 2019 11:52:04 +0300
919688
Subject: [PATCH] AP: Silently ignore management frame from unexpected source
919688
 address
919688
919688
Do not process any received Management frames with unexpected/invalid SA
919688
so that we do not add any state for unexpected STA addresses or end up
919688
sending out frames to unexpected destination. This prevents unexpected
919688
sequences where an unprotected frame might end up causing the AP to send
919688
out a response to another device and that other device processing the
919688
unexpected response.
919688
919688
In particular, this prevents some potential denial of service cases
919688
where the unexpected response frame from the AP might result in a
919688
connected station dropping its association.
919688
919688
Signed-off-by: Jouni Malinen <j@w1.fi>
919688
---
919688
 src/ap/drv_callbacks.c | 13 +++++++++++++
919688
 src/ap/ieee802_11.c    | 12 ++++++++++++
919688
 2 files changed, 25 insertions(+)
919688
919688
diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
919688
index 31587685fe3b..34ca379edc3d 100644
919688
--- a/src/ap/drv_callbacks.c
919688
+++ b/src/ap/drv_callbacks.c
919688
@@ -131,6 +131,19 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
919688
 			   "hostapd_notif_assoc: Skip event with no address");
919688
 		return -1;
919688
 	}
919688
+
919688
+	if (is_multicast_ether_addr(addr) ||
919688
+	    is_zero_ether_addr(addr) ||
919688
+	    os_memcmp(addr, hapd->own_addr, ETH_ALEN) == 0) {
919688
+		/* Do not process any frames with unexpected/invalid SA so that
919688
+		 * we do not add any state for unexpected STA addresses or end
919688
+		 * up sending out frames to unexpected destination. */
919688
+		wpa_printf(MSG_DEBUG, "%s: Invalid SA=" MACSTR
919688
+			   " in received indication - ignore this indication silently",
919688
+			   __func__, MAC2STR(addr));
919688
+		return 0;
919688
+	}
919688
+
919688
 	random_add_randomness(addr, ETH_ALEN);
919688
 
919688
 	hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
919688
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
919688
index c85a28db44b7..e7065372e158 100644
919688
--- a/src/ap/ieee802_11.c
919688
+++ b/src/ap/ieee802_11.c
919688
@@ -4626,6 +4626,18 @@ int ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len,
919688
 	fc = le_to_host16(mgmt->frame_control);
919688
 	stype = WLAN_FC_GET_STYPE(fc);
919688
 
919688
+	if (is_multicast_ether_addr(mgmt->sa) ||
919688
+	    is_zero_ether_addr(mgmt->sa) ||
919688
+	    os_memcmp(mgmt->sa, hapd->own_addr, ETH_ALEN) == 0) {
919688
+		/* Do not process any frames with unexpected/invalid SA so that
919688
+		 * we do not add any state for unexpected STA addresses or end
919688
+		 * up sending out frames to unexpected destination. */
919688
+		wpa_printf(MSG_DEBUG, "MGMT: Invalid SA=" MACSTR
919688
+			   " in received frame - ignore this frame silently",
919688
+			   MAC2STR(mgmt->sa));
919688
+		return 0;
919688
+	}
919688
+
919688
 	if (stype == WLAN_FC_STYPE_BEACON) {
919688
 		handle_beacon(hapd, mgmt, len, fi);
919688
 		return 1;
919688
-- 
919688
2.20.1
919688