mac80211: fix missing crypto tailroom in fast-xmit
PATCH 1/1 mac80211: fix missing crypto tailroom in fast-xmit
A key uploaded to hardware with the IEEE80211_KEY_FLAG_RESERVE_TAILROOM flag set tells mac80211 that the driver will handle the encryption itself but needs MIC tailroom reserved in the skb. The regular TX path honors this through crypto_tx_tailroom_needed_cnt in ieee80211_skb_resize(), but the fast-xmit path always passes ENCRYPT_NO and never reserves tailroom for such keys.
mac80211_hwsim claims CCMP/GCMP keys as hardware keys while encrypting in software at TX time, so with full-MSS TCP segments the CCMP code finds an skb without the required tailroom.
dmesg logs:
WARNING: CPU: 0 PID: 0 at net/mac80211/wpa.c:462 ccmp_encrypt_skb.isra.0+0x73/0x1f0 [mac80211] RIP: 0010:ccmp_encrypt_skb.isra.0+0x73/0x1f0 [mac80211] Call Trace: <IRQ> ieee80211_crypto_ccmp_encrypt+0x3c/0x60 [mac80211] ieee80211_encrypt_tx_skb+0x91/0x110 [mac80211] mac80211_hwsim_tx+0x1cc/0x7f0 [mac80211_hwsim] ieee80211_handle_wake_tx_queue+0x74/0xc0 [mac80211] ieee80211_queue_skb+0x204/0x430 [mac80211] __ieee80211_xmit_fast+0x206/0x3b0 [mac80211]
and the frame is dropped. The same combination of fast-xmit and a RESERVE_TAILROOM key is reachable on ath11k and ath12k in raw mode, where the firmware expects the reserved MIC space to be present.
Pass ENCRYPT_DATA instead so that tailroom is reserved whenever a driver requested it. For drivers without any RESERVE_TAILROOM keys the counter is zero and the resize behaves exactly as before.
--- net/mac80211/tx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/mac80211/tx.c +4 -4
@@ -3753,14 +3753,14 @@ void __ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata, ieee80211_amsdu_aggregate(sdata, sta, fast_tx, skb, da, sa)) return; -/* will not be crypto-handled beyond what we do here, so use false -* as the may-encrypt argument for the resize to not account for -* more room than we already have in 'extra_head' +/* the key may require tailroom to be reserved, e.g. when the +* driver encrypts in software (IEEE80211_KEY_FLAG_RESERVE_TAILROOM), +* so ask for encryption tailroom even though we don't encrypt here */ if (unlikely (ieee80211_skb_resize (sdata, skb,max_t (int, extra_head + hw_headroom -skb_headroom (skb),0 ), -ENCRYPT_NO ))) +ENCRYPT_DATA ))) goto free; hdr =skb_push (skb, extra_head);
Signature · 1 line
2.56.0