Skip to contentSkip to conversation

station: check return of handshake_state_set_pmksa

PATCH Superseded James Prestwood 2 participants 3 messages Dec 3, 2025

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 station: check return of handshake_state_set_pmksa

If this fails num_pmkids and pmkids would get set, but to an uninitialized buffer. This would then fail to build the handshake object later when copying the PMKID.

---
 src/station.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
src/station.c +7 -3
index 50997f5f..6c9e8d13 100644
@@ -1378,9 +1378,13 @@ build_ie:
 					bss->ssid, bss->ssid_len,
 					info.akm_suites);
 		if (pmksa) {
-			handshake_state_set_pmksa(hs, pmksa);
-			info.num_pmkids = 1;
-			info.pmkids = hs->pmksa->pmkid;
+			if (!handshake_state_set_pmksa(hs, pmksa)) {
+				l_warn("failed to set PMKSA to handshake");
+				pmksa_cache_free(pmksa);
+			} else {
+				info.num_pmkids = 1;
+				info.pmkids = hs->pmksa->pmkid;
+			}
 		}
 	}
 
Signature · 1 line
2.34.1
#1 lore raw

Hi James,

Quoted 12 lines · James Prestwood

If this fails num_pmkids and pmkids would get set, but to an uninitialized buffer. This would then fail to build the handshake object later when copying the PMKID.

---
  src/station.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
src/station.c +0 -0
index 50997f5f..6c9e8d13 100644

src/station.c build_ie: · line 1381

Quoted 7 lines
src/station.c +1 -3
@@ -1378,9 +1378,13 @@ build_ie:
  					bss->ssid, bss->ssid_len,
  					info.akm_suites);
  		if (pmksa) {
-			handshake_state_set_pmksa(hs, pmksa);
-			info.num_pmkids = 1;
-			info.pmkids = hs->pmksa->pmkid;
+			if (!handshake_state_set_pmksa(hs, pmksa)) {

This seems fishy. Are you sure you're not masking the real issue here? Would this possibly be related to fast transition re-using an old handshake? Maybe we should not try to use or set the PMKSA for FT ?

src/station.c build_ie: · line 1390

Quoted 9 lines
src/station.c +6 -0
+				l_warn("failed to set PMKSA to handshake");
+				pmksa_cache_free(pmksa);
+			} else {
+				info.num_pmkids = 1;
+				info.pmkids = hs->pmksa->pmkid;
+			}
  		}
  	}
 

Regards,
-Denis

#2 lore raw
Quoted 10 lines · Denis Kenzior

Hi James,

Quoted 7 lines · James Prestwood

If this fails num_pmkids and pmkids would get set, but to an uninitialized buffer. This would then fail to build the handshake object later when copying the PMKID.
---
  src/station.c | 10 +++++++---

  1 file changed, 7 insertions(+), 3 deletions(-)
Quoted 14 lines

src/station.c build_ie: · line 1381

Quoted 12 lines
src/station.c +1 -3
index 50997f5f..6c9e8d13 100644
@@ -1378,9 +1378,13 @@ build_ie:
                       bss->ssid, bss->ssid_len,
                       info.akm_suites);
           if (pmksa) {
-            handshake_state_set_pmksa(hs, pmksa);
-            info.num_pmkids = 1;
-            info.pmkids = hs->pmksa->pmkid;
+            if (!handshake_state_set_pmksa(hs, pmksa)) {

This seems fishy.  Are you sure you're not masking the real issue here?  Would this possibly be related to fast transition re-using an old handshake?  Maybe we should not try to use or set the PMKSA for FT ?

Possibly. What happens is we complete an initial association (call it AP1) and establish a PMKSA. Possibly unrelated but IWD did fail to FT due to an association rejection status=40, IWD connects again (different AP), and we then try to FT back to the original AP1. This is where handshake_state_set_pmksa() fails.

Not using PMKSA for FT is reasonable for sure, since there's not really a point there...

Quoted 12 lines

src/station.c build_ie: · line 1389

Quoted 9 lines
src/station.c +6 -0
+                l_warn("failed to set PMKSA to handshake");
+                pmksa_cache_free(pmksa);
+            } else {
+                info.num_pmkids = 1;
+                info.pmkids = hs->pmksa->pmkid;
+            }
           }
       }

Regards,
-Denis