From a678a510fb207b02413903b9206962f48bf1c428 Mon Sep 17 00:00:00 2001 From: Yichen Yu Date: Tue, 20 Dec 2022 07:08:41 +0000 Subject: [PATCH] dbus: Add D-Bus signal for PSK mismatch heuristics As a workup action during disassociation, wpa_supplicant checks if the disconnection could have been caused by PSK mismatch during WPA 4-way handshake with function could_be_psk_mismatch() in event.c. A MSG_INFO message will be sent on the control interface when there could be a PSK mismatch, and this heuristic can be useful to indicate if the disconnection is caused by a wrong passphrase provided by the user. Here, propagate a new D-Bus signal 'PskMismatch' to notify other applicantions. Signed-off-by: Yichen Yu --- doc/dbus.doxygen | 5 +++++ wpa_supplicant/dbus/dbus_new.c | 23 +++++++++++++++++++++++ wpa_supplicant/dbus/dbus_new.h | 5 +++++ wpa_supplicant/events.c | 1 + wpa_supplicant/notify.c | 6 ++++++ wpa_supplicant/notify.h | 1 + 6 files changed, 41 insertions(+) diff --git a/doc/dbus.doxygen b/doc/dbus.doxygen index f75917c2a..87f4c02fb 100644 --- a/doc/dbus.doxygen +++ b/doc/dbus.doxygen @@ -1329,6 +1329,11 @@ fi.w1.wpa_supplicant1.CreateInterface.
  • InterworkingSelectDone ( )

  • + +
  • +

    PskMismatch ( )

    +

    A possible PSK mismatch is identified.

    +
  • diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c index 9c23588c8..8fc29b398 100644 --- a/wpa_supplicant/dbus/dbus_new.c +++ b/wpa_supplicant/dbus/dbus_new.c @@ -1102,6 +1102,29 @@ void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s, } +void wpas_dbus_signal_psk_mismatch(struct wpa_supplicant *wpa_s) +{ + struct wpas_dbus_priv *iface; + DBusMessage *msg; + + iface = wpa_s->global->dbus; + + /* Do nothing if the control interface is not turned on */ + if (!iface || !wpa_s->dbus_new_path) + return; + + msg = dbus_message_new_signal(wpa_s->dbus_new_path, + WPAS_DBUS_NEW_IFACE_INTERFACE, + "PskMismatch"); + if (!msg) + return; + + dbus_connection_send(iface->con, msg, NULL); + + dbus_message_unref(msg); +} + + /** * wpas_dbus_signal_sta - Send a station related event signal * @wpa_s: %wpa_supplicant network interface data diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h index ca8506f87..5c5d85506 100644 --- a/wpa_supplicant/dbus/dbus_new.h +++ b/wpa_supplicant/dbus/dbus_new.h @@ -254,6 +254,7 @@ void wpas_dbus_signal_preq(struct wpa_supplicant *wpa_s, const u8 *ie, size_t ie_len, u32 ssi_signal); void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s, const char *status, const char *parameter); +void wpas_dbus_signal_psk_mismatch(struct wpa_supplicant *wpa_s); void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s, const u8 *sta); void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s, @@ -585,6 +586,10 @@ static inline void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s, { } +static inline void wpas_dbus_signal_psk_mismatch(struct wpa_supplicant *wpa_s) +{ +} + static inline void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s, const u8 *sta) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index c3f0e744e..e58a3da83 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -3977,6 +3977,7 @@ static void wpa_supplicant_event_disassoc_finish(struct wpa_supplicant *wpa_s, if (wpas_p2p_4way_hs_failed(wpa_s) > 0) return; /* P2P group removed */ wpas_auth_failed(wpa_s, "WRONG_KEY", prev_pending_bssid); + wpas_notify_psk_mismatch(wpa_s); #ifdef CONFIG_DPP2 wpas_dpp_send_conn_status_result(wpa_s, DPP_STATUS_AUTH_FAILURE); diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c index d8a64327c..4b4a34b52 100644 --- a/wpa_supplicant/notify.c +++ b/wpa_supplicant/notify.c @@ -877,6 +877,12 @@ void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code) } +void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s) +{ + wpas_dbus_signal_psk_mismatch(wpa_s); +} + + void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) { diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h index 78ae4bcb1..efb9efa07 100644 --- a/wpa_supplicant/notify.h +++ b/wpa_supplicant/notify.h @@ -143,6 +143,7 @@ void wpas_notify_preq(struct wpa_supplicant *wpa_s, void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status, const char *parameter); void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code); +void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s); void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid); void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,