From 870edfd67e414e27248f990d7636a62bcbe4ccc0 Mon Sep 17 00:00:00 2001 From: Vinayak Yadawad Date: Tue, 6 Dec 2022 14:52:27 +0530 Subject: [PATCH] WPA3: Update transition disable bitmap based on port authorized event In case of drivers that offload the 4-way handshake to the driver, there was no way of updating wpa_supplicant about the transition disable bitmap received as a part of EAPOL-Key msg 3/4. With latest provisions in cfg80211_port_authorized(), the TD bitmap can be sent to the upper layer. Parse that as a part of the port authorized event and set the transition disable information accordingly. Signed-off-by: Vinayak Yadawad --- src/drivers/driver.h | 7 +++++++ src/drivers/driver_nl80211_event.c | 13 ++++++++++++- wpa_supplicant/events.c | 9 +++++++++ wpa_supplicant/wpas_glue.c | 10 ++++++++-- wpa_supplicant/wpas_glue.h | 2 ++ 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 71e6e658a..cb27282aa 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -6472,6 +6472,13 @@ union wpa_event_data { */ struct pasn_auth pasn_auth; + /** + * struct port_authorized - Data for EVENT_PORT_AUTHORIZED + */ + struct port_authorized { + const u8 *td_bitmap; + size_t td_bitmap_len; + } port_authorized; }; /** diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index bb80fbe39..29613161b 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -3158,6 +3158,9 @@ static void nl80211_port_authorized(struct wpa_driver_nl80211_data *drv, struct nlattr **tb) { const u8 *addr; + union wpa_event_data event; + + os_memset(&event, 0, sizeof(event)); if (!tb[NL80211_ATTR_MAC] || nla_len(tb[NL80211_ATTR_MAC]) != ETH_ALEN) { @@ -3175,7 +3178,15 @@ static void nl80211_port_authorized(struct wpa_driver_nl80211_data *drv, return; } - wpa_supplicant_event(drv->ctx, EVENT_PORT_AUTHORIZED, NULL); + if (tb[NL80211_ATTR_TD_BITMAP]) { + event.port_authorized.td_bitmap_len = + nla_len(tb[NL80211_ATTR_TD_BITMAP]); + if (event.port_authorized.td_bitmap_len > 0) + event.port_authorized.td_bitmap = + nla_data(tb[NL80211_ATTR_TD_BITMAP]); + } + + wpa_supplicant_event(drv->ctx, EVENT_PORT_AUTHORIZED, &event); } diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 77f0b661a..1d228f4b7 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -6061,6 +6061,15 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, break; #endif /* CONFIG_PASN */ case EVENT_PORT_AUTHORIZED: +#ifndef CONFIG_NO_WPA + if (data->port_authorized.td_bitmap_len) { + wpa_printf(MSG_DEBUG, + "WPA3: Transition Disable bitmap from the driver event: 0x%x", + data->port_authorized.td_bitmap[0]); + wpas_transition_disable( + wpa_s, data->port_authorized.td_bitmap[0]); + } +#endif /* CONFIG_NO_WPA */ wpa_supplicant_event_port_authorized(wpa_s); break; case EVENT_STATION_OPMODE_CHANGED: diff --git a/wpa_supplicant/wpas_glue.c b/wpa_supplicant/wpas_glue.c index a309ea278..e5a4053c8 100644 --- a/wpa_supplicant/wpas_glue.c +++ b/wpa_supplicant/wpas_glue.c @@ -1282,9 +1282,8 @@ static void disable_wpa_wpa2(struct wpa_ssid *ssid) } -static void wpa_supplicant_transition_disable(void *_wpa_s, u8 bitmap) +void wpas_transition_disable(struct wpa_supplicant *wpa_s, u8 bitmap) { - struct wpa_supplicant *wpa_s = _wpa_s; struct wpa_ssid *ssid; int changed = 0; @@ -1354,6 +1353,13 @@ static void wpa_supplicant_transition_disable(void *_wpa_s, u8 bitmap) } +static void wpa_supplicant_transition_disable(void *_wpa_s, u8 bitmap) +{ + struct wpa_supplicant *wpa_s = _wpa_s; + wpas_transition_disable(wpa_s, bitmap); +} + + static void wpa_supplicant_store_ptk(void *ctx, u8 *addr, int cipher, u32 life_time, const struct wpa_ptk *ptk) { diff --git a/wpa_supplicant/wpas_glue.h b/wpa_supplicant/wpas_glue.h index 338af4e65..dd692b902 100644 --- a/wpa_supplicant/wpas_glue.h +++ b/wpa_supplicant/wpas_glue.h @@ -27,4 +27,6 @@ enum wpa_ctrl_req_type wpa_supplicant_ctrl_req_from_string(const char *field); void wpas_send_ctrl_req(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, const char *field_name, const char *txt); +void wpas_transition_disable(struct wpa_supplicant *wpa_s, u8 bitmap); + #endif /* WPAS_GLUE_H */