Skip to content

Commit 14c5e93

Browse files
author
CKI Backport Bot
committed
wifi: ath12k: Fix invalid data access in ath12k_dp_rx_h_undecap_nwifi
JIRA: https://issues.redhat.com/browse/RHEL-93256 CVE: CVE-2025-37943 commit 9a0dddf Author: Manish Dharanenthiran <quic_mdharane@quicinc.com> Date: Tue Feb 11 14:33:02 2025 +0530 wifi: ath12k: Fix invalid data access in ath12k_dp_rx_h_undecap_nwifi In certain cases, hardware might provide packets with a length greater than the maximum native Wi-Fi header length. This can lead to accessing and modifying fields in the header within the ath12k_dp_rx_h_undecap_nwifi function for DP_RX_DECAP_TYPE_NATIVE_WIFI decap type and potentially resulting in invalid data access and memory corruption. Add a sanity check before processing the SKB to prevent invalid data access in the undecap native Wi-Fi function for the DP_RX_DECAP_TYPE_NATIVE_WIFI decap type. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.3.1-00173-QCAHKSWPL_SILICONZ-1 Signed-off-by: Manish Dharanenthiran <quic_mdharane@quicinc.com> Signed-off-by: Tamizh Chelvam Raja <tamizh.raja@oss.qualcomm.com> Link: https://patch.msgid.link/20250211090302.4105141-1-tamizh.raja@oss.qualcomm.com Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com> Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
1 parent 06792db commit 14c5e93

File tree

1 file changed

+40
-2
lines changed
  • drivers/net/wireless/ath/ath12k

1 file changed

+40
-2
lines changed

drivers/net/wireless/ath/ath12k/dp_rx.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,6 +2470,29 @@ static void ath12k_dp_rx_deliver_msdu(struct ath12k *ar, struct napi_struct *nap
24702470
ieee80211_rx_napi(ath12k_ar_to_hw(ar), pubsta, msdu, napi);
24712471
}
24722472

2473+
static bool ath12k_dp_rx_check_nwifi_hdr_len_valid(struct ath12k_base *ab,
2474+
struct hal_rx_desc *rx_desc,
2475+
struct sk_buff *msdu)
2476+
{
2477+
struct ieee80211_hdr *hdr;
2478+
u8 decap_type;
2479+
u32 hdr_len;
2480+
2481+
decap_type = ath12k_dp_rx_h_decap_type(ab, rx_desc);
2482+
if (decap_type != DP_RX_DECAP_TYPE_NATIVE_WIFI)
2483+
return true;
2484+
2485+
hdr = (struct ieee80211_hdr *)msdu->data;
2486+
hdr_len = ieee80211_hdrlen(hdr->frame_control);
2487+
2488+
if ((likely(hdr_len <= DP_MAX_NWIFI_HDR_LEN)))
2489+
return true;
2490+
2491+
ab->soc_stats.invalid_rbm++;
2492+
WARN_ON_ONCE(1);
2493+
return false;
2494+
}
2495+
24732496
static int ath12k_dp_rx_process_msdu(struct ath12k *ar,
24742497
struct sk_buff *msdu,
24752498
struct sk_buff_head *msdu_list,
@@ -2528,6 +2551,11 @@ static int ath12k_dp_rx_process_msdu(struct ath12k *ar,
25282551
}
25292552
}
25302553

2554+
if (unlikely(!ath12k_dp_rx_check_nwifi_hdr_len_valid(ab, rx_desc, msdu))) {
2555+
ret = -EINVAL;
2556+
goto free_out;
2557+
}
2558+
25312559
ath12k_dp_rx_h_ppdu(ar, rx_desc, rx_status);
25322560
ath12k_dp_rx_h_mpdu(ar, msdu, rx_desc, rx_status);
25332561

