mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Filip Balluch <fballuch@redhat.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	jtornosm@redhat.com, Filip Balluch <fballuch@redhat.com>
Subject: [PATCH] mac80211: fix missing crypto tailroom in fast-xmit
Date: Tue, 24 Nov 2026 10:20:47 +0100	[thread overview]
Message-ID: <20261124092047.452491-1-fballuch@redhat.com> (raw)

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.

Fixes: 17c18bf880b2 ("mac80211: add TX fastpath")

Signed-off-by: Filip Balluch <fballuch@redhat.com>
---
 net/mac80211/tx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 91b14112e24f..760da3114956 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -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);
-- 
2.56.0


                 reply	other threads:[~2026-11-24  9:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124092047.452491-1-fballuch@redhat.com \
    --to=fballuch@redhat.com \
    --cc=johannes@sipsolutions.net \
    --cc=jtornosm@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®