Skip to contentSkip to conversation

mac80211: Fix ieee80211_amsdu_aggregate frag_tail bug

PATCH Superseded Ping-Ke Shih 1 participant 2 messages Aug 30, 2021 mac80211

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mac80211: Fix ieee80211_amsdu_aggregate frag_tail bug

From: Chih-Kang Chang <[email protected]>

In ieee80211_amsdu_aggregate() set a pointer frag_tail point to the end of skb_shinfo(head)->frag_list, and use it to bind other skb in the end of this function. But when execute ieee80211_amsdu_aggregate() ->ieee80211_amsdu_realloc_pad()->pskb_expand_head(), the address of skb_shinfo(head)->frag_list will be changed. However, the ieee80211_amsdu_aggregate() not update frag_tail after call pskb_expand_head(). That will cause the second skb can't bind to the head skb appropriately.So we update the address of frag_tail to fix it.

Fixes 6e0456b54545 ("mac80211: add A-MSDU tx support")

---
v2: an alternative fix to prevent iterating fragment twice.

---
 net/mac80211/tx.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/mac80211/tx.c +7 -0
index 2d1193ed3eb5..fb5e43489b62 100644
@@ -3380,6 +3380,13 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata,
 	if (!ieee80211_amsdu_prepare_head(sdata, fast_tx, head))
 		goto out;
 
+       /* While n == 2, frag_tail should be the address of head's frag_list.
+	* However, head probably re-alloc after ieee80211_amsdu_prepare_head.
+	* So, re-assign frag_tail again to make sure the correctness.
+	*/
+	if (n == 2)
+		frag_tail = &skb_shinfo(head)->frag_list;
+
 	/*
 	 * Pad out the previous subframe to a multiple of 4 by adding the
 	 * padding to the next one, that's being added. Note that head->len
Signature · 1 line
2.25.1
author
#1 lore raw
Quoted 34 lines

-----Original Message-----
From: Ping-Ke Shih [mailto:[email protected]]
Sent: Monday, August 30, 2021 2:17 PM
To: [email protected]
Cc: [email protected]; [email protected]; Gary Chang; Kevin Yang
Subject: [PATCH v2] mac80211: Fix ieee80211_amsdu_aggregate frag_tail bug

From: Chih-Kang Chang <[email protected]>

In ieee80211_amsdu_aggregate() set a pointer frag_tail point to the end of skb_shinfo(head)->frag_list, and use it to bind other skb in the end of this function. But when execute ieee80211_amsdu_aggregate() ->ieee80211_amsdu_realloc_pad()->pskb_expand_head(), the address of skb_shinfo(head)->frag_list will be changed. However, the ieee80211_amsdu_aggregate() not update frag_tail after call pskb_expand_head(). That will cause the second skb can't bind to the head skb appropriately.So we update the address of frag_tail to fix it.

Fixes 6e0456b54545 ("mac80211: add A-MSDU tx support")

---
v2: an alternative fix to prevent iterating fragment twice.

---
 net/mac80211/tx.c | 7 +++++++
 1 file changed, 7 insertions(+)
net/mac80211/tx.c +0 -0
index 2d1193ed3eb5..fb5e43489b62 100644

net/mac80211/tx.c static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata, · line 3389

Quoted 10 lines
net/mac80211/tx.c +7 -0
@@ -3380,6 +3380,13 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata,
 	if (!ieee80211_amsdu_prepare_head(sdata, fast_tx, head))
 		goto out;
 
+       /* While n == 2, frag_tail should be the address of head's frag_list.
+	* However, head probably re-alloc after ieee80211_amsdu_prepare_head.
+	* So, re-assign frag_tail again to make sure the correctness.
+	*/
+	if (n == 2)
+		frag_tail = &skb_shinfo(head)->frag_list;
+

I mess up the coding style and fix it by v3 [1]. Please ignore this patch.

[1] https://lore.kernel.org/linux-wireless/[email protected]/T/#u

--
Ping-Ke