[PATCH 1/1] wpa_supplicant: Fixes for transitional mode OWE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Overwriting of SSID for the hidden OWE BSS entry has some side effects:
- first the entry is notified over DBus with empty SSID and the update
  of SSID is never signaled (it is not even possible at the moment to
  notify the SSID change - see wpas_dbus_bss_signal_prop_changed()),
- during (and after) association there will be multiple entries
  referring to the same BSSID/SSID pair,
- during association we look for the relevant BSS by BSSID but there are
  multiple entries with the same BSSID and SSID and supplicant can
  choose entry that was initially signaled with empty SSID.

To address this two changes are made:
1. Stop overwriting SSID.
2. When selecting the BSS entry for CurrentBSS property prefer ones that
   have non-empty SSID.

Signed-off-by: Andrzej Ostruszka <andrzejo@xxxxxxxxxxxx>
---
 wpa_supplicant/bss.c    | 27 +++++++++++++++++++++
 wpa_supplicant/bss.h    |  2 ++
 wpa_supplicant/events.c | 52 +++++++----------------------------------
 3 files changed, 37 insertions(+), 44 deletions(-)

diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index 5ada34c4f..d245aa524 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -1088,6 +1088,33 @@ struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
 }
 
 
+/**
+ * wpa_bss_with_ssid_get - Fetch a BSS table entry based on BSSID
+ * @wpa_s: Pointer to wpa_supplicant data
+ * @bssid: BSSID
+ * Returns: Pointer to the BSS entry or %NULL if not found
+ *
+ * This is a version of wpa_bss_get_bssid that gives preference to the entries
+ * with non-empty SSID.
+ */
+struct wpa_bss * wpa_bss_with_ssid_get(struct wpa_supplicant *wpa_s,
+				       const u8 *bssid)
+{
+	struct wpa_bss *bss = NULL, *bss_candidate = NULL;
+	if (!wpa_supplicant_filter_bssid_match(wpa_s, bssid))
+		return NULL;
+	dl_list_for_each_reverse(bss_candidate, &wpa_s->bss, struct wpa_bss, list) {
+		if (os_memcmp(bss_candidate->bssid, bssid, ETH_ALEN) != 0)
+			continue;
+		if (!bss)
+			bss = bss_candidate;
+		if (bss_candidate->ssid_len > 0)
+			return bss_candidate;
+	}
+	return bss;
+}
+
+
 /**
  * wpa_bss_get_bssid_latest - Fetch the latest BSS table entry based on BSSID
  * @wpa_s: Pointer to wpa_supplicant data
diff --git a/wpa_supplicant/bss.h b/wpa_supplicant/bss.h
index 39dad868e..599e533c9 100644
--- a/wpa_supplicant/bss.h
+++ b/wpa_supplicant/bss.h
@@ -161,6 +161,8 @@ struct wpa_bss * wpa_bss_get(struct wpa_supplicant *wpa_s, const u8 *bssid,
 			     const u8 *ssid, size_t ssid_len);
 struct wpa_bss * wpa_bss_get_bssid(struct wpa_supplicant *wpa_s,
 				   const u8 *bssid);
+struct wpa_bss * wpa_bss_with_ssid_get(struct wpa_supplicant *wpa_s,
+				       const u8 *bssid);
 struct wpa_bss * wpa_bss_get_bssid_latest(struct wpa_supplicant *wpa_s,
 					  const u8 *bssid);
 struct wpa_bss * wpa_bss_get_p2p_dev_addr(struct wpa_supplicant *wpa_s,
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 1f186eb67..fa02d9785 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -166,8 +166,15 @@ wpa_supplicant_update_current_bss(struct wpa_supplicant *wpa_s, const u8 *bssid)
 		bss = wpa_supplicant_get_new_bss(wpa_s, bssid);
 	}
 
-	if (bss)
+	if (bss) {
+#ifdef CONFIG_OWE
+		/* If selected bss has an empty SSID try to find a matching
+		 * entry with non-empty SSID */
+		if (bss->ssid_len == 0)
+			bss = wpa_bss_with_ssid_get(wpa_s, bssid);
+#endif /* CONFIG_OWE */
 		wpa_s->current_bss = bss;
+	}
 
 	return bss;
 }
@@ -1092,7 +1099,6 @@ static void owe_trans_ssid(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
 #ifdef CONFIG_OWE
 	const u8 *owe, *pos, *end, *bssid;
 	u8 ssid_len;
-	struct wpa_bss *open_bss;
 
 	owe = wpa_bss_get_vendor_ie(bss, OWE_IE_VENDOR_TYPE);
 	if (!owe || !wpa_bss_get_ie(bss, WLAN_EID_RSN))
@@ -1133,48 +1139,6 @@ static void owe_trans_ssid(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
 			}
 		}
 	}
-
-	if (bss->ssid_len > 0)
-		return;
-
-	open_bss = wpa_bss_get_bssid_latest(wpa_s, bssid);
-	if (!open_bss)
-		return;
-	if (ssid_len != open_bss->ssid_len ||
-	    os_memcmp(pos, open_bss->ssid, ssid_len) != 0) {
-		wpa_dbg(wpa_s, MSG_DEBUG,
-			"OWE: transition mode SSID mismatch: %s",
-			wpa_ssid_txt(open_bss->ssid, open_bss->ssid_len));
-		return;
-	}
-
-	owe = wpa_bss_get_vendor_ie(open_bss, OWE_IE_VENDOR_TYPE);
-	if (!owe || wpa_bss_get_ie(open_bss, WLAN_EID_RSN)) {
-		wpa_dbg(wpa_s, MSG_DEBUG,
-			"OWE: transition mode open BSS unexpected info");
-		return;
-	}
-
-	pos = owe + 6;
-	end = owe + 2 + owe[1];
-
-	if (end - pos < ETH_ALEN + 1)
-		return;
-	if (os_memcmp(pos, bss->bssid, ETH_ALEN) != 0) {
-		wpa_dbg(wpa_s, MSG_DEBUG,
-			"OWE: transition mode BSSID mismatch: " MACSTR,
-			MAC2STR(pos));
-		return;
-	}
-	pos += ETH_ALEN;
-	ssid_len = *pos++;
-	if (end - pos < ssid_len || ssid_len > SSID_MAX_LEN)
-		return;
-	wpa_dbg(wpa_s, MSG_DEBUG, "OWE: learned transition mode OWE SSID: %s",
-		wpa_ssid_txt(pos, ssid_len));
-	os_memcpy(bss->ssid, pos, ssid_len);
-	bss->ssid_len = ssid_len;
-	bss->flags |= WPA_BSS_OWE_TRANSITION;
 #endif /* CONFIG_OWE */
 }
 
-- 
2.42.0.869.gea05f2083d-goog


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux