Jelajahi Sumber

qcacld-3.0: Extend KEK and KCK lengths

For GTK offload functionality, currently only 16bytes of
KEK and KCK are being copied from the userspace.

In latest kernel, kek length and kck length are sent to the
host driver as part of set_rekey_data command. Therefore,
use this length to copy the kek, kck params in host driver.

Change-Id: Idef0247aaab22022a84898eca6eb2f010ca1bf1f
CRs-Fixed: 3345506
Surya Prakash Sivaraj 2 tahun lalu
induk
melakukan
e1ce015186

+ 3 - 0
components/pmo/dispatcher/src/wlan_pmo_tgt_gtk.c

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -63,8 +64,10 @@ QDF_STATUS pmo_tgt_send_gtk_offload_req(struct wlan_objmgr_vdev *vdev,
 		qdf_atomic_set(&vdev_ctx->gtk_err_enable, true);
 		qdf_mem_copy(op_gtk_req->kck, gtk_req->kck,
 			     gtk_req->kck_len);
+		op_gtk_req->kck_len = gtk_req->kck_len;
 		qdf_mem_copy(op_gtk_req->kek, gtk_req->kek,
 			     PMO_KEK_LEN);
+		op_gtk_req->kek_len = gtk_req->kek_len;
 		qdf_mem_copy(&op_gtk_req->replay_counter,
 			&gtk_req->replay_counter, PMO_REPLAY_COUNTER_LEN);
 	} else {

+ 55 - 5
core/hdd/src/wlan_hdd_cfg80211.c

@@ -19333,6 +19333,31 @@ void wlan_hdd_set_mlo_wiphy_ext_feature(struct wiphy *wiphy,
 }
 #endif
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
+static inline
+void wlan_hdd_set_ext_kek_kck_support(struct wiphy *wiphy)
+{
+	wiphy->flags |= WIPHY_FLAG_SUPPORTS_EXT_KEK_KCK;
+}
+#else
+static inline
+void wlan_hdd_set_ext_kek_kck_support(struct wiphy *wiphy)
+{
+}
+#endif
+
+#ifdef NL80211_KCK_EXT_LEN_32
+static inline
+void wlan_hdd_set_32bytes_kck_support(struct wiphy *wiphy)
+{
+	wiphy->flags |= WIPHY_FLAG_SUPPORTS_EXT_KCK_32;
+}
+#else
+static inline
+void wlan_hdd_set_32bytes_kck_support(struct wiphy *wiphy)
+{
+}
+#endif
 /*
  * In this function, wiphy structure is updated after QDF
  * initialization. In wlan_hdd_cfg80211_init, only the
@@ -19427,6 +19452,8 @@ void wlan_hdd_update_wiphy(struct hdd_context *hdd_ctx)
 
 	wlan_wifi_pos_cfg80211_set_wiphy_ext_feature(wiphy, hdd_ctx->psoc);
 	wlan_hdd_set_mlo_wiphy_ext_feature(wiphy, hdd_ctx);
+	wlan_hdd_set_ext_kek_kck_support(wiphy);
+	wlan_hdd_set_32bytes_kck_support(wiphy);
 }
 
 /**
@@ -23403,7 +23430,8 @@ out:
  *
  * Return: none
  */
-#ifdef CFG80211_REKEY_DATA_KEK_LEN
+#if (defined(CFG80211_REKEY_DATA_KEK_LEN) || \
+	LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0))
 static
 void wlan_hdd_copy_gtk_kek(struct pmo_gtk_req *gtk_req,
 			   struct cfg80211_gtk_rekey_data *data)
@@ -23421,6 +23449,30 @@ void wlan_hdd_copy_gtk_kek(struct pmo_gtk_req *gtk_req,
 }
 #endif
 
+/**
+ * wlan_hdd_copy_gtk_kck - Copy the KCK from GTK rekey data to GTK request
+ * @gtk_req: Pointer to GTK request
+ * @data: Pointer to rekey data
+ *
+ * Return: None
+ */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
+static
+void wlan_hdd_copy_gtk_kck(struct pmo_gtk_req *gtk_req,
+			   struct cfg80211_gtk_rekey_data *data)
+{
+	qdf_mem_copy(gtk_req->kck, data->kck, data->kck_len);
+	gtk_req->kck_len = data->kck_len;
+}
+#else
+static
+void wlan_hdd_copy_gtk_kck(struct pmo_gtk_req *gtk_req,
+			   struct cfg80211_gtk_rekey_data *data)
+{
+	qdf_mem_copy(gtk_req->kck, data->kck, NL80211_KCK_LEN);
+	gtk_req->kck_len = NL80211_KCK_LEN;
+}
+#endif
 /**
  * __wlan_hdd_cfg80211_set_rekey_data() - set rekey data
  * @wiphy: Pointer to wiphy
@@ -23480,10 +23532,8 @@ int __wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy,
 		gtk_req->replay_counter);
 
 	wlan_hdd_copy_gtk_kek(gtk_req, data);
-	if (data->kck) {
-		qdf_mem_copy(gtk_req->kck, data->kck, NL80211_KCK_LEN);
-		gtk_req->kck_len = NL80211_KCK_LEN;
-	}
+	wlan_hdd_copy_gtk_kck(gtk_req, data);
+
 	gtk_req->is_fils_connection = hdd_is_fils_connection(hdd_ctx, adapter);
 	vdev = hdd_objmgr_get_vdev_by_user(adapter, WLAN_OSIF_POWER_ID);
 	if (!vdev) {