qcacmn: Implement crypto locking mechanism
Implement a locking mechanism for retrieving and storing crypto keys. Currently, due to race condition, Host driver is fetching information in one thread while simultaneously writing key information in another thread, resulting in synchronization issues. This change is to add lock mechanism while reading and writing crypto keys. Change-Id: I156b619cf7c3c052ad3122a6f808d732fb5e4f51 CRs-Fixed: 3669552
此提交包含在:
@@ -148,12 +148,15 @@ int wlan_cfg80211_store_link_key(struct wlan_objmgr_psoc *psoc,
|
||||
* key may already exist at times and may be retrieved only to
|
||||
* update it.
|
||||
*/
|
||||
wlan_crypto_aquire_lock();
|
||||
crypto_key = wlan_crypto_get_ml_sta_link_key(psoc, key_index,
|
||||
link_addr, link_id);
|
||||
if (!crypto_key) {
|
||||
wlan_crypto_release_lock();
|
||||
crypto_key = qdf_mem_malloc(sizeof(*crypto_key));
|
||||
if (!crypto_key)
|
||||
return -EINVAL;
|
||||
wlan_crypto_aquire_lock();
|
||||
}
|
||||
|
||||
wlan_cfg80211_translate_ml_sta_key(key_index, key_type, mac_addr,
|
||||
@@ -162,10 +165,12 @@ int wlan_cfg80211_store_link_key(struct wlan_objmgr_psoc *psoc,
|
||||
status = wlan_crypto_save_ml_sta_key(psoc, key_index, crypto_key,
|
||||
link_addr, link_id);
|
||||
if (QDF_IS_STATUS_ERROR(status)) {
|
||||
wlan_crypto_release_lock();
|
||||
osif_err("Failed to save key");
|
||||
qdf_mem_free(crypto_key);
|
||||
return -EINVAL;
|
||||
}
|
||||
wlan_crypto_release_lock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -213,11 +218,14 @@ int wlan_cfg80211_store_key(struct wlan_objmgr_vdev *vdev,
|
||||
* key may already exist at times and may be retrieved only to
|
||||
* update it.
|
||||
*/
|
||||
wlan_crypto_aquire_lock();
|
||||
crypto_key = wlan_crypto_get_key(vdev, key_index);
|
||||
if (!crypto_key) {
|
||||
wlan_crypto_release_lock();
|
||||
crypto_key = qdf_mem_malloc(sizeof(*crypto_key));
|
||||
if (!crypto_key)
|
||||
return -EINVAL;
|
||||
wlan_crypto_aquire_lock();
|
||||
}
|
||||
|
||||
wlan_cfg80211_translate_key(vdev, key_index, key_type, mac_addr,
|
||||
@@ -225,10 +233,12 @@ int wlan_cfg80211_store_key(struct wlan_objmgr_vdev *vdev,
|
||||
|
||||
status = wlan_crypto_save_key(vdev, key_index, crypto_key);
|
||||
if (QDF_IS_STATUS_ERROR(status)) {
|
||||
wlan_crypto_release_lock();
|
||||
osif_err("Failed to save key");
|
||||
qdf_mem_free(crypto_key);
|
||||
return -EINVAL;
|
||||
}
|
||||
wlan_crypto_release_lock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -268,11 +278,14 @@ int wlan_cfg80211_crypto_add_key(struct wlan_objmgr_vdev *vdev,
|
||||
.timeout_ms = WLAN_WAIT_TIME_ADD_KEY,
|
||||
};
|
||||
|
||||
wlan_crypto_aquire_lock();
|
||||
crypto_key = wlan_crypto_get_key(vdev, key_index);
|
||||
if (!crypto_key) {
|
||||
wlan_crypto_release_lock();
|
||||
osif_err("Crypto KEY is NULL");
|
||||
return -EINVAL;
|
||||
}
|
||||
wlan_crypto_release_lock();
|
||||
|
||||
if (sync) {
|
||||
priv = wlan_get_vdev_crypto_obj(vdev);
|
||||
@@ -309,7 +322,6 @@ int wlan_cfg80211_crypto_add_key(struct wlan_objmgr_vdev *vdev,
|
||||
} else {
|
||||
status = ucfg_crypto_set_key_req(vdev, crypto_key, key_type);
|
||||
}
|
||||
|
||||
return qdf_status_to_os_return(status);
|
||||
}
|
||||
|
||||
|
新增問題並參考
封鎖使用者