diff mbox series

station: fix potential NULL access with forced roam

Message ID 20230502185955.436081-1-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series station: fix potential NULL access with forced roam | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-alpine-ci-makedistcheck fail Make Distcheck Make FAIL: make[2]: *** No rule to make target 'ell/sysctl.h', needed by 'distdir-am'. Stop. make[1]: *** [Makefile:3218: distdir] Error 2 make: *** [Makefile:3298: dist] Error 2
prestwoj/iwd-alpine-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makecheckvalgrind fail Make FAIL: make[1]: *** No rule to make target 'ell/sysctl.c', needed by 'ell/sysctl.lo'. Stop. make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1710: all] Error 2
prestwoj/iwd-alpine-ci-makecheck pending makecheck SKIP
prestwoj/iwd-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-ci-makecheckvalgrind fail Make FAIL: make[1]: *** No rule to make target 'ell/sysctl.c', needed by 'ell/sysctl.lo'. Stop. make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1709: all] Error 2
prestwoj/iwd-ci-makecheck pending makecheck SKIP
prestwoj/iwd-ci-clang fail Clang IWD - make FAIL: make[1]: *** No rule to make target 'ell/sysctl.c', needed by 'ell/sysctl.lo'. Stop. make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1709: all] Error 2
prestwoj/iwd-ci-makedistcheck fail Make Distcheck Make FAIL: make[2]: *** No rule to make target 'ell/sysctl.h', needed by 'distdir-am'. Stop. make[1]: *** [Makefile:3217: distdir] Error 2 make: *** [Makefile:3297: dist] Error 2
prestwoj/iwd-ci-testrunner pending testrunner SKIP

Commit Message

James Prestwood May 2, 2023, 6:59 p.m. UTC
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(-)

Comments

Denis Kenzior May 7, 2023, 11:10 p.m. UTC | #1
Hi James,

On 5/2/23 13:59, James Prestwood wrote:
> 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?

> diff --git a/src/station.c b/src/station.c
> index be571083..9104ebf6 100644
> --- a/src/station.c
> +++ b/src/station.c
> @@ -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.

>   	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
James Prestwood May 8, 2023, 1:49 p.m. UTC | #2
Hi Denis,

On 5/7/23 4:10 PM, Denis Kenzior wrote:
> Hi James,
> 
> On 5/2/23 13:59, James Prestwood wrote:
>> 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?
> 
>> diff --git a/src/station.c b/src/station.c
>> index be571083..9104ebf6 100644
>> --- a/src/station.c
>> +++ b/src/station.c
>> @@ -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.

> 
>>       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
diff mbox series

Patch

diff --git a/src/station.c b/src/station.c
index be571083..9104ebf6 100644
--- a/src/station.c
+++ b/src/station.c
@@ -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;
 	}