diff mbox series

station: fix crash when deauth comes before FT work completes

Message ID 20231127124947.273760-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series station: fix crash when deauth comes before FT work completes | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint fail station: fix crash when deauth comes before FT work completes 28: B1 Line exceeds max length (87>80): "src/netconfig-commit.c:netconfig_commit_print_addrs() removing address: yyy.yyy.yyy.yyy" 31: B1 Line exceeds max length (81>80): "src/station.c:station_enter_state() Old State: connected, new state: disconnected" 32: B1 Line exceeds max length (89>80): "src/station.c:station_enter_state() Old State: disconnected, new state: autoconnect_quick"
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-testrunner success test-runner PASS

Commit Message

James Prestwood Nov. 27, 2023, 12:49 p.m. UTC
If the FT-Authenticate frame has been sent then a deauth is received
the work item for sending the FT-Associate frame is never canceled.
When this runs station->connected_network is NULL which causes a
crash:

src/station.c:station_try_next_transition() 7, target xx:xx:xx:xx:xx:xx
src/wiphy.c:wiphy_radio_work_insert() Inserting work item 5843
src/wiphy.c:wiphy_radio_work_insert() Inserting work item 5844
src/wiphy.c:wiphy_radio_work_done() Work item 5842 done
src/wiphy.c:wiphy_radio_work_next() Starting work item 5843
src/netdev.c:netdev_mlme_notify() MLME notification Remain on Channel(55)
src/ft.c:ft_send_authenticate()
src/netdev.c:netdev_mlme_notify() MLME notification Frame TX Status(60)
src/netdev.c:netdev_link_notify() event 16 on ifindex 7
src/netdev.c:netdev_mlme_notify() MLME notification Del Station(20)
src/netdev.c:netdev_mlme_notify() MLME notification Deauthenticate(39)
src/netdev.c:netdev_deauthenticate_event()
src/netdev.c:netdev_mlme_notify() MLME notification Disconnect(48)
src/netdev.c:netdev_disconnect_event()
Received Deauthentication event, reason: 7, from_ap: true
src/station.c:station_disconnect_event() 7
src/station.c:station_disassociated() 7
src/station.c:station_reset_connection_state() 7
src/station.c:station_roam_state_clear() 7
src/netconfig.c:netconfig_event_handler() l_netconfig event 2
src/netconfig-commit.c:netconfig_commit_print_addrs() removing address: yyy.yyy.yyy.yyy
src/resolve.c:resolve_systemd_revert() ifindex: 7
[DHCPv4] l_dhcp_client_stop:1264 Entering state: DHCP_STATE_INIT
src/station.c:station_enter_state() Old State: connected, new state: disconnected
src/station.c:station_enter_state() Old State: disconnected, new state: autoconnect_quick
src/wiphy.c:wiphy_radio_work_insert() Inserting work item 5845
src/netdev.c:netdev_mlme_notify() MLME notification Cancel Remain on Channel(56)
src/wiphy.c:wiphy_radio_work_done() Work item 5843 done
src/wiphy.c:wiphy_radio_work_next() Starting work item 5844

"Program terminated with signal SIGSEGV, Segmentation fault.",
"#0  0x0000565359ee3f54 in network_bss_find_by_addr ()",
"#0  0x0000565359ee3f54 in network_bss_find_by_addr ()",
"#1  0x0000565359ec9d23 in station_ft_work_ready ()",
"#2  0x0000565359ec0af0 in wiphy_radio_work_next ()",
"#3  0x0000565359f20080 in offchannel_mlme_notify ()",
"#4  0x0000565359f4416b in received_data ()",
"#5  0x0000565359f40d90 in io_callback ()",
"#6  0x0000565359f3ff4d in l_main_iterate ()",
"#7  0x0000565359f4001c in l_main_run ()",
"#8  0x0000565359f40240 in l_main_run_with_signal ()",
"#9  0x0000565359eb3888 in main ()"
---
 src/station.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Denis Kenzior Nov. 27, 2023, 3:24 p.m. UTC | #1
