1: ae246d374d93 ! 1: ab0fed3e157f wifi: ath11k: only trust the RX checksum of a frame the hardware checked @@ Commit message parse within the first 256 bytes. An IP fragment carries only part of the datagram its checksum covers.  + The descriptor also describes only the MSDU the hardware received. A + frame that ath11k_dp_rx_h_defrag() reassembles from 802.11 fragments + keeps the descriptor of its first fragment, of which only the MSDU + length is rewritten, so the flags say nothing about the payload of the + later fragments. With raw decap (frame_mode=0 or crypto_mode=1) an + A-MSDU reaches mac80211 as one MPDU; when it spans several RX buffers + and ath11k_dp_rx_msdu_coalesce() moves it into a larger buffer, + ieee80211_amsdu_to_8023s() hands that skb, ip_summed included, to the + last subframe. + The stack then skips the checks it would make: icmp_rcv() takes the checksum as verified, and reassembly keeps CHECKSUM_UNNECESSARY when - every fragment carries it, so a UDP datagram that arrives in fragments - is never checked. By the code this holds for every ath11k chip and frame - mode and - for any frame an associated peer sends. + every fragment carries it, so a UDP datagram that arrives in IP + fragments is never checked. By the code this holds for every ath11k + chip and frame mode and for any frame an associated peer sends.  The MSDU start TLV carries the flags that say what the hardware parsed: TCP, UDP, IP fragment, and whether the fixed IP header and the TCP/UDP header were parsed. Mark a frame CHECKSUM_UNNECESSARY only when it is - TCP or UDP, not a fragment, and both headers were parsed; + TCP or UDP, not a fragment, and both headers were parsed, and never for + a reassembled 802.11 frame or a raw A-MSDU; ath10k_htt_rx_get_csum_state() already leaves a frame that is neither TCP nor UDP to the stack. The flags sit in a different descriptor layout on each chip family, so add a hw_ops accessor for the MSDU start word that holds them.  - Found by reading the code with an AI review tool. + Found by an LLM review (Claude) of the code.  Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Signed-off-by: Julius Bairaktaris   ## drivers/net/wireless/ath/ath11k/dp_rx.c ## -@@ drivers/net/wireless/ath/ath11k/dp_rx.c: static void ath11k_dp_rx_h_csum_offload(struct ath11k *ar, struct sk_buff *msdu) +@@ drivers/net/wireless/ath/ath11k/dp_rx.c: static struct sk_buff *ath11k_dp_rx_get_msdu_last_buf(struct sk_buff_head *msdu_ + return NULL; + } +  ++static bool ath11k_dp_rx_h_is_raw_amsdu(struct ath11k_base *ab, ++ struct sk_buff *msdu) ++{ ++ struct ath11k_skb_rxcb *rxcb = ATH11K_SKB_RXCB(msdu); ++ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data; ++ ++ if (ath11k_dp_rx_h_msdu_start_decap_type(ab, rxcb->rx_desc) != ++ DP_RX_DECAP_TYPE_RAW) ++ return false; ++ ++ /* ++ * Neither an MPDU the hardware delivered as several MSDUs nor a frame ++ * too short to tell is taken as a single MSDU. ++ */ ++ if (!rxcb->is_first_msdu || !rxcb->is_last_msdu) ++ return true; ++ ++ if (msdu->len < sizeof(hdr->frame_control)) ++ return true; ++ ++ if (!ieee80211_is_data_qos(hdr->frame_control)) ++ return false; ++ ++ if (msdu->len < ieee80211_hdrlen(hdr->frame_control)) ++ return true; ++ ++ return *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_A_MSDU_PRESENT; ++} ++ + static void ath11k_dp_rx_h_csum_offload(struct ath11k *ar, struct sk_buff *msdu) + { struct ath11k_skb_rxcb *rxcb = ATH11K_SKB_RXCB(msdu); struct rx_attention *rx_attention; bool ip_csum_fail, l4_csum_fail; @@ drivers/net/wireless/ath/ath11k/dp_rx.c: static void ath11k_dp_rx_h_csum_offload ip_csum_fail = ath11k_dp_rx_h_attn_ip_cksum_fail(rx_attention); l4_csum_fail = ath11k_dp_rx_h_attn_l4_cksum_fail(rx_attention);  + info2 = ar->ab->hw_params.hw_ops->rx_desc_get_msdu_start_info2(rxcb->rx_desc); -  -- msdu->ip_summed = (ip_csum_fail || l4_csum_fail) ? -- CHECKSUM_NONE : CHECKSUM_UNNECESSARY; ++  + msdu->ip_summed = CHECKSUM_NONE;  + ++ /* ++ * The descriptor describes one MSDU as the hardware received it. A ++ * frame reassembled from 802.11 fragments keeps the descriptor of its ++ * first fragment, and mac80211 splits a raw A-MSDU into subframes the ++ * descriptor does not describe one by one. ++ */ ++ if (rxcb->is_frag || ath11k_dp_rx_h_is_raw_amsdu(ar->ab, msdu)) ++ return; ++  + if (ip_csum_fail || l4_csum_fail)  + return;  + @@ drivers/net/wireless/ath/ath11k/dp_rx.c: static void ath11k_dp_rx_h_csum_offload  + !(info2 & RX_MSDU_START_INFO2_IP_FIXED_HDR_VALID) ||  + !(info2 & RX_MSDU_START_INFO2_IP_TCP_UDP_HDR_VALID))  + return; -+ +  +- msdu->ip_summed = (ip_csum_fail || l4_csum_fail) ? +- CHECKSUM_NONE : CHECKSUM_UNNECESSARY;  + msdu->ip_summed = CHECKSUM_UNNECESSARY; }  2: 5c9bb3e55d02 ! 2: 4f41e41e0793 wifi: ath12k: only trust the RX checksum of a frame the hardware checked @@ Commit message checksum it never computed: any protocol other than TCP and UDP, such as ICMP, ICMPv6 or GRE, a TCP or UDP frame whose headers it did not parse, and an IP fragment, which carries only part of the datagram its - checksum covers. icmp_rcv() then takes the checksum as verified, and a - UDP datagram whose fragments all carry CHECKSUM_UNNECESSARY keeps it - after reassembly. + checksum covers. A frame that ath12k_wifi7_dp_rx_h_defrag() reassembles + from 802.11 fragments keeps the descriptor of its first fragment, of + which only the MSDU length is rewritten, so its flags say nothing about + the payload of the later fragments. icmp_rcv() then takes the checksum + as verified, and a UDP datagram whose IP fragments all carry + CHECKSUM_UNNECESSARY keeps it after reassembly.  ath11k has the same check. Extract the protocol, fragment and header-parsed flags of the MSDU end TLV with the other descriptor - fields on each chip, and mark a frame CHECKSUM_UNNECESSARY only when it - is TCP or UDP, not a fragment, and its IP and TCP/UDP headers were - parsed. + fields on each chip, from the last buffer of the MSDU like the other + MSDU end fields, and mark a frame CHECKSUM_UNNECESSARY only when it is + TCP or UDP, not a fragment, its IP and TCP/UDP headers were parsed, and + it was not reassembled from 802.11 fragments. Unlike ath11k, ath12k + needs no case for a raw A-MSDU: nothing in the driver sets + ATH12K_FLAG_RAW_MODE.  - Found by reading the code with an AI review tool. + Found by an LLM review (Claude) of the code.  Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Signed-off-by: Julius Bairaktaris  @@ drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c: int ath12k_wifi7_dp_rx_tid_delete  + /*  + * The failure bits only report a checksum the hardware computed, so  + * they are also clear for a frame it did not check: anything but a -+ * TCP or UDP frame whose headers it parsed, and an IP fragment. ++ * TCP or UDP frame whose headers it parsed, and an IP fragment. A ++ * frame reassembled from 802.11 fragments keeps the descriptor of its ++ * first fragment, which does not describe the later ones.  + */ -+ msdu->ip_summed = (rx_info->ip_csum_fail || rx_info->l4_csum_fail || ++ msdu->ip_summed = (ATH12K_SKB_RXCB(msdu)->is_frag || ++ rx_info->ip_csum_fail || rx_info->l4_csum_fail ||  + !rx_info->l4_csum_checked) ? CHECKSUM_NONE : CHECKSUM_UNNECESSARY; } @@ drivers/net/wireless/ath/ath12k/wifi7/hal_qcc2072.c: static bool ath12k_hal_rx_h return !!le32_get_bits(desc->u.qcc2072.msdu_end.info13,  @@ drivers/net/wireless/ath/ath12k/wifi7/hal_qcc2072.c: static void ath12k_hal_extract_rx_desc_data_qcc2072(struct hal_rx_desc_data *rx_ rx_desc_data->msdu_done = ath12k_hal_rx_h_msdu_done_qcc2072(ldesc); - rx_desc_data->l4_csum_fail = ath12k_hal_rx_h_l4_cksum_fail_qcc2072(rx_desc); - rx_desc_data->ip_csum_fail = ath12k_hal_rx_h_ip_cksum_fail_qcc2072(rx_desc); -+ rx_desc_data->l4_csum_checked = ath12k_hal_rx_h_l4_csum_checked_qcc2072(rx_desc); - rx_desc_data->is_decrypted = ath12k_hal_rx_h_is_decrypted_qcc2072(rx_desc); - rx_desc_data->err_bitmap = ath12k_hal_rx_h_mpdu_err_qcc2072(rx_desc); + rx_desc_data->l4_csum_fail = ath12k_hal_rx_h_l4_cksum_fail_qcc2072(ldesc); + rx_desc_data->ip_csum_fail = ath12k_hal_rx_h_ip_cksum_fail_qcc2072(ldesc); ++ rx_desc_data->l4_csum_checked = ath12k_hal_rx_h_l4_csum_checked_qcc2072(ldesc); + rx_desc_data->is_decrypted = ath12k_hal_rx_h_is_decrypted_qcc2072(ldesc); + rx_desc_data->err_bitmap = ath12k_hal_rx_h_mpdu_err_qcc2072(ldesc); }  ## drivers/net/wireless/ath/ath12k/wifi7/hal_qcn9274.c ## @@ drivers/net/wireless/ath/ath12k/wifi7/hal_qcn9274.c: bool ath12k_hal_rx_h_l4_cks {  @@ drivers/net/wireless/ath/ath12k/wifi7/hal_qcn9274.c: void ath12k_hal_extract_rx_desc_data_qcn9274(struct hal_rx_desc_data *rx_desc_da rx_desc_data->msdu_done = ath12k_hal_rx_h_msdu_done_qcn9274(ldesc); - rx_desc_data->l4_csum_fail = ath12k_hal_rx_h_l4_cksum_fail_qcn9274(rx_desc); - rx_desc_data->ip_csum_fail = ath12k_hal_rx_h_ip_cksum_fail_qcn9274(rx_desc); -+ rx_desc_data->l4_csum_checked = ath12k_hal_rx_h_l4_csum_checked_qcn9274(rx_desc); - rx_desc_data->is_decrypted = ath12k_hal_rx_h_is_decrypted_qcn9274(rx_desc); - rx_desc_data->err_bitmap = ath12k_hal_rx_h_mpdu_err_qcn9274(rx_desc); + rx_desc_data->l4_csum_fail = ath12k_hal_rx_h_l4_cksum_fail_qcn9274(ldesc); + rx_desc_data->ip_csum_fail = ath12k_hal_rx_h_ip_cksum_fail_qcn9274(ldesc); ++ rx_desc_data->l4_csum_checked = ath12k_hal_rx_h_l4_csum_checked_qcn9274(ldesc); + rx_desc_data->is_decrypted = ath12k_hal_rx_h_is_decrypted_qcn9274(ldesc); + rx_desc_data->err_bitmap = ath12k_hal_rx_h_mpdu_err_qcn9274(ldesc); }  ## drivers/net/wireless/ath/ath12k/wifi7/hal_wcn7850.c ## @@ drivers/net/wireless/ath/ath12k/wifi7/hal_wcn7850.c: bool ath12k_hal_rx_h_l4_cks {  @@ drivers/net/wireless/ath/ath12k/wifi7/hal_wcn7850.c: void ath12k_hal_extract_rx_desc_data_wcn7850(struct hal_rx_desc_data *rx_desc_da rx_desc_data->msdu_done = ath12k_hal_rx_h_msdu_done_wcn7850(ldesc); - rx_desc_data->l4_csum_fail = ath12k_hal_rx_h_l4_cksum_fail_wcn7850(rx_desc); - rx_desc_data->ip_csum_fail = ath12k_hal_rx_h_ip_cksum_fail_wcn7850(rx_desc); -+ rx_desc_data->l4_csum_checked = ath12k_hal_rx_h_l4_csum_checked_wcn7850(rx_desc); - rx_desc_data->is_decrypted = ath12k_hal_rx_h_is_decrypted_wcn7850(rx_desc); - rx_desc_data->err_bitmap = ath12k_hal_rx_h_mpdu_err_wcn7850(rx_desc); + rx_desc_data->l4_csum_fail = ath12k_hal_rx_h_l4_cksum_fail_wcn7850(ldesc); + rx_desc_data->ip_csum_fail = ath12k_hal_rx_h_ip_cksum_fail_wcn7850(ldesc); ++ rx_desc_data->l4_csum_checked = ath12k_hal_rx_h_l4_csum_checked_wcn7850(ldesc); + rx_desc_data->is_decrypted = ath12k_hal_rx_h_is_decrypted_wcn7850(ldesc); + rx_desc_data->err_bitmap = ath12k_hal_rx_h_mpdu_err_wcn7850(ldesc); } 3: 8fd33c75e0ba ! 3: 1474f3b7d5da wifi: ath11k: drop decapped frames with a source other than the station @@ Commit message already hands such 4-address frames to mac80211 as 802.11 frames (ath12k_dp_rx_h_undecap()), and mac80211 drops them on an AP interface.  - Found by reading the code with an AI review tool; the trigger above was + Found by an LLM review (Claude) of the code; the trigger above was then reproduced on hardware.  Fixes: 2167fa606c0f ("ath11k: Add support for RX decapsulation offload") 4: fabfe1203768 ! 4: b2c82a7aa872 wifi: ath11k: clear the crypto flags of the receive status for each MSDU @@ Commit message  Clear the three flags with the other per-MPDU flags.  - Found by reading the code with an AI review tool. + Found by an LLM review (Claude) of the code.  Fixes: 2167fa606c0f ("ath11k: Add support for RX decapsulation offload") Signed-off-by: Julius Bairaktaris  5: d075a8cfddc7 ! 5: 68f383fcc5fd wifi: ath12k: clear the crypto flags of the receive status for each MSDU @@ Commit message  Clear the three flags with the other per-MPDU flags.  - Found by reading the code with an AI review tool. + Found by an LLM review (Claude) of the code.  Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices") Signed-off-by: Julius Bairaktaris  6: ddd0bd753c6b ! 6: 96f41ca7afb7 wifi: ath12k: clear RX_FLAG_8023 of the receive status for each MSDU @@ Commit message Clear RX_FLAG_8023 with the other per-MPDU flags in ath12k_wifi7_dp_rx_h_mpdu(), before ath12k_dp_rx_h_undecap() sets it.  - Found by reading the code with an AI review tool. + Found by an LLM review (Claude) of the code.  Fixes: c4aa897fe234 ("wifi: ath12k: Handle DP_RX_DECAP_TYPE_8023 type in Rx path") Signed-off-by: Julius Bairaktaris