mac80211: Fix ieee80211_amsdu_aggregate frag_tail bug
PATCH 1/2 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.
--- net/mac80211/tx.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/mac80211/tx.c +6 -0
@@ -3406,6 +3406,12 @@ static bool ieee80211_amsdu_aggregate(struct ieee80211_sub_if_data *sdata, head->len += skb->len; head->data_len += skb->len; + +/* frag_list should be updated after pskb_expand_head() */ + frag_tail = &skb_shinfo (head)->frag_list; +while (*frag_tail) + frag_tail = &(*frag_tail)->next; + *frag_tail = skb; out_recalc:
Signature · 1 line
2.25.1
PATCH 2/2 mac80211: Fix insufficient headroom issue for AMSDU
From: Chih-Kang Chang <[email protected]>
ieee80211_amsdu_realloc_pad() lacks some check for extra_tx_headroom, the original reserved headroom might be eaten. So we add the extra_tx_headroom check.
--- net/mac80211/tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/tx.c +2 -1
@@ -3242,7 +3242,8 @@ static bool ieee80211_amsdu_prepare_head(struct ieee80211_sub_if_data *sdata,if (info->control.flags &IEEE80211_TX_CTRL_AMSDU )return true; -if (!ieee80211_amsdu_realloc_pad (local, skb,sizeof (*amsdu_hdr))) +if (!ieee80211_amsdu_realloc_pad (local, skb,sizeof (*amsdu_hdr) + + local->hw.extra_tx_headroom))return false; data =skb_push (skb,sizeof (*amsdu_hdr));
Signature · 1 line
2.25.1
Quoted 10 lines · Ping-Ke Shih
From: Chih-Kang Chang <[email protected]>
In
ieee80211_amsdu_aggregate()set a pointerfrag_tailpoint to the end of skb_shinfo(head)->frag_list, and use it to bind other skb in the end of this function. But when executeieee80211_amsdu_aggregate()->ieee80211_amsdu_realloc_pad()->pskb_expand_head(), the address of skb_shinfo(head)->frag_list will be changed. However, theieee80211_amsdu_aggregate()not updatefrag_tailafter callpskb_expand_head(). That will cause the second skb can't bind to the head skb appropriately.So we update the address offrag_tailto fix it.
I think instead of iterating over fragments a second time, we should move the ieee80211_amsdu_prepare_head call further up.
- Felix
Quoted 19 lines
-----Original Message-----
From: Felix Fietkau [mailto:[email protected]]
Sent: Monday, August 16, 2021 8:23 PM
To: Pkshih; [email protected]
Cc: [email protected]; Gary Chang
Subject: Re: [PATCH 1/2] mac80211: Fixieee80211_amsdu_aggregatefrag_tailbugQuoted 10 lines · Ping-Ke Shih
From: Chih-Kang Chang <[email protected]>
In
ieee80211_amsdu_aggregate()set a pointerfrag_tailpoint to the end of skb_shinfo(head)->frag_list, and use it to bind other skb in the end of this function. But when executeieee80211_amsdu_aggregate()->ieee80211_amsdu_realloc_pad()->pskb_expand_head(), the address of skb_shinfo(head)->frag_list will be changed. However, theieee80211_amsdu_aggregate()not updatefrag_tailafter callpskb_expand_head(). That will cause the second skb can't bind to the head skb appropriately.So we update the address offrag_tailto fix it.
Quoted 3 lines
I think instead of iterating over fragments a second time, we should move the
ieee80211_amsdu_prepare_headcall further up.
The first iteration is used to calculate 'n' and 'nfrags' to decide if we need to do AMSDU as well as ieee80211_amsdu_prepare_head(), so we don't have a good idea to move the function upward. However, we have an alternative idea [1] to fix frag_tail.
[1] https://lore.kernel.org/linux-wireless/[email protected]/T/#u
--
Ping-Ke