[PATCH ath-next] wifi: ath12k: drop decapped frames with a source other than the station

Julius Bairaktaris posted 1 patch 13 hours ago
drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
[PATCH ath-next] wifi: ath12k: drop decapped frames with a source other than the station
Posted by Julius Bairaktaris 13 hours ago
With Ethernet decap, ath12k hands mac80211 an MSDU with the Ethernet
source the hardware took from the frame, which for an A-MSDU subframe
is whatever its subframe header carries, and mac80211's 802.3 receive
path takes it as the station's address. When mac80211 deaggregates an
A-MSDU itself, ieee80211_amsdu_to_8023s() drops a subframe whose source
is not the station on an access point; the decap path has no such
check.

Drop such an MSDU on an AP for a station that does not use four
addresses, as ath11k does. The address compared with is that of the
ieee80211_sta, which for a multi-link station is its MLD address, the
one mac80211 compares with too. A four-address MPDU from such a station
passes: ath12k_dp_rx_h_undecap() hands it to mac80211 as an 802.11
frame, from which mac80211 reports the station for dynamic WDS.

Found by reading the code.

Fixes: d889913205cf ("wifi: ath12k: driver for Qualcomm Wi-Fi 7 devices")
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
Applies on top of "wifi: ath11k, ath12k: RX correctness fixes",
which changes the same function:
https://lore.kernel.org/all/20261122210525.2076058-1-julius@bairaktaris.de/

I used Claude (Anthropic) to help write these patches.

 drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c b/drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c
index 1d52eab418a1..abc3b6d197f1 100644
--- a/drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c
+++ b/drivers/net/wireless/ath/ath12k/wifi7/dp_rx.c
@@ -354,6 +354,40 @@ static void ath12k_wifi7_dp_rx_h_csum_offload(struct sk_buff *msdu,
 			   CHECKSUM_NONE : CHECKSUM_UNNECESSARY;
 }
 
+/*
+ * With Ethernet decap the hardware passes on the source address of the frame,
+ * which the header of an A-MSDU subframe sets, and mac80211's 802.3 path takes
+ * it as the address of the station. An access point takes no other source from
+ * a station that does not use four addresses: mac80211 drops such a subframe
+ * in ieee80211_amsdu_to_8023s() when it deaggregates the A-MSDU itself. The
+ * address it compares with is the station's, its MLD address for a multi-link
+ * station. A four-address frame from such a station is left alone:
+ * ath12k_dp_rx_h_undecap() hands it to mac80211 as an 802.11 frame, from which
+ * mac80211 reports the station for dynamic WDS.
+ */
+static bool ath12k_wifi7_dp_rx_h_eth_sa_valid(struct ath12k_dp_peer *peer,
+					      struct hal_rx_desc_data *rx_info,
+					      struct sk_buff *msdu)
+{
+	struct ath12k_sta *ahsta;
+	struct ethhdr *eth;
+
+	if (rx_info->decap_type != DP_RX_DECAP_TYPE_ETHERNET2_DIX ||
+	    !peer->sta || peer->use_4addr ||
+	    (rx_info->is_from_ds && rx_info->is_to_ds))
+		return true;
+
+	ahsta = ath12k_sta_to_ahsta(peer->sta);
+	if (ahsta->ahvif->vdev_type != WMI_VDEV_TYPE_AP)
+		return true;
+
+	if (msdu->len < ETH_HLEN)
+		return false;
+
+	eth = (struct ethhdr *)msdu->data;
+	return ether_addr_equal(eth->h_source, peer->sta->addr);
+}
+
 static int ath12k_wifi7_dp_rx_h_mpdu(struct ath12k_pdev_dp *dp_pdev,
 				     struct sk_buff *msdu,
 				     struct hal_rx_desc_data *rx_info)
@@ -390,6 +424,9 @@ static int ath12k_wifi7_dp_rx_h_mpdu(struct ath12k_pdev_dp *dp_pdev,
 				return -EINVAL;
 		}
 
+		if (!ath12k_wifi7_dp_rx_h_eth_sa_valid(peer, rx_info, msdu))
+			return -EINVAL;
+
 		/* resetting mcbc bit because mcbc packets are unicast
 		 * packets only for AP as STA sends unicast packets.
 		 */

base-commit: 1983b40acfcb3c3464b291c85977290a785bcfdc
prerequisite-patch-id: ed566369a9bbda0ac9a48357261e8cfe1cc0f1d1
prerequisite-patch-id: 726d7737c833da0842192eccececad4a0dedb1a6
prerequisite-patch-id: cf0b8ff1ac6cef681433247e4b937a3e23af78a3
prerequisite-patch-id: 03c89df01745ac9a80653431261f9a003dbca7db
prerequisite-patch-id: cb48c0eddbe0c2fe176e8edc94c6bc40be3c48a9
prerequisite-patch-id: 1956ec85ad80b68868538070fc0e89c29603467a
-- 
2.53.0