Skip to contentSkip to conversation

station: fix potential NULL access with forced roam

PATCH In review James Prestwood 2 participants 3 messages May 2, 2023 – May 8, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 station: fix potential NULL access with forced roam

If forcing a roam using developer mode IWD could become unconnected during the scan and result in a segfault when the network_get_security() is called.

---
 src/station.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/station.c +1 -1
index be571083..9104ebf6 100644
@@ -2482,7 +2482,7 @@ static bool station_roam_scan_notify(int err, struct l_queue *bss_list,
 	uint16_t mdid;
 	enum security orig_security, security;
 
-	if (err) {
+	if (err || !network) {
 		station_roam_failed(station);
 		return false;
 	}
Signature · 1 line
2.25.1
#1 lore raw

Hi James,

Quoted 7 lines · James Prestwood

If forcing a roam using developer mode IWD could become unconnected during the scan and result in a segfault when the network_get_security() is called.

---
  src/station.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Do you have a backtrace?

src/station.c static bool station_roam_scan_notify(int err, struct l_queue *bss_list,

Quoted 5 lines
src/station.c +0 -0
index be571083..9104ebf6 100644
@@ -2482,7 +2482,7 @@ static bool station_roam_scan_notify(int err, struct l_queue *bss_list,

This seems suspicious. Forced roam should be going via station_force_roam_scan_notify(), not via this callback.

src/station.c static bool station_roam_scan_notify(int err, struct l_queue *bss_list, · line 2488

Quoted 8 lines
src/station.c +1 -1
  	uint16_t mdid;
  	enum security orig_security, security;
 
-	if (err) {
+	if (err || !network) {
  		station_roam_failed(station);
  		return false;
  	}

And even then, isn't station->roam_scan_id canceled, so the callback shouldn't even be called in the first place?

Regards,
-Denis

#2 lore raw

Hi Denis,

Quoted 13 lines · Denis Kenzior

Hi James,

Quoted 7 lines · James Prestwood

If forcing a roam using developer mode IWD could become unconnected during the scan and result in a segfault when the network_get_security() is called.
---
  src/station.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)

Do you have a backtrace?

Quoted 8 lines

src/station.c static bool station_roam_scan_notify(int err, · line 2482

Quoted 6 lines
src/station.c +0 -0
index be571083..9104ebf6 100644
@@ -2482,7 +2482,7 @@ static bool station_roam_scan_notify(int err, 
 struct l_queue *bss_list,

This seems suspicious.  Forced roam should be going via station_force_roam_scan_notify(), not via this callback.

Yes true. I did see this crash here but maybe it was related to local changes. I was roaming back and forth but your right, a forced roam shouldn't ever hit this callback.

I'll get back to you on this.

Quoted 13 lines

src/station.c static bool station_roam_scan_notify(int err, struct l_queue *bss_list, · line 2488

Quoted 8 lines
src/station.c +1 -1
       uint16_t mdid;
       enum security orig_security, security;
-    if (err) {
+    if (err || !network) {
           station_roam_failed(station);
           return false;
       }

And even then, isn't station->roam_scan_id canceled, so the callback shouldn't even be called in the first place?

Regards,
-Denis