diff mbox series

[RESEND,2/2] wpa_supplicant: Clear WPA/EAPOL config when the current network is removed

Message ID CAB8Pm=xgCG8wwDcfkSgSVnCMD_GZRwxLfnFa=EDxV14Lrrx-1w@mail.gmail.com
State New
Headers show
Series [RESEND,1/2] WPS: Keep the in-use network valid when removing a duplicate credential | expand

Commit Message

Alejandro Pacheco Oct. 17, 2026, 1:10 p.m. UTC
wpas_notify_network_removed() clears wpa_s->current_ssid when the
network block being removed is the current one, but the WPA and EAPOL
state machines keep their own pointers to that network block (the
network context and the EAP peer configuration).
wpa_supplicant_remove_network(), wpa_supplicant_remove_all_networks()
and wpas_clear_wps() clear these explicitly before freeing the block,
but some other paths that call wpas_notify_network_removed() and
wpa_config_remove_network() do not, so removing the current network on
one of those paths leaves the state machines pointing to freed memory.

Clear the WPA and EAPOL configuration at the same place current_ssid is
cleared so that every removal of the current network through this
notification drops these references together.

Signed-off-by: Alejandro Pacheco <alepacheco99@gmail.com>
---
Resent: the first posting of this patch
(<CAB8Pm=wr7qy2VBxuQyLYwrXS=gFnhVwmA0psNH_DQ6HTs1oDTQ@mail.gmail.com>)
reached the list with its long lines wrapped, so it does not apply.
The patch is unchanged. This time the diff is attached as plain text so
that it arrives intact; git am takes this mail as it is.

 wpa_supplicant/notify.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 18cd63113..13e201c46 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -20,6 +20,7 @@ 
 #include "dbus/dbus_new.h"
 #include "rsn_supp/wpa.h"
 #include "rsn_supp/pmksa_cache.h"
+#include "eapol_supp/eapol_supp_sm.h"
 #include "fst/fst.h"
 #include "crypto/tls.h"
 #include "bss.h"
@@ -412,8 +413,11 @@  void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
 		wpa_s->next_ssid = NULL;
 	if (wpa_s->last_ssid == ssid)
 		wpa_s->last_ssid = NULL;
-	if (wpa_s->current_ssid == ssid)
+	if (wpa_s->current_ssid == ssid) {
 		wpa_s->current_ssid = NULL;
+		wpa_sm_set_config(wpa_s->wpa, NULL);
+		eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
+	}
 	if (wpa_s->ml_connect_probe_ssid == ssid) {
 		wpa_s->ml_connect_probe_ssid = NULL;
 		wpa_s->ml_connect_probe_bss = NULL;