Skip to content

Commit 35f432a

Browse files
committed
mac80211: initialize fast-xmit 'info' later
In ieee80211_xmit_fast(), 'info' is initialized to point to the skb that's passed in, but that skb may later be replaced by a clone (if it was shared), leading to an invalid pointer. This can lead to use-after-free and also later crashes since the real SKB's info->hw_queue doesn't get initialized properly. Fix this by assigning info only later, when it's needed, after the skb replacement (may have) happened. Cc: stable@vger.kernel.org Reported-by: Ben Greear <greearb@candelatech.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent eb7903b commit 35f432a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/mac80211/tx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3287,7 +3287,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
32873287
int extra_head = fast_tx->hdr_len - (ETH_HLEN - 2);
32883288
int hw_headroom = sdata->local->hw.extra_tx_headroom;
32893289
struct ethhdr eth;
3290-
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
3290+
struct ieee80211_tx_info *info;
32913291
struct ieee80211_hdr *hdr = (void *)fast_tx->hdr;
32923292
struct ieee80211_tx_data tx;
32933293
ieee80211_tx_result r;
@@ -3351,6 +3351,7 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
33513351
memcpy(skb->data + fast_tx->da_offs, eth.h_dest, ETH_ALEN);
33523352
memcpy(skb->data + fast_tx->sa_offs, eth.h_source, ETH_ALEN);
33533353

3354+
info = IEEE80211_SKB_CB(skb);
33543355
memset(info, 0, sizeof(*info));
33553356
info->band = fast_tx->band;
33563357
info->control.vif = &sdata->vif;

0 commit comments

Comments
 (0)