From 058e19a3f5025501454a0237ff926b67cbcbef68 Mon Sep 17 00:00:00 2001 From: Jane Rachinger Date: Wed, 16 Apr 2025 14:21:09 +0200 Subject: [PATCH] hack: wifi: Disable WPA-PSK-SHA256 for brcmfmac in AP mode This does the equivalent of purism's patch on librem 5 on pmOS, but doesn't affect other drivers. https://source.puri.sm/pureos/packages/network-manager/-/blob/pureos/latest/debian/patches/pureos/wifi-Disable-WPA-PSK-SHA256-in-AP-mode.patch --- src/core/devices/wifi/nm-device-wifi.c | 3 +++ src/core/supplicant/nm-supplicant-config.c | 18 +++++++++++++++++- src/core/supplicant/nm-supplicant-config.h | 1 + .../supplicant/tests/test-supplicant-config.c | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/core/devices/wifi/nm-device-wifi.c b/src/core/devices/wifi/nm-device-wifi.c index 2536622f1c..ca2f099e2a 100644 --- a/src/core/devices/wifi/nm-device-wifi.c +++ b/src/core/devices/wifi/nm-device-wifi.c @@ -2929,12 +2929,14 @@ build_supplicant_config(NMDeviceWifi *self, NMSettingWirelessSecurityPmf pmf; NMSettingWirelessSecurityFils fils; NMTernary ap_isolation; + gboolean quirk_is_brcmfmac; g_return_val_if_fail(priv->sup_iface, NULL); s_wireless = nm_connection_get_setting_wireless(connection); g_return_val_if_fail(s_wireless != NULL, NULL); + quirk_is_brcmfmac = nm_streq(nm_device_get_driver(NM_DEVICE(self)), "brcmfmac"); config = nm_supplicant_config_new(nm_supplicant_interface_get_capabilities(priv->sup_iface), nm_utils_get_connection_first_permissions_user(connection)); @@ -3013,6 +3015,7 @@ build_supplicant_config(NMDeviceWifi *self, pmf, fils, nm_device_get_private_files(NM_DEVICE(self)), + quirk_is_brcmfmac, error)) { g_prefix_error(error, "802-11-wireless-security: "); goto error; diff --git a/src/core/supplicant/nm-supplicant-config.c b/src/core/supplicant/nm-supplicant-config.c index 56cc832b57..5d89e1e478 100644 --- a/src/core/supplicant/nm-supplicant-config.c +++ b/src/core/supplicant/nm-supplicant-config.c @@ -934,6 +934,7 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig NMSettingWirelessSecurityPmf pmf, NMSettingWirelessSecurityFils fils, GHashTable *files, + gboolean quirk_is_brcmfmac, GError **error) { NMSupplicantConfigPrivate *priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE(self); @@ -942,6 +943,7 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig const char *psk; gboolean set_pmf, wps_disabled; gboolean is_ap; + gboolean quirk_no_ap_wpa_psk_sha256; g_return_val_if_fail(NM_IS_SUPPLICANT_CONFIG(self), FALSE); g_return_val_if_fail(setting != NULL, FALSE); @@ -955,6 +957,20 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig */ is_ap = nm_streq0(mode, NM_SETTING_WIRELESS_MODE_AP); + /* Some Librem 5 have a sparklan wifi card, which cannot use + * WPA-PSK-SHA256 in AP mode. This quirk shouldn't be in this + * highlevel program but rather in the kernel, but this was + * faster and unbreaks AP for the Librem 5 without affecting + * other drivers. I sadly wasn't able to find a matching + * bugzilla entry in the kernel. Without more details I'm scoping + * this quirk to the whole brcmfmac driver as the commit messages + * in PureOS indicate this. + * + * https://puri.sm/posts/shipping-new-sparklan-wifi-cards-with-librem-5/ + * https://source.puri.sm/pureos/packages/network-manager/-/merge_requests/1 + */ + quirk_no_ap_wpa_psk_sha256 = is_ap && quirk_is_brcmfmac; + /* Check if we actually support FILS */ if (!_get_capability(priv, NM_SUPPL_CAP_TYPE_FILS)) { if (fils == NM_SETTING_WIRELESS_SECURITY_FILS_REQUIRED) { @@ -984,7 +1000,7 @@ nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig } else if (nm_streq(key_mgmt, "wpa-psk")) { if (pmf != NM_SETTING_WIRELESS_SECURITY_PMF_REQUIRED) g_string_append(key_mgmt_conf, "WPA-PSK"); - if (_get_capability(priv, NM_SUPPL_CAP_TYPE_PMF)) + if (!quirk_no_ap_wpa_psk_sha256 && _get_capability(priv, NM_SUPPL_CAP_TYPE_PMF)) g_string_append(key_mgmt_conf, " WPA-PSK-SHA256"); if (!is_ap && _get_capability(priv, NM_SUPPL_CAP_TYPE_FT)) g_string_append(key_mgmt_conf, " FT-PSK"); diff --git a/src/core/supplicant/nm-supplicant-config.h b/src/core/supplicant/nm-supplicant-config.h index 96460b86c7..2cb393bed3 100644 --- a/src/core/supplicant/nm-supplicant-config.h +++ b/src/core/supplicant/nm-supplicant-config.h @@ -58,6 +58,7 @@ gboolean nm_supplicant_config_add_setting_wireless_security(NMSupplicantConfig NMSettingWirelessSecurityPmf pmf, NMSettingWirelessSecurityFils fils, GHashTable *files, + gboolean quirk_is_brcmfmac, GError **error); gboolean nm_supplicant_config_add_no_security(NMSupplicantConfig *self, GError **error); diff --git a/src/core/supplicant/tests/test-supplicant-config.c b/src/core/supplicant/tests/test-supplicant-config.c index 416fe0054f..d934ba1b58 100644 --- a/src/core/supplicant/tests/test-supplicant-config.c +++ b/src/core/supplicant/tests/test-supplicant-config.c @@ -122,6 +122,7 @@ build_supplicant_config(NMConnection *connection, pmf, fils, NULL, + FALSE, &error); } else { success = nm_supplicant_config_add_no_security(config, &error); -- 2.53.0