ath11k: Don't cast ath11k_skb_cb to ieee80211_tx_info.control
PATCH 1/2 ath11k: Don't cast ath11k_skb_cb to ieee80211_tx_info.control
The driver_data area of ieee80211_tx_info is used in ath11k for ath11k_skb_cb. The first function in the TX patch which rewrites it to ath11k_skb_cb is already ath11k_mac_op_tx. No one else in the code path must use it for something else before it reinitializes it. Otherwise the data has to be considered uninitialized or corrupt.
But the ieee80211_tx_info.control shares exactly the same area as ieee80211_tx_info.driver_data and ath11k is still using it. This results in best case in a
ath11k c000000.wifi1: no vif found for mgmt frame, flags 0x0
or (slightly worse) in a kernel oops.
Instead, the interesting data must be moved first into the ath11k_skb_cb and ieee80211_tx_info.control must then not be used anymore.
Tested-on: IPQ8074 hw2.0 WLAN.HK.2.4.0.1.r1-00026-QCAHKSWPL_SILICONZ-2
--- drivers/net/wireless/ath/ath11k/mac.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath11k/mac.c +11 -9
@@ -3977,21 +3977,20 @@ static void ath11k_mgmt_over_wmi_tx_purge(struct ath11k *ar)static void ath11k_mgmt_over_wmi_tx_work (struct work_struct *work) { struct ath11k *ar = container_of(work, struct ath11k, wmi_mgmt_tx_work); -struct ieee80211_tx_info *info; +struct ath11k_skb_cb *skb_cb;struct ath11k_vif *arvif;struct sk_buff *skb;int ret;while ((skb =skb_dequeue (&ar->wmi_mgmt_tx_queue)) !=NULL ) { - info =IEEE80211_SKB_CB (skb); -if (!info->control.vif) { -ath11k_warn (ar->ab,"no vif found for mgmt frame, flags 0x%x\n" , - info->control.flags); + skb_cb =ATH11K_SKB_CB (skb); +if (!skb_cb->vif) { +ath11k_warn (ar->ab,"no vif found for mgmt frame\n" );ieee80211_free_txskb (ar->hw, skb);continue ; } - arvif =ath11k_vif_to_arvif (info->control.vif); + arvif =ath11k_vif_to_arvif (skb_cb->vif);if (ar->allocated_vdev_map & (1LL << arvif->vdev_id) && arvif->is_started) { ret =ath11k_mac_mgmt_tx_wmi (ar, arvif, skb);
@@ -4004,8 +4003,8 @@ static void ath11k_mgmt_over_wmi_tx_work(struct work_struct *work) } }else {ath11k_warn (ar->ab, -"dropping mgmt frame for vdev %d, flags 0x%x is_started %d\n" , - arvif->vdev_id, info->control.flags, +"dropping mgmt frame for vdev %d, is_started %d\n" , + arvif->vdev_id, arvif->is_started);ieee80211_free_txskb (ar->hw, skb); }
@@ -4053,10 +4052,13 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw,struct ieee80211_vif *vif = info->control.vif;struct ath11k_vif *arvif =ath11k_vif_to_arvif (vif);struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; +u32 info_flags = info->flags;bool is_prb_rsp;int ret; -if (info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) { + skb_cb->vif = vif; + +if (info_flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) { skb_cb->flags |=ATH11K_SKB_HW_80211_ENCAP ; }else if (ieee80211_is_mgmt (hdr->frame_control)) { is_prb_rsp =ieee80211_is_probe_resp (hdr->frame_control);
Signature · 1 line
2.29.2
PATCH 2/2 ath11k: Reset ath11k_skb_cb before setting new flags
It was observed that the codepath for the ATH11K_SKB_HW_80211_ENCAP was used even when the IEEE80211_TX_CTRL_HW_80211_ENCAP was not enabled for a an skbuff. This became even more prominent when the QCAs wlan-open patchset for ath11k [1] was applied and a sane looking fix just caused crashes when injecting frames via a monitor interface (for example with ratechecker):
[ 86.963152] Unable to handle kernel NULL pointer dereference at virtual address 00000338 [ 86.963192] pgd = ffffffc0008f0000 [ 86.971034] [00000338] *pgd=0000000051706003, *pud=0000000051706003, *pmd=0000000051707003, *pte=00e800000b000707 [ 86.984292] Internal error: Oops: 96000006 [#1] PREEMPT SMP [...] [ 87.713339] [<ffffffbffc802480>] ieee80211_tx_status_8023+0xf8/0x220 [mac80211] [ 87.715654] [<ffffffbffc98bad4>] ath11k_dp_tx_completion_handler+0x42c/0xa10 [ath11k] [ 87.722924] [<ffffffbffc989190>] ath11k_dp_service_srng+0x70/0x3c8 [ath11k] [ 87.730831] [<ffffffbffca03460>] 0xffffffbffca03460 [ 87.737599] [<ffffffc00046ef58>] net_rx_action+0xf8/0x288 [ 87.742462] [<ffffffc000097554>] __do_softirq+0xfc/0x220 [ 87.748014] [<ffffffc000097900>] irq_exit+0x98/0xe8 [ 87.753396] [<ffffffc0000cf188>] __handle_domain_irq+0x90/0xb8 [ 87.757999] [<ffffffc000081ca4>] gic_handle_irq+0x6c/0xc8 [ 87.763899] Exception stack(0xffffffc00081bdc0 to 0xffffffc00081bef0)
Problem is that the state of ath11k_skb_cb->flags must be considered unknown and could contain anything when it is not manually initialized. So it could also contain ATH11K_SKB_HW_80211_ENCAP. And this can result in the code to assume that the ath11k_skb_cb->vif is set - even when this is not always the case for non ATH11K_SKB_HW_80211_ENCAP transmissions.
Tested-on: IPQ8074 hw2.0 WLAN.HK.2.4.0.1.r1-00026-QCAHKSWPL_SILICONZ-2
[1] https://source.codeaurora.org/quic/qsdk/oss/system/feeds/wlan-open/tree/mac80211/patches?h=NHSS.QSDK.11.4.r3
(162 patches at the moment which are often not upstreamed but essential
to get ath11k working)
--- drivers/net/wireless/ath/ath11k/mac.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath11k/mac.c +1 -0
@@ -4056,6 +4056,7 @@ static void ath11k_mac_op_tx(struct ieee80211_hw *hw,bool is_prb_rsp;int ret; +memset (skb_cb,0 ,sizeof (*skb_cb)); skb_cb->vif = vif;if (info_flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) {
Signature · 7 lines
2.29.2 -- ath11k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath11k