hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/net/wireless/sme.c
....@@ -5,7 +5,7 @@
55 * (for nl80211's connect() and wext)
66 *
77 * Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
8
- * Copyright (C) 2009 Intel Corporation. All rights reserved.
8
+ * Copyright (C) 2009, 2020 Intel Corporation. All rights reserved.
99 * Copyright 2017 Intel Deutschland GmbH
1010 */
1111
....@@ -24,7 +24,7 @@
2424
2525 /*
2626 * Software SME in cfg80211, using auth/assoc/deauth calls to the
27
- * driver. This is is for implementing nl80211's connect/disconnect
27
+ * driver. This is for implementing nl80211's connect/disconnect
2828 * and wireless extensions (if configured.)
2929 */
3030
....@@ -205,7 +205,7 @@
205205 return err;
206206 case CFG80211_CONN_ASSOC_FAILED_TIMEOUT:
207207 *treason = NL80211_TIMEOUT_ASSOC;
208
- /* fall through */
208
+ fallthrough;
209209 case CFG80211_CONN_ASSOC_FAILED:
210210 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
211211 NULL, 0,
....@@ -215,7 +215,7 @@
215215 cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid,
216216 NULL, 0,
217217 WLAN_REASON_DEAUTH_LEAVING, false);
218
- /* fall through */
218
+ fallthrough;
219219 case CFG80211_CONN_ABANDON:
220220 /* free directly, disconnected event already sent */
221221 cfg80211_sme_free(wdev);
....@@ -694,6 +694,7 @@
694694 return;
695695 }
696696
697
+ wdev->unprot_beacon_reported = 0;
697698 nl80211_send_connect_result(wiphy_to_rdev(wdev->wiphy), dev, cr,
698699 GFP_KERNEL);
699700
....@@ -741,7 +742,7 @@
741742 }
742743
743744 if (cr->status != WLAN_STATUS_SUCCESS) {
744
- kzfree(wdev->connect_keys);
745
+ kfree_sensitive(wdev->connect_keys);
745746 wdev->connect_keys = NULL;
746747 wdev->ssid_len = 0;
747748 wdev->conn_owner_nlportid = 0;
....@@ -796,12 +797,36 @@
796797 u8 *next;
797798
798799 if (params->bss) {
799
- /* Make sure the bss entry provided by the driver is valid. */
800800 struct cfg80211_internal_bss *ibss = bss_from_pub(params->bss);
801801
802
- if (WARN_ON(list_empty(&ibss->list))) {
803
- cfg80211_put_bss(wdev->wiphy, params->bss);
804
- return;
802
+ if (list_empty(&ibss->list)) {
803
+ struct cfg80211_bss *found = NULL, *tmp = params->bss;
804
+
805
+ found = cfg80211_get_bss(wdev->wiphy, NULL,
806
+ params->bss->bssid,
807
+ wdev->ssid, wdev->ssid_len,
808
+ wdev->conn_bss_type,
809
+ IEEE80211_PRIVACY_ANY);
810
+ if (found) {
811
+ /* The same BSS is already updated so use it
812
+ * instead, as it has latest info.
813
+ */
814
+ params->bss = found;
815
+ } else {
816
+ /* Update with BSS provided by driver, it will
817
+ * be freshly added and ref cnted, we can free
818
+ * the old one.
819
+ *
820
+ * signal_valid can be false, as we are not
821
+ * expecting the BSS to be found.
822
+ *
823
+ * keep the old timestamp to avoid confusion
824
+ */
825
+ cfg80211_bss_update(rdev, ibss, false,
826
+ ibss->ts);
827
+ }
828
+
829
+ cfg80211_put_bss(wdev->wiphy, tmp);
805830 }
806831 }
807832
....@@ -897,6 +922,7 @@
897922 cfg80211_hold_bss(bss_from_pub(info->bss));
898923 wdev->current_bss = bss_from_pub(info->bss);
899924
925
+ wdev->unprot_beacon_reported = 0;
900926 nl80211_send_roamed(wiphy_to_rdev(wdev->wiphy),
901927 wdev->netdev, info, GFP_KERNEL);
902928
....@@ -1072,7 +1098,7 @@
10721098 wdev->current_bss = NULL;
10731099 wdev->ssid_len = 0;
10741100 wdev->conn_owner_nlportid = 0;
1075
- kzfree(wdev->connect_keys);
1101
+ kfree_sensitive(wdev->connect_keys);
10761102 wdev->connect_keys = NULL;
10771103
10781104 nl80211_send_disconnected(rdev, dev, reason, ie, ie_len, from_ap);
....@@ -1092,7 +1118,10 @@
10921118
10931119 if (wiphy_ext_feature_isset(
10941120 wdev->wiphy,
1095
- NL80211_EXT_FEATURE_BEACON_PROTECTION))
1121
+ NL80211_EXT_FEATURE_BEACON_PROTECTION) ||
1122
+ wiphy_ext_feature_isset(
1123
+ wdev->wiphy,
1124
+ NL80211_EXT_FEATURE_BEACON_PROTECTION_CLIENT))
10961125 max_key_idx = 7;
10971126 for (i = 0; i <= max_key_idx; i++)
10981127 rdev_del_key(rdev, dev, i, false, NULL);
....@@ -1182,6 +1211,8 @@
11821211
11831212 cfg80211_oper_and_ht_capa(&connect->ht_capa_mask,
11841213 rdev->wiphy.ht_capa_mod_mask);
1214
+ cfg80211_oper_and_vht_capa(&connect->vht_capa_mask,
1215
+ rdev->wiphy.vht_capa_mod_mask);
11851216
11861217 if (connkeys && connkeys->def >= 0) {
11871218 int idx;
....@@ -1250,7 +1281,7 @@
12501281
12511282 ASSERT_WDEV_LOCK(wdev);
12521283
1253
- kzfree(wdev->connect_keys);
1284
+ kfree_sensitive(wdev->connect_keys);
12541285 wdev->connect_keys = NULL;
12551286
12561287 wdev->conn_owner_nlportid = 0;