Skip to contentSkip to conversation

dpp: check that DPP is running in station watch

PATCH Applied James Prestwood 2 participants 5 messages Nov 16, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dpp: check that DPP is running in station watch

This was causing unneeded WARNING prints because the DPP state was never checked. Fix this and bail out if DPP isn't running.

---
 src/dpp.c | 3 +++
 1 file changed, 3 insertions(+)
src/dpp.c +3 -0
index 5cf9ca23..18b2a7c6 100644
@@ -3686,6 +3686,9 @@ static void dpp_station_state_watch(enum station_state state, void *user_data)
 {
 	struct dpp_sm *dpp = user_data;
 
+	if (dpp->state == DPP_STATE_NOTHING)
+		return;
+
 	switch (state) {
 	case STATION_STATE_DISCONNECTED:
 	case STATION_STATE_DISCONNECTING:
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 dpp: check for non-utf8 SSID's in scan results

In theory this shouldn't be possible because the configuration object validates that the SSID is utf-8. But it doesn't hurt to check especially since we can't control what the kernel sends us.

---
 src/dpp.c | 3 +++
 1 file changed, 3 insertions(+)
src/dpp.c +3 -0
index 18b2a7c6..8da79603 100644
@@ -884,6 +884,9 @@ static bool dpp_scan_results(int err, struct l_queue *bss_list,
 	/* Purely for grabbing the SSID */
 	bss = l_queue_peek_head(bss_list);
 
+	if (L_WARN_ON(!util_ssid_is_utf8(bss->ssid_len, bss->ssid)))
+		goto reset;
+
 	memcpy(ssid, bss->ssid, bss->ssid_len);
 	ssid[bss->ssid_len] = '\0';
 
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 2/2] dpp: check for non-utf8 SSID's in scan results

Hi James,

Quoted 12 lines · James Prestwood

In theory this shouldn't be possible because the configuration object validates that the SSID is utf-8. But it doesn't hurt to check especially since we can't control what the kernel sends us.

---
  src/dpp.c | 3 +++
  1 file changed, 3 insertions(+)
src/dpp.c +0 -0
index 18b2a7c6..8da79603 100644

src/dpp.c static bool dpp_scan_results(int err, struct l_queue *bss_list, · line 889

Quoted 6 lines
src/dpp.c +3 -0
@@ -884,6 +884,9 @@ static bool dpp_scan_results(int err, struct l_queue *bss_list,
  	/* Purely for grabbing the SSID */
  	bss = l_queue_peek_head(bss_list);
 
+	if (L_WARN_ON(!util_ssid_is_utf8(bss->ssid_len, bss->ssid)))
+		goto reset;
+

This still seems brittle. You have the validated SSID from the DPP session, shouldn't you be storing that and using it to filter the scan results? There's no guarantee that a filtered active scan is going to return only the SSID you asked for (lets say a misbehaving or malicious AP), so assuming that the first BSS in the scan results list is the SSID you want isn't really guaranteed.

src/dpp.c static bool dpp_scan_results(int err, struct l_queue *bss_list, · line 892

Quoted 3 lines
src/dpp.c +0 -0
  	memcpy(ssid, bss->ssid, bss->ssid_len);
  	ssid[bss->ssid_len] = '\0';
 

Regards,
-Denis

#3 lore raw

Re: [PATCH 2/2] dpp: check for non-utf8 SSID's in scan results

Hi Denis,

Quoted 10 lines · Denis Kenzior

Hi James,

Quoted 7 lines · James Prestwood

In theory this shouldn't be possible because the configuration object validates that the SSID is utf-8. But it doesn't hurt to check especially since we can't control what the kernel sends us.
---
  src/dpp.c | 3 +++

  1 file changed, 3 insertions(+)
Quoted 13 lines

src/dpp.c static bool dpp_scan_results(int err, struct · line 889

Quoted 11 lines
src/dpp.c +2 -0
index 18b2a7c6..8da79603 100644
@@ -884,6 +884,9 @@ static bool dpp_scan_results(int err, struct 
 l_queue *bss_list,
       /* Purely for grabbing the SSID */
       bss = l_queue_peek_head(bss_list);
   +    if (L_WARN_ON(!util_ssid_is_utf8(bss->ssid_len, bss->ssid)))
+        goto reset;
+

This still seems brittle.  You have the validated SSID from the DPP session, shouldn't you be storing that and using it to filter the scan results?  There's no guarantee that a filtered active scan is going to return only the SSID you asked for (lets say a misbehaving or malicious AP), so assuming that the first BSS in the scan results list is the SSID you want isn't really guaranteed.

Sure I can do that. I was banking on the kernel filtering, but we can be 100% sure and just store the SSID in the dpp_sm.

Quoted 6 lines

src/dpp.c static bool dpp_scan_results(int err, struct l_queue *bss_list, · line 891

Quoted 3 lines
src/dpp.c +0 -0
       memcpy(ssid, bss->ssid, bss->ssid_len);
       ssid[bss->ssid_len] = '\0';

Regards,
-Denis

#4 lore raw
In reply to James Prestwood

Hi James,

Quoted 6 lines · James Prestwood

This was causing unneeded WARNING prints because the DPP state was never checked. Fix this and bail out if DPP isn't running.

---
  src/dpp.c | 3 +++
  1 file changed, 3 insertions(+)

Applied, thanks.

Regards,
-Denis