Hi James,

On 11/27/23 06:49, James Prestwood wrote:
> If the FT-Authenticate frame has been sent then a deauth is received
> the work item for sending the FT-Associate frame is never canceled.
> When this runs station->connected_network is NULL which causes a
> crash:
> 
> src/station.c:station_try_next_transition() 7, target xx:xx:xx:xx:xx:xx
> src/wiphy.c:wiphy_radio_work_insert() Inserting work item 5843
> src/wiphy.c:wiphy_radio_work_insert() Inserting work item 5844
> src/wiphy.c:wiphy_radio_work_done() Work item 5842 done
> src/wiphy.c:wiphy_radio_work_next() Starting work item 5843
> src/netdev.c:netdev_mlme_notify() MLME notification Remain on Channel(55)
> src/ft.c:ft_send_authenticate()
> src/netdev.c:netdev_mlme_notify() MLME notification Frame TX Status(60)
> src/netdev.c:netdev_link_notify() event 16 on ifindex 7
> src/netdev.c:netdev_mlme_notify() MLME notification Del Station(20)
> src/netdev.c:netdev_mlme_notify() MLME notification Deauthenticate(39)
> src/netdev.c:netdev_deauthenticate_event()
> src/netdev.c:netdev_mlme_notify() MLME notification Disconnect(48)
> src/netdev.c:netdev_disconnect_event()
> Received Deauthentication event, reason: 7, from_ap: true
> src/station.c:station_disconnect_event() 7
> src/station.c:station_disassociated() 7
> src/station.c:station_reset_connection_state() 7
> src/station.c:station_roam_state_clear() 7
> src/netconfig.c:netconfig_event_handler() l_netconfig event 2
> src/netconfig-commit.c:netconfig_commit_print_addrs() removing address: yyy.yyy.yyy.yyy
> src/resolve.c:resolve_systemd_revert() ifindex: 7
> [DHCPv4] l_dhcp_client_stop:1264 Entering state: DHCP_STATE_INIT
> src/station.c:station_enter_state() Old State: connected, new state: disconnected
> src/station.c:station_enter_state() Old State: disconnected, new state: autoconnect_quick
> src/wiphy.c:wiphy_radio_work_insert() Inserting work item 5845
> src/netdev.c:netdev_mlme_notify() MLME notification Cancel Remain on Channel(56)
> src/wiphy.c:wiphy_radio_work_done() Work item 5843 done
> src/wiphy.c:wiphy_radio_work_next() Starting work item 5844
> 
> "Program terminated with signal SIGSEGV, Segmentation fault.",
> "#0  0x0000565359ee3f54 in network_bss_find_by_addr ()",
> "#0  0x0000565359ee3f54 in network_bss_find_by_addr ()",
> "#1  0x0000565359ec9d23 in station_ft_work_ready ()",
> "#2  0x0000565359ec0af0 in wiphy_radio_work_next ()",
> "#3  0x0000565359f20080 in offchannel_mlme_notify ()",
> "#4  0x0000565359f4416b in received_data ()",
> "#5  0x0000565359f40d90 in io_callback ()",
> "#6  0x0000565359f3ff4d in l_main_iterate ()",
> "#7  0x0000565359f4001c in l_main_run ()",
> "#8  0x0000565359f40240 in l_main_run_with_signal ()",
> "#9  0x0000565359eb3888 in main ()"
> ---
>   src/station.c | 3 +++
>   1 file changed, 3 insertions(+)
> 

Applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/station.c b/src/station.c
index ff8a7466..49cad135 100644
--- a/src/station.c
+++ b/src/station.c
@@ -1721,6 +1721,9 @@  static void station_roam_state_clear(struct station *station)
 	l_queue_clear(station->roam_bss_list, l_free);
 
 	ft_clear_authentications(netdev_get_ifindex(station->netdev));
+
+	if (station->ft_work.id)
+		wiphy_radio_work_done(station->wiphy, station->ft_work.id);
 }
 
 static void station_reset_connection_state(struct station *station)