diff --git a/components/mlme/core/inc/wlan_mlme_main.h b/components/mlme/core/inc/wlan_mlme_main.h index dd43b5064f8d..c3817f5c2c8c 100644 --- a/components/mlme/core/inc/wlan_mlme_main.h +++ b/components/mlme/core/inc/wlan_mlme_main.h @@ -61,11 +61,17 @@ struct wlan_disconnect_info { /** * struct peer_mlme_priv_obj - peer MLME component object + * @last_pn_valid if last PN is valid + * @last_pn: last pn received + * @rmf_pn_replays: rmf pn replay count * @is_pmf_enabled: True if PMF is enabled * @last_assoc_received_time: last assoc received time * @last_disassoc_deauth_received_time: last disassoc/deauth received time */ struct peer_mlme_priv_obj { + uint8_t last_pn_valid; + uint64_t last_pn; + uint32_t rmf_pn_replays; bool is_pmf_enabled; qdf_time_t last_assoc_received_time; qdf_time_t last_disassoc_deauth_received_time; diff --git a/core/wma/src/wma_mgmt.c b/core/wma/src/wma_mgmt.c index 31d6a1e3e203..b15732b6331a 100644 --- a/core/wma/src/wma_mgmt.c +++ b/core/wma/src/wma_mgmt.c @@ -3029,61 +3029,56 @@ static uint64_t wma_extract_ccmp_pn(uint8_t *ccmp_ptr) ((uint64_t) pn[2] << 16) | ((uint64_t) pn[1] << 8) | ((uint64_t) pn[0] << 0); - WMA_LOGE("PN of received packet is %llu", new_pn); return new_pn; } /** * wma_is_ccmp_pn_replay_attack() - detect replay attacking using PN in CCMP - * @cds_ctx: cds context + * @wma: wma context * @wh: 802.11 frame header * @ccmp_ptr: CCMP frame header * * Return: true/false */ static bool -wma_is_ccmp_pn_replay_attack(void *cds_ctx, struct ieee80211_frame *wh, - uint8_t *ccmp_ptr) +wma_is_ccmp_pn_replay_attack(tp_wma_handle wma, struct ieee80211_frame *wh, + uint8_t *ccmp_ptr) { - uint8_t vdev_id; - uint8_t *last_pn_valid = NULL; - uint64_t *last_pn = NULL, new_pn; - uint32_t *rmf_pn_replays = NULL; - void *soc = cds_get_context(QDF_MODULE_ID_SOC); + uint64_t new_pn; bool ret = false; - - if (wma_find_vdev_id_by_bssid(cds_ctx, wh->i_addr3, &vdev_id) && - wma_find_vdev_id_by_addr(cds_ctx, wh->i_addr1, &vdev_id)) { - WMA_LOGE("%s: Failed to find vdev", __func__); - return true; - } + struct peer_mlme_priv_obj *peer_priv; + struct wlan_objmgr_peer *peer; new_pn = wma_extract_ccmp_pn(ccmp_ptr); - cdp_get_pn_info(soc, wh->i_addr3, vdev_id, &last_pn_valid, &last_pn, - &rmf_pn_replays); + peer = wlan_objmgr_get_peer_by_mac(wma->psoc, wh->i_addr2, + WLAN_LEGACY_WMA_ID); + if (!peer) + return ret; - if (!last_pn_valid || !last_pn || !rmf_pn_replays) { - WMA_LOGE("%s: PN validation seems not supported", __func__); - goto rel_peer_ref; + peer_priv = wlan_objmgr_peer_get_comp_private_obj(peer, + WLAN_UMAC_COMP_MLME); + if (!peer_priv) { + wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_WMA_ID); + return ret; } - if (*last_pn_valid) { - if (new_pn > *last_pn) { - *last_pn = new_pn; - WMA_LOGE("%s: PN validation successful", __func__); + if (peer_priv->last_pn_valid) { + if (new_pn > peer_priv->last_pn) { + peer_priv->last_pn = new_pn; } else { - WMA_LOGE("%s: PN Replay attack detected", __func__); + wma_err_rl("PN Replay attack detected"); /* per 11W amendment, keeping track of replay attacks */ - *rmf_pn_replays += 1; + peer_priv->rmf_pn_replays += 1; ret = true; } } else { - *last_pn_valid = 1; - *last_pn = new_pn; + peer_priv->last_pn_valid = 1; + peer_priv->last_pn = new_pn; } -rel_peer_ref: + wlan_objmgr_peer_release_ref(peer, WLAN_LEGACY_WMA_ID); + return ret; } @@ -3256,9 +3251,8 @@ int wma_process_rmf_frame(tp_wma_handle wma_handle, orig_hdr = (uint8_t *) qdf_nbuf_data(wbuf); /* Pointer to head of CCMP header */ ccmp = orig_hdr + sizeof(*wh); - if (wma_is_ccmp_pn_replay_attack( - wma_handle, wh, ccmp)) { - WMA_LOGE("Dropping the frame"); + if (wma_is_ccmp_pn_replay_attack(wma_handle, wh, ccmp)) { + wma_err_rl("Dropping the frame"); cds_pkt_return_packet(rx_pkt); return -EINVAL; }