eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit 6b51f0972e9ec0fa1904fbc70433deb2cd640fea
parent 66b52592f42828cb9837e17b34a5653acc285e2c
Author: illiliti <illiliti@protonmail.com>
Date:   Thu,  2 Feb 2023 23:53:35 +0300

Merge tag '2.3'

Release 2.3

Diffstat:
MChangeLog | 6++++++
Mconfigure.ac | 2+-
Mmonitor/nlmon.c | 7+++++--
Msrc/ap.c | 3++-
Msrc/eap-tls-common.c | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
Msrc/iwd.network.rst | 15+++++++++++++++
6 files changed, 99 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,9 @@ +ver 2.3: + Fix issue with length calculation for WMM IE. + Fix issue with channel number allocation off-by-one. + Fix issue with cached session when TLS phase2 fails. + Add support for FastReauthentication setting for EAP-TLS. + ver 2.2: Fix issue with handling FT and multiple roaming scans. Fix issue with handling multiple wiphy registrations. diff --git a/configure.ac b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ([2.69]) -AC_INIT([iwd],[2.2]) +AC_INIT([iwd],[2.3]) AC_CONFIG_HEADERS(config.h) AC_CONFIG_AUX_DIR(build-aux) diff --git a/monitor/nlmon.c b/monitor/nlmon.c @@ -4530,6 +4530,7 @@ static void print_authentication_mgmt_frame(unsigned int level, { const char *str; const struct mmpdu_authentication *body; + uint16_t alg; if (!mmpdu) return; @@ -4540,8 +4541,9 @@ static void print_authentication_mgmt_frame(unsigned int level, print_mpdu_frame_control(level + 1, &mmpdu->fc); print_mmpdu_header(level + 1, mmpdu); + alg = L_LE16_TO_CPU(body->algorithm); - switch (L_LE16_TO_CPU(body->algorithm)) { + switch (alg) { case MMPDU_AUTH_ALGO_OPEN_SYSTEM: str = "Open"; break; @@ -4563,7 +4565,8 @@ static void print_authentication_mgmt_frame(unsigned int level, L_LE16_TO_CPU(body->transaction_sequence), L_LE16_TO_CPU(body->status)); - if (L_LE16_TO_CPU(body->algorithm) != MMPDU_AUTH_ALGO_SHARED_KEY) + if (!L_IN_SET(alg, MMPDU_AUTH_ALGO_SHARED_KEY, + MMPDU_AUTH_ALGO_FT, MMPDU_AUTH_ALGO_SAE)) return; if (L_LE16_TO_CPU(body->transaction_sequence) < 2 || diff --git a/src/ap.c b/src/ap.c @@ -939,8 +939,9 @@ static size_t ap_get_extra_ies_len(struct ap_state *ap, len += ap_get_wsc_ie_len(ap, type, client_frame, client_frame_len); + /* WMM IE length */ if (ap->supports_ht) - len += 26; + len += 50; if (ap->ops->get_extra_ies_len) len += ap->ops->get_extra_ies_len(type, client_frame, diff --git a/src/eap-tls-common.c b/src/eap-tls-common.c @@ -115,6 +115,8 @@ struct eap_tls_state { bool expecting_frag_ack:1; bool tunnel_ready:1; + bool tls_session_resumed:1; + bool tls_cache_disabled:1; struct l_queue *ca_cert; struct l_certchain *client_cert; @@ -129,8 +131,11 @@ static struct l_settings *eap_tls_session_cache; static eap_tls_session_cache_load_func_t eap_tls_session_cache_load; static eap_tls_session_cache_sync_func_t eap_tls_session_cache_sync; -static void __eap_tls_common_state_reset(struct eap_tls_state *eap_tls) +static void __eap_tls_common_state_reset(struct eap_state *eap) { + struct eap_tls_state *eap_tls = eap_get_data(eap); + const char *peer_id; + eap_tls->version_negotiated = EAP_TLS_VERSION_NOT_NEGOTIATED; eap_tls->method_completed = false; eap_tls->phase2_failed = false; @@ -145,6 +150,43 @@ static void __eap_tls_common_state_reset(struct eap_tls_state *eap_tls) if (eap_tls->tunnel) l_tls_reset(eap_tls->tunnel); + /* + * Drop the TLS session cache for this peer if the overall EAP + * method didn't succeed. + * + * Additionally if the session was cached previously, meaning + * that we've had a successful authentication at least once before, + * and we now used session resumption successfully and the method + * failed, become suspicious of this server's TLS session + * resumption support. Some authenticators strangely allow + * resumption but can't handle it all the way to EAP method + * success. This improves the chances that authentication + * succeeds on the next attempt. + * + * Drop the cache even if we have no indication that the + * method failed but it just didn't succeed, to handle cases like + * the server getting stuck and a timout occuring at a higher + * layer. The risk is that we may occasionally flush the session + * data when there was only a momentary radio issue, invalid + * phase2 credentials or decision to abort. Those are not hot + * paths. + * + * Note: TLS errors before the ready callback are handled in l_tls. + */ + peer_id = eap_get_peer_id(eap); + if (peer_id && eap_tls_session_cache && !eap_method_is_success(eap) && + l_settings_has_group(eap_tls_session_cache, peer_id)) { + eap_tls_forget_peer(peer_id); + + if (eap_tls->tls_session_resumed) + l_warn("EAP: method did not finish after successful TLS" + " session resumption. If this repeats consider" + " disabling [Security].EAP-%sFastReauthentication", + eap_get_method_name(eap)); + } + + eap_tls->tls_session_resumed = false; + eap_tls->tx_frag_offset = 0; eap_tls->tx_frag_last_len = 0; @@ -187,7 +229,7 @@ bool eap_tls_common_state_reset(struct eap_state *eap) { struct eap_tls_state *eap_tls = eap_get_data(eap); - __eap_tls_common_state_reset(eap_tls); + __eap_tls_common_state_reset(eap); if (eap_tls->variant_ops->reset) eap_tls->variant_ops->reset(eap_tls->variant_data); @@ -199,7 +241,7 @@ void eap_tls_common_state_free(struct eap_state *eap) { struct eap_tls_state *eap_tls = eap_get_data(eap); - __eap_tls_common_state_reset(eap_tls); + __eap_tls_common_state_reset(eap); eap_set_data(eap, NULL); @@ -244,7 +286,9 @@ static void eap_tls_tunnel_ready(const char *peer_identity, void *user_data) { struct eap_state *eap = user_data; struct eap_tls_state *eap_tls = eap_get_data(eap); - bool resumed = l_tls_get_session_resumed(eap_tls->tunnel); + + eap_tls->tls_session_resumed = + l_tls_get_session_resumed(eap_tls->tunnel); if (eap_tls->ca_cert && !peer_identity) { l_error("%s: TLS did not verify AP identity", @@ -265,7 +309,8 @@ static void eap_tls_tunnel_ready(const char *peer_identity, void *user_data) if (!eap_tls->variant_ops->tunnel_ready) return; - if (!eap_tls->variant_ops->tunnel_ready(eap, peer_identity, resumed)) + if (!eap_tls->variant_ops->tunnel_ready(eap, peer_identity, + eap_tls->tls_session_resumed)) l_tls_close(eap_tls->tunnel); } @@ -649,7 +694,7 @@ static bool eap_tls_tunnel_init(struct eap_state *eap) if (eap_tls->domain_mask) l_tls_set_domain_mask(eap_tls->tunnel, eap_tls->domain_mask); - if (!eap_tls_session_cache_load) + if (!eap_tls_session_cache_load || eap_tls->tls_cache_disabled) goto start; if (!eap_tls_session_cache) @@ -998,6 +1043,16 @@ int eap_tls_common_settings_check(struct l_settings *settings, return -EINVAL; } + snprintf(setting_key, sizeof(setting_key), + "%sFastReauthentication", prefix); + + if (l_settings_has_key(settings, "Security", setting_key) && + !l_settings_get_bool(settings, "Security", + setting_key, NULL)) { + l_error("Can't parse %s", setting_key); + return -EINVAL; + } + return 0; } @@ -1009,6 +1064,7 @@ bool eap_tls_common_settings_load(struct eap_state *eap, struct eap_tls_state *eap_tls; char setting_key[72]; char *domain_mask_str; + bool bool_val; L_AUTO_FREE_VAR(char *, value) = NULL; @@ -1038,6 +1094,14 @@ bool eap_tls_common_settings_load(struct eap_state *eap, l_free(domain_mask_str); } + snprintf(setting_key, sizeof(setting_key), + "%sFastReauthentication", prefix); + + if (!l_settings_get_bool(settings, "Security", setting_key, &bool_val)) + bool_val = true; + + eap_tls->tls_cache_disabled = !bool_val; + eap_set_data(eap, eap_tls); return true; diff --git a/src/iwd.network.rst b/src/iwd.network.rst @@ -281,6 +281,21 @@ connect to that network. domain name. An asterisk segment in the mask matches any label. An asterisk segment at the beginning of the mask matches one or more consecutive labels from the beginning of the domain string. + * - | EAP-TLS-FastReauthentication, + | EAP-TTLS-FastReauthentication, + | EAP-PEAP-FastReauthentication, + - Values: **true**, false + + Controls whether TLS session caching for EAP-TLS, EAP-TTLS and EAP-PEAP + is used. This allows for faster re-connections to EAP-Enterprise based + networks. + + Some network authenticators may be misconfigured in a way that TLS + session resumption is allowed but actually attempting it will cause + the EAP method to fail or time out. In that case, assuming the + credentials and other settings are correct, every other connection + attempt will fail as sessions are cached and forgotten in alternating + attempts. Use this setting to disable caching for this network. * - | EAP-TTLS-Phase2-Method - | The following values are allowed: | Tunneled-CHAP,