FILS IP address and station shutdown fixes
cover FILS IP address and station shutdown fixes
Two fixes for bugs I hit while testing ell netconfig changes under mac80211_hwsim, with iwd in AP mode as the access point and dnsmasq sending RAs:
1: an iwd AP that has no DHCP lease for the station sends a pending FILS
IP Address Assignment response, and the station then acts on an uninitialized structure. Depending on what was on the stack it got a garbage static IPv4 and IPv6 configuration, or stayed in the connecting (netconfig) state until it was restarted.
2: a GetManagedObjects call while iwd is shutting down reads freed BSSes
(ASan heap-use-after-free). I reproduced this 2 times out of 2 by calling GetManagedObjects in a loop while stopping iwd, and 0 out of 2 with the patch applied.
AI was used to draft patches and commit messages, with all manually reviewed and tested.
Ryan Walklin (2):
ie: Fill in pending FILS IP Address responses
station: Unregister BSS objects before freeing
src/ie.c | 1 + src/station.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-)
Signature · 1 line
2.55.0
PATCH 1/2 ie: Fill in pending FILS IP Address responses
ie_parse_fils_ip_addr_response() returns 0 without writing to @out when the IP address assignment pending flag is set. station_connect_ok() doesn't initialize its info structure, so it then acts on whatever was on the stack: it may report the assignment as failed, as OK with all zeros, or as OK with a garbage address, gateway and DNS server that get installed as static configuration. If the garbage doesn't pass netconfig_load_fils_settings(), netconfig_configure() fails and the station stays in the connecting (netconfig) state.
An iwd AP with no DHCP lease for the station always sends a pending response, so this can be seen with an iwd AP and an iwd station that use different network configuration settings.
--- src/ie.c | 1 + 1 file changed, 1 insertion(+)
src/ie.c +1 -0
@@ -2419,6 +2419,7 @@ int ie_parse_fils_ip_addr_response(struct ie_tlv_iter *iter,if (info.response_pending) { info.response_timeout =bit_field (*resp_ctrl,1 ,6 );/* seconds */ +memcpy (out, &info,sizeof (info));return 0 ; }
Signature · 1 line
2.55.0
PATCH 2/2 station: Unregister BSS objects before freeing
In reply to Ryan Walklinstation_free() frees the BSSes in bss_list without unregistering their D-Bus objects. Removing the network objects doesn't remove the BSS objects below them, so a GetManagedObjects call while iwd is shutting down still reaches the BSSes through the object tree and network_bss_property_get_address() reads freed memory:
ERROR: AddressSanitizer: heap-use-after-free
#0 util_address_to_string src/util.c:115
#1 network_bss_property_get_address src/network.c:2197 #2 get_properties_dict ell/dbus-service.c:824
...
freed by thread T0 here:
#3 station_free src/station.c:5269
#4 station_destroy_interface src/station.c:5337
...
#8 netdev_free src/netdev.c:1047
#9 netdev_shutdown src/netdev.c:6896Unregister each BSS object first. station_unregister_bss() isn't used since it warns about BSSes without an object path, which bss_list has when the security type can't be determined.
--- src/station.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
src/station.c +16 -1
@@ -5193,6 +5193,8 @@ static struct station *station_create(struct netdev *netdev)static void station_free (struct station *station) { +struct scan_bss *bss; +l_debug ("" );if (!l_queue_remove (station_list, station))
@@ -5264,9 +5266,22 @@ static void station_free(struct station *station)station_roam_state_clear (station); +/* +* Unregister the BSS objects before freeing the BSSes, otherwise a +* GetManagedObjects call can still reach them through the object tree. +*/ +while ((bss =l_queue_pop_head (station->bss_list))) { +const char *path =station_get_bss_path (station, bss); + +if (path) +l_dbus_unregister_object (dbus_get_bus (), path); + +scan_bss_free (bss); + } + +l_queue_destroy (station->bss_list,NULL );l_queue_destroy (station->networks_sorted,NULL );l_hashmap_destroy (station->networks, network_free); -l_queue_destroy (station->bss_list, bss_free);l_queue_destroy (station->hidden_bss_list_sorted,NULL );l_queue_destroy (station->autoconnect_list,NULL );
Signature · 1 line
2.55.0