[PATCH 1/1] dbus: Add D-Bus property for PSK mismatch heuristics
Yichen Yu
yichenyu at chromium.org
Fri Dec 16 16:10:18 PST 2022
As a workup action during disassociation, wpa_supplicant checks if the
disconnection is caused by PSK mismatch during WPA 4way handshake with
function 'could_be_psk_mismatch' in event.c. A MSG_INFO will be logged
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, a new property 'PskMismatch' is added and a corresponding D-Bus
PropertiesChanged signal is propogated to notify other applicantions.
Signed-off-by: Yichen Yu <yichenyu at chromium.org>
---
wpa_supplicant/dbus/dbus_new.c | 9 +++++++++
wpa_supplicant/dbus/dbus_new.h | 1 +
wpa_supplicant/dbus/dbus_new_handlers.c | 20 ++++++++++++++++++++
wpa_supplicant/dbus/dbus_new_handlers.h | 1 +
wpa_supplicant/events.c | 1 +
wpa_supplicant/notify.c | 8 ++++++++
wpa_supplicant/notify.h | 1 +
7 files changed, 41 insertions(+)
diff --git a/wpa_supplicant/dbus/dbus_new.c b/wpa_supplicant/dbus/dbus_new.c
index 9c23588c8..a1e4038da 100644
--- a/wpa_supplicant/dbus/dbus_new.c
+++ b/wpa_supplicant/dbus/dbus_new.c
@@ -2350,6 +2350,9 @@ void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
case WPAS_DBUS_PROP_SIGNAL_CHANGE:
prop = "SignalChange";
break;
+ case WPAS_DBUS_PROP_PSK_MISMATCH:
+ prop = "PskMismatch";
+ break;
default:
wpa_printf(MSG_ERROR, "dbus: %s: Unknown Property value %d",
__func__, property);
@@ -3922,6 +3925,12 @@ static const struct wpa_dbus_property_desc wpas_dbus_interface_properties[] = {
NULL,
NULL
},
+ {
+ "PskMismatch", WPAS_DBUS_NEW_IFACE_INTERFACE, "b",
+ wpas_dbus_getter_psk_mismatch,
+ NULL,
+ NULL
+ },
#ifdef CONFIG_MESH
{ "MeshPeers", WPAS_DBUS_NEW_IFACE_MESH, "aay",
wpas_dbus_getter_mesh_peers,
diff --git a/wpa_supplicant/dbus/dbus_new.h b/wpa_supplicant/dbus/dbus_new.h
index ca8506f87..b80cbff2d 100644
--- a/wpa_supplicant/dbus/dbus_new.h
+++ b/wpa_supplicant/dbus/dbus_new.h
@@ -40,6 +40,7 @@ enum wpas_dbus_prop {
WPAS_DBUS_PROP_BSS_TM_STATUS,
WPAS_DBUS_PROP_MAC_ADDRESS,
WPAS_DBUS_PROP_SIGNAL_CHANGE,
+ WPAS_DBUS_PROP_PSK_MISMATCH,
};
enum wpas_dbus_bss_prop {
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index 9a0f8c157..39a7f427d 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -3730,6 +3730,26 @@ dbus_bool_t wpas_dbus_getter_bss_tm_status(
}
+/**
+ * wpas_dbus_getter_psk_mismatch - Get true when PSK mismatches
+ * @iter: Pointer to incoming dbus message iter
+ * @error: Location to store error on failure
+ * @user_data: Function specific data
+ * Returns: TRUE on success, FALSE on failure
+ *
+ * Getter function for "PskMismatch" property.
+ */
+dbus_bool_t wpas_dbus_getter_psk_mismatch(
+ const struct wpa_dbus_property_desc *property_desc,
+ DBusMessageIter *iter, DBusError *error, void *user_data)
+{
+ dbus_bool_t is_psk_mismatch = TRUE;
+
+ return wpas_dbus_simple_property_getter(iter, DBUS_TYPE_BOOLEAN,
+ &is_psk_mismatch, error);
+}
+
+
/**
* wpas_dbus_getter_bss_expire_age - Get BSS entry expiration age
* @iter: Pointer to incoming dbus message iter
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.h b/wpa_supplicant/dbus/dbus_new_handlers.h
index 97fa337bd..d9f1a7758 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.h
+++ b/wpa_supplicant/dbus/dbus_new_handlers.h
@@ -172,6 +172,7 @@ DECLARE_ACCESSOR(wpas_dbus_getter_roam_time);
DECLARE_ACCESSOR(wpas_dbus_getter_roam_complete);
DECLARE_ACCESSOR(wpas_dbus_getter_session_length);
DECLARE_ACCESSOR(wpas_dbus_getter_bss_tm_status);
+DECLARE_ACCESSOR(wpas_dbus_getter_psk_mismatch);
DECLARE_ACCESSOR(wpas_dbus_getter_bss_expire_age);
DECLARE_ACCESSOR(wpas_dbus_setter_bss_expire_age);
DECLARE_ACCESSOR(wpas_dbus_getter_bss_expire_count);
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index e55dbce5a..b9ba950ba 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -3926,6 +3926,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..904d108a2 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -185,6 +185,14 @@ void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
}
+void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s)
+{
+ if (wpa_s->p2p_mgmt)
+ return;
+
+ wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_PSK_MISMATCH);
+}
+
void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
{
diff --git a/wpa_supplicant/notify.h b/wpa_supplicant/notify.h
index 78ae4bcb1..686657680 100644
--- a/wpa_supplicant/notify.h
+++ b/wpa_supplicant/notify.h
@@ -32,6 +32,7 @@ void wpas_notify_roam_time(struct wpa_supplicant *wpa_s);
void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s);
void wpas_notify_session_length(struct wpa_supplicant *wpa_s);
void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s);
+void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s);
void wpas_notify_network_changed(struct wpa_supplicant *wpa_s);
void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s);
void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s);
--
2.37.3
More information about the Hostap
mailing list