@@ -2880,6 +2908,9 @@ static int ath12k_dp_rx_h_verify_tkip_mic(struct ath12k *ar, struct ath12k_peer
28802908
RX_FLAG_IV_STRIPPED | RX_FLAG_DECRYPTED;
28812909
skb_pull(msdu, hal_rx_desc_sz);
28822910

2911+
if (unlikely(!ath12k_dp_rx_check_nwifi_hdr_len_valid(ab, rx_desc, msdu)))
2912+
return -EINVAL;
2913+
28832914
ath12k_dp_rx_h_ppdu(ar, rx_desc, rxs);
28842915
ath12k_dp_rx_h_undecap(ar, msdu, rx_desc,
28852916
HAL_ENCRYPT_TYPE_TKIP_MIC, rxs, true);
@@ -3600,6 +3631,9 @@ static int ath12k_dp_rx_h_null_q_desc(struct ath12k *ar, struct sk_buff *msdu,
36003631
skb_put(msdu, hal_rx_desc_sz + l3pad_bytes + msdu_len);
36013632
skb_pull(msdu, hal_rx_desc_sz + l3pad_bytes);
36023633
}
3634+
if (unlikely(!ath12k_dp_rx_check_nwifi_hdr_len_valid(ab, desc, msdu)))
3635+
return -EINVAL;
3636+
36033637
ath12k_dp_rx_h_ppdu(ar, desc, status);
36043638

36053639
ath12k_dp_rx_h_mpdu(ar, msdu, desc, status);
@@ -3644,7 +3678,7 @@ static bool ath12k_dp_rx_h_reo_err(struct ath12k *ar, struct sk_buff *msdu,
36443678
return drop;
36453679
}
36463680

3647-
static void ath12k_dp_rx_h_tkip_mic_err(struct ath12k *ar, struct sk_buff *msdu,
3681+
static bool ath12k_dp_rx_h_tkip_mic_err(struct ath12k *ar, struct sk_buff *msdu,
36483682
struct ieee80211_rx_status *status)
36493683
{
36503684
struct ath12k_base *ab = ar->ab;
@@ -3662,13 +3696,17 @@ static void ath12k_dp_rx_h_tkip_mic_err(struct ath12k *ar, struct sk_buff *msdu,
36623696
skb_put(msdu, hal_rx_desc_sz + l3pad_bytes + msdu_len);
36633697
skb_pull(msdu, hal_rx_desc_sz + l3pad_bytes);
36643698

3699+
if (unlikely(!ath12k_dp_rx_check_nwifi_hdr_len_valid(ab, desc, msdu)))
3700+
return true;
3701+
36653702
ath12k_dp_rx_h_ppdu(ar, desc, status);
36663703

36673704
status->flag |= (RX_FLAG_MMIC_STRIPPED | RX_FLAG_MMIC_ERROR |
36683705
RX_FLAG_DECRYPTED);
36693706

36703707
ath12k_dp_rx_h_undecap(ar, msdu, desc,
36713708
HAL_ENCRYPT_TYPE_TKIP_MIC, status, false);
3709+
return false;
36723710
}
36733711

36743712
static bool ath12k_dp_rx_h_rxdma_err(struct ath12k *ar, struct sk_buff *msdu,
@@ -3687,7 +3725,7 @@ static bool ath12k_dp_rx_h_rxdma_err(struct ath12k *ar, struct sk_buff *msdu,
36873725
case HAL_REO_ENTR_RING_RXDMA_ECODE_TKIP_MIC_ERR:
36883726
err_bitmap = ath12k_dp_rx_h_mpdu_err(ab, rx_desc);
36893727
if (err_bitmap & HAL_RX_MPDU_ERR_TKIP_MIC) {
3690-
ath12k_dp_rx_h_tkip_mic_err(ar, msdu, status);
3728+
drop = ath12k_dp_rx_h_tkip_mic_err(ar, msdu, status);
36913729
break;
36923730
}
36933731
fallthrough;

0 commit comments

Comments
 (0)