5
5
* Copyright 2006-2007 Jiri Benc <[email protected] >
6
6
* Copyright 2013-2014 Intel Mobile Communications GmbH
7
7
* Copyright (C) 2017 Intel Deutschland GmbH
8
- * Copyright (C) 2018-2024 Intel Corporation
8
+ * Copyright (C) 2018-2025 Intel Corporation
9
9
*/
10
10
11
11
#include <net/mac80211.h>
@@ -1025,12 +1025,9 @@ EXPORT_SYMBOL(ieee80211_alloc_hw_nm);
1025
1025
1026
1026
static int ieee80211_init_cipher_suites (struct ieee80211_local * local )
1027
1027
{
1028
- bool have_wep = !fips_enabled ; /* FIPS does not permit the use of RC4 */
1029
1028
bool have_mfp = ieee80211_hw_check (& local -> hw , MFP_CAPABLE );
1030
- int r = 0 , w = 0 ;
1031
- u32 * suites ;
1032
1029
static const u32 cipher_suites [] = {
1033
- /* keep WEP first, it may be removed below */
1030
+ /* keep WEP and TKIP first, they may be removed below */
1034
1031
WLAN_CIPHER_SUITE_WEP40 ,
1035
1032
WLAN_CIPHER_SUITE_WEP104 ,
1036
1033
WLAN_CIPHER_SUITE_TKIP ,
@@ -1046,34 +1043,17 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local)
1046
1043
WLAN_CIPHER_SUITE_BIP_GMAC_256 ,
1047
1044
};
1048
1045
1049
- if (ieee80211_hw_check (& local -> hw , SW_CRYPTO_CONTROL ) ||
1050
- local -> hw .wiphy -> cipher_suites ) {
1051
- /* If the driver advertises, or doesn't support SW crypto,
1052
- * we only need to remove WEP if necessary.
1053
- */
1054
- if (have_wep )
1055
- return 0 ;
1056
-
1057
- /* well if it has _no_ ciphers ... fine */
1058
- if (!local -> hw .wiphy -> n_cipher_suites )
1059
- return 0 ;
1060
-
1061
- /* Driver provides cipher suites, but we need to exclude WEP */
1062
- suites = kmemdup_array (local -> hw .wiphy -> cipher_suites ,
1063
- local -> hw .wiphy -> n_cipher_suites ,
1064
- sizeof (u32 ), GFP_KERNEL );
1065
- if (!suites )
1066
- return - ENOMEM ;
1067
-
1068
- for (r = 0 ; r < local -> hw .wiphy -> n_cipher_suites ; r ++ ) {
1069
- u32 suite = local -> hw .wiphy -> cipher_suites [r ];
1070
-
1071
- if (suite == WLAN_CIPHER_SUITE_WEP40 ||
1072
- suite == WLAN_CIPHER_SUITE_WEP104 )
1073
- continue ;
1074
- suites [w ++ ] = suite ;
1075
- }
1076
- } else {
1046
+ if (ieee80211_hw_check (& local -> hw , SW_CRYPTO_CONTROL ) && fips_enabled ) {
1047
+ dev_err (local -> hw .wiphy -> dev .parent ,
1048
+ "Drivers with SW_CRYPTO_CONTROL cannot work with FIPS\n" );
1049
+ return - EINVAL ;
1050
+ }
1051
+
1052
+ if (WARN_ON (ieee80211_hw_check (& local -> hw , SW_CRYPTO_CONTROL ) &&
1053
+ !local -> hw .wiphy -> cipher_suites ))
1054
+ return - EINVAL ;
1055
+
1056
+ if (fips_enabled || !local -> hw .wiphy -> cipher_suites ) {
1077
1057
/* assign the (software supported and perhaps offloaded)
1078
1058
* cipher suites
1079
1059
*/
@@ -1083,19 +1063,13 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local)
1083
1063
if (!have_mfp )
1084
1064
local -> hw .wiphy -> n_cipher_suites -= 4 ;
1085
1065
1086
- if (!have_wep ) {
1087
- local -> hw .wiphy -> cipher_suites += 2 ;
1088
- local -> hw .wiphy -> n_cipher_suites -= 2 ;
1066
+ /* FIPS does not permit the use of RC4 */
1067
+ if (fips_enabled ) {
1068
+ local -> hw .wiphy -> cipher_suites += 3 ;
1069
+ local -> hw .wiphy -> n_cipher_suites -= 3 ;
1089
1070
}
1090
-
1091
- /* not dynamically allocated, so just return */
1092
- return 0 ;
1093
1071
}
1094
1072
1095
- local -> hw .wiphy -> cipher_suites = suites ;
1096
- local -> hw .wiphy -> n_cipher_suites = w ;
1097
- local -> wiphy_ciphers_allocated = true;
1098
-
1099
1073
return 0 ;
1100
1074
}
1101
1075
@@ -1651,10 +1625,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
1651
1625
ieee80211_led_exit (local );
1652
1626
destroy_workqueue (local -> workqueue );
1653
1627
fail_workqueue :
1654
- if (local -> wiphy_ciphers_allocated ) {
1655
- kfree (local -> hw .wiphy -> cipher_suites );
1656
- local -> wiphy_ciphers_allocated = false;
1657
- }
1658
1628
kfree (local -> int_scan_req );
1659
1629
return result ;
1660
1630
}
@@ -1725,11 +1695,6 @@ void ieee80211_free_hw(struct ieee80211_hw *hw)
1725
1695
1726
1696
mutex_destroy (& local -> iflist_mtx );
1727
1697
1728
- if (local -> wiphy_ciphers_allocated ) {
1729
- kfree (local -> hw .wiphy -> cipher_suites );
1730
- local -> wiphy_ciphers_allocated = false;
1731
- }
1732
-
1733
1698
idr_for_each (& local -> ack_status_frames ,
1734
1699
ieee80211_free_ack_frame , NULL );
1735
1700
idr_destroy (& local -> ack_status_frames );
0 commit comments