Skip to contentSkip to conversation

network: add 6GHz restrictions to network_can_connect_bss

PATCH Superseded James Prestwood 2 participants 4 messages Feb 25, 2022

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

James Prestwood

author
#0 lore raw

PATCH v2 1/3 network: add 6GHz restrictions to network_can_connect_bss

The 802.11ax standards adds some restrictions for the 6GHz band. In short stations must use SAE, OWE, or 8021x on this band and frame protection is required.

---
 src/network.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

v2:
* Removed mfpr setting since this is enforced in station.c

src/network.c +34 -0
index 4e7af27c..0aa2d3af 100644
@@ -55,6 +55,7 @@
 #include "src/util.h"
 #include "src/erp.h"
 #include "src/handshake.h"
+#include "src/band.h"
 
 #define SAE_PT_SETTING "SAE-PT-Group%u"
 
@@ -774,6 +775,7 @@ int network_can_connect_bss(struct network *network, const struct scan_bss *bss)
 	struct network_config *config = info ? &info->config : NULL;
 	bool can_transition_disable = wiphy_can_transition_disable(wiphy);
 	struct ie_rsn_info rsn;
+	enum band_freq band;
 	int ret;
 
 	switch (security) {
@@ -785,6 +787,9 @@ int network_can_connect_bss(struct network *network, const struct scan_bss *bss)
 		return -ENOSYS;
 	}
 
+	if (!band_freq_to_channel(bss->frequency, &band))
+		return -ENOTSUP;
+
 	memset(&rsn, 0, sizeof(rsn));
 	ret = scan_bss_get_rsn_info(bss, &rsn);
 	if (ret < 0) {
@@ -797,6 +802,13 @@ int network_can_connect_bss(struct network *network, const struct scan_bss *bss)
 		 * We assume the spec means us to check bit 3 here
 		 */
 		if (ret == -ENOENT && security == SECURITY_NONE) {
+			/*
+			 * 802.11ax 12.12.2 - STA shall not use Open System
+			 * authentication without encryption
+			 */
+			if (band == BAND_FREQ_6_GHZ)
+				return -EPERM;
+
 			if (!config)
 				return 0;
 
@@ -852,6 +864,28 @@ int network_can_connect_bss(struct network *network, const struct scan_bss *bss)
 	}
 
 no_transition_disable:
+	/* 802.11ax Section 12.12.2 */
+	if (band == BAND_FREQ_6_GHZ) {
+		/* STA shall not use the following cipher suite selectors */
+		rsn.pairwise_ciphers &= ~IE_RSN_CIPHER_SUITE_USE_GROUP_CIPHER;
+		rsn.pairwise_ciphers &= ~IE_RSN_CIPHER_SUITE_TKIP;
+
+		/* STA shall not use the following AKM suite selectors */
+		rsn.akm_suites &= ~IE_RSN_AKM_SUITE_PSK;
+		rsn.akm_suites &= ~IE_RSN_AKM_SUITE_PSK_SHA256;
+		rsn.akm_suites &= ~IE_RSN_AKM_SUITE_FT_USING_PSK;
+
+		/* Basically the STA must use OWE, SAE, or 8021x */
+		if (!(rsn.akm_suites & (IE_RSN_AKM_SUITE_8021X |
+					IE_RSN_AKM_SUITE_FT_OVER_8021X |
+					IE_RSN_AKM_SUITE_8021X_SHA256 |
+					IE_RSN_AKM_SUITE_SAE_SHA256 |
+					IE_RSN_AKM_SUITE_FT_OVER_SAE_SHA256 |
+					IE_RSN_AKM_SUITE_FT_OVER_8021X_SHA384 |
+					IE_RSN_AKM_SUITE_OWE)))
+			return -EPERM;
+	}
+
 	if (!wiphy_select_cipher(wiphy, rsn.pairwise_ciphers))
 		return -ENOTSUP;
 
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v2 2/3 station: check supported frequencies in neighbor report

If the report has an unsupported frequency don't add it to the list.

---
 src/station.c | 6 ++++++
 1 file changed, 6 insertions(+)
src/station.c +6 -0
index cd119ff1..dd924c00 100644
@@ -1715,6 +1715,8 @@ static void parse_neighbor_report(struct station *station,
 	struct scan_freq_set *freq_set_md, *freq_set_no_md;
 	uint32_t current_freq = 0;
 	struct handshake_state *hs = netdev_get_handshake(station->netdev);
+	const struct scan_freq_set *supported =
+				wiphy_get_supported_freqs(station->wiphy);
 
 	freq_set_md = scan_freq_set_new();
 	freq_set_no_md = scan_freq_set_new();
@@ -1751,6 +1753,10 @@ static void parse_neighbor_report(struct station *station,
 		if (!(band & wiphy_get_supported_bands(station->wiphy)))
 			continue;
 
+		/* Skip if frequency is not supported */
+		if (!scan_freq_set_contains(supported, freq))
+			continue;
+
 		if (!memcmp(info.addr,
 				station->connected_bss->addr, ETH_ALEN)) {
 			/*
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v2 2/3] station: check supported frequencies in neighbor report

Hi James,

Quoted 5 lines · James Prestwood

If the report has an unsupported frequency don't add it to the list.

---
  src/station.c | 6 ++++++
  1 file changed, 6 insertions(+)

Patch 2 & 3 applied, thanks.

Regards,
-Denis

author
#3 lore raw

PATCH v2 3/3 station: enforce MFPR=1 for 6GHz frequencies

In reply to James Prestwood

This adds checks if MFP is set to 0 or 1:

0 - Always fail if the frequency is 6GHz
1 - Fail if MFPC=0 and the frequency is 6GHz.
If HW is capable set MFPR=1 for 6GHz

---
 src/station.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)
src/station.c +24 -1
index dd924c00..a0e95cb7 100644
@@ -1012,9 +1012,13 @@ static int station_build_handshake_rsn(struct handshake_state *hs,
 	struct ie_rsn_info info;
 	uint8_t *ap_ie;
 	bool disable_ocv;
+	enum band_freq band;
 
 	memset(&info, 0, sizeof(info));
 
+	if (!band_freq_to_channel(bss->frequency, &band))
+		goto not_supported;
+
 	memset(&bss_info, 0, sizeof(bss_info));
 	scan_bss_get_rsn_info(bss, &bss_info);
 
@@ -1061,12 +1065,31 @@ static int station_build_handshake_rsn(struct handshake_state *hs,
 
 	switch (mfp_setting) {
 	case 0:
-		break;
+		if (band != BAND_FREQ_6_GHZ)
+			break;
+
+		l_error("MFP turned off by [General].ManagementFrameProtection,"
+				" 6GHz frequencies are disabled");
+		goto not_supported;
 	case 1:
 		info.group_management_cipher =
 			wiphy_select_cipher(wiphy,
 				bss_info.group_management_cipher);
 		info.mfpc = info.group_management_cipher != 0;
+
+		if (band != BAND_FREQ_6_GHZ)
+			break;
+
+		if (!info.mfpc)
+			goto not_supported;
+
+		/*
+		 * 802.11ax Section 12.12.2
+		 * The STA shall use management frame protection
+		 * (MFPR=1) when using RSN.
+		 */
+		info.mfpr = true;
+
 		break;
 	case 2:
 		info.group_management_cipher =
Signature · 1 line
2.34.1