* [PATCH wireless-next 0/4] wifi: mac80211: encap offload fixes
@ 2026-08-02 8:57 Johannes Berg
2026-08-02 8:57 ` [PATCH wireless-next 1/4] wifi: mac80211: fix unauthorised port check for encap offload Johannes Berg
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Johannes Berg @ 2026-08-02 8:57 UTC (permalink / raw)
To: linux-wireless
Targeting wireless-next mostly because apparently nobody cares and
it's really late in the cycle (and there's some risk involved).
johannes
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH wireless-next 1/4] wifi: mac80211: fix unauthorised port check for encap offload
2026-08-02 8:57 [PATCH wireless-next 0/4] wifi: mac80211: encap offload fixes Johannes Berg
@ 2026-08-02 8:57 ` Johannes Berg
2026-08-02 8:57 ` [PATCH wireless-next 2/4] wifi: mac80211: fix key selection for encap offload frames Johannes Berg
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2026-08-02 8:57 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
The check in ieee80211_tx_dequeue() reads frame_control, addr1 and
addr2 out of the skb, but for encapsulation offload that's just a
random part of the ethernet addresses, so dropping depends on bits
in the destination address. This is obviously wrong.
Refactor the check and short-circuit for ethernet format frames,
it only needs the port-control flag check since those are locally
generated and not forwarded frames.
Fixes: 50ff477a8639 ("mac80211: add 802.11 encapsulation offloading support")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/tx.c | 48 +++++++++++++++++++++++++++++++++--------------
1 file changed, 34 insertions(+), 14 deletions(-)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 0cf5f6ec75e6..44c40c98b497 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -3882,6 +3882,38 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,
return true;
}
+static bool ieee80211_drop_unauth_port(struct ieee80211_tx_data *tx)
+{
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
+ struct ieee80211_hdr *hdr;
+
+ if (likely(test_sta_flag(tx->sta, WLAN_STA_AUTHORIZED)))
+ return false;
+
+ if (info->flags & IEEE80211_TX_CTL_INJECTED)
+ return false;
+
+ if (ieee80211_vif_is_mesh(&tx->sdata->vif) ||
+ tx->sdata->vif.type == NL80211_IFTYPE_OCB)
+ return false;
+
+ /* no need to check forwarding here */
+ if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP)
+ return !(info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO);
+
+ hdr = (struct ieee80211_hdr *)tx->skb->data;
+
+ if (!ieee80211_is_data_present(hdr->frame_control) ||
+ is_multicast_ether_addr(hdr->addr1))
+ return false;
+
+ if ((info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO) &&
+ ieee80211_is_our_addr(tx->sdata, hdr->addr2, NULL))
+ return false;
+
+ return true;
+}
+
struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
struct ieee80211_txq *txq)
{
@@ -3948,20 +3980,8 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,
if (txq->sta) {
tx.sta = container_of(txq->sta, struct sta_info, sta);
- /*
- * Drop unicast frames to unauthorised stations unless they are
- * injected frames or EAPOL frames from the local station.
- */
- if (unlikely(!(info->flags & IEEE80211_TX_CTL_INJECTED) &&
- ieee80211_is_data_present(hdr->frame_control) &&
- !ieee80211_vif_is_mesh(&tx.sdata->vif) &&
- tx.sdata->vif.type != NL80211_IFTYPE_OCB &&
- !is_multicast_ether_addr(hdr->addr1) &&
- !test_sta_flag(tx.sta, WLAN_STA_AUTHORIZED) &&
- (!(info->control.flags &
- IEEE80211_TX_CTRL_PORT_CTRL_PROTO) ||
- !ieee80211_is_our_addr(tx.sdata, hdr->addr2,
- NULL)))) {
+
+ if (unlikely(ieee80211_drop_unauth_port(&tx))) {
I802_DEBUG_INC(local->tx_handlers_drop_unauth_port);
ieee80211_free_txskb(&local->hw, skb);
goto begin;
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH wireless-next 2/4] wifi: mac80211: fix key selection for encap offload frames
2026-08-02 8:57 [PATCH wireless-next 0/4] wifi: mac80211: encap offload fixes Johannes Berg
2026-08-02 8:57 ` [PATCH wireless-next 1/4] wifi: mac80211: fix unauthorised port check for encap offload Johannes Berg
@ 2026-08-02 8:57 ` Johannes Berg
2026-09-08 9:43 ` [PATCH] mac80211: tx: Use info->flags in ieee80211_tx_h_select_key() Bert Karwatzki
2026-08-02 8:57 ` [PATCH wireless-next 3/4] wifi: mac80211: don't send encap offload frames unencrypted Johannes Berg
2026-08-02 8:57 ` [PATCH wireless-next 4/4] wifi: mac80211: drop encap offload frames with a tainted key Johannes Berg
3 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2026-08-02 8:57 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
ieee80211_tx_h_select_key() assumes the frame is in 802.11 format
for picking the key, at least when there's no pairwise TK for the
STA to transmit with.
For unicast this is likely not relevant because if there's no
pairwise TK for the STA there's probably not going to be any other
key either. But multicast encapsulation offload frames have no
STA, so it looks at the ethernet header as if it was 802.11. This
may not matter very much since multicast encapsulation offload is
likely to ignore the key selection, but it's still wrong.
Create a separate selection function that doesn't (need to) look
at the frame header - it's data anyway, so either unicast to a
station (with sta pointer) or multicast. For MLO, the driver has
to duplicate the frame and select the key anyway, so just skip
it in that case entirely.
Fixes: 50ff477a8639 ("mac80211: add 802.11 encapsulation offloading support")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/tx.c | 37 +++++++++++++++++++++++++++++++------
1 file changed, 31 insertions(+), 6 deletions(-)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 44c40c98b497..2ef77bb80b92 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -592,6 +592,34 @@ ieee80211_select_link_key(struct ieee80211_tx_data *tx)
return NULL;
}
+/*
+ * An 802.3 frame is always a data frame, so there are no 802.11 addresses to
+ * look at: with a station the pairwise key is all that can apply, without one
+ * the frame is group addressed. On an MLD the driver has to pick the group key
+ * itself, as the same frame goes out on several links that each have their own.
+ */
+static ieee80211_tx_result
+ieee80211_select_key_8023(struct ieee80211_tx_data *tx)
+{
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
+
+ if (unlikely(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT))
+ return TX_CONTINUE;
+
+ if (tx->sta) {
+ tx->key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx]);
+ if (!tx->key)
+ tx->key = rcu_dereference(tx->sdata->default_unicast_key);
+ } else if (!ieee80211_vif_is_mld(&tx->sdata->vif)) {
+ tx->key = rcu_dereference(tx->sdata->deflink.default_multicast_key);
+ }
+
+ if (tx->key && tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
+ info->control.hw_key = &tx->key->conf;
+
+ return TX_CONTINUE;
+}
+
static ieee80211_tx_result debug_noinline
ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
{
@@ -599,6 +627,9 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
+ if (info->control.flags & IEEE80211_TX_CTL_HW_80211_ENCAP)
+ return ieee80211_select_key_8023(tx);
+
if (unlikely(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) {
tx->key = NULL;
return TX_CONTINUE;
@@ -615,12 +646,6 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
else
tx->key = NULL;
- if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) {
- if (tx->key && tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
- info->control.hw_key = &tx->key->conf;
- return TX_CONTINUE;
- }
-
if (tx->key) {
bool skip_hw = false;
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH wireless-next 3/4] wifi: mac80211: don't send encap offload frames unencrypted
2026-08-02 8:57 [PATCH wireless-next 0/4] wifi: mac80211: encap offload fixes Johannes Berg
2026-08-02 8:57 ` [PATCH wireless-next 1/4] wifi: mac80211: fix unauthorised port check for encap offload Johannes Berg
2026-08-02 8:57 ` [PATCH wireless-next 2/4] wifi: mac80211: fix key selection for encap offload frames Johannes Berg
@ 2026-08-02 8:57 ` Johannes Berg
2026-08-02 8:57 ` [PATCH wireless-next 4/4] wifi: mac80211: drop encap offload frames with a tainted key Johannes Berg
3 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2026-08-02 8:57 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
For 802.11 frames, ieee80211_tx_h_select_key() drops a data frame
that ended up without a key if the station requires encryption, so
that traffic can never leak out unprotected. Encapsulation offload
erroneously didn't get this code path. Fix that.
Fixes: 50ff477a8639 ("mac80211: add 802.11 encapsulation offloading support")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/tx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 2ef77bb80b92..c6e1171876f9 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -610,6 +610,9 @@ ieee80211_select_key_8023(struct ieee80211_tx_data *tx)
tx->key = rcu_dereference(tx->sta->ptk[tx->sta->ptk_idx]);
if (!tx->key)
tx->key = rcu_dereference(tx->sdata->default_unicast_key);
+
+ if (!tx->key && test_sta_flag(tx->sta, WLAN_STA_USES_ENCRYPTION))
+ return TX_DROP;
} else if (!ieee80211_vif_is_mld(&tx->sdata->vif)) {
tx->key = rcu_dereference(tx->sdata->deflink.default_multicast_key);
}
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH wireless-next 4/4] wifi: mac80211: drop encap offload frames with a tainted key
2026-08-02 8:57 [PATCH wireless-next 0/4] wifi: mac80211: encap offload fixes Johannes Berg
` (2 preceding siblings ...)
2026-08-02 8:57 ` [PATCH wireless-next 3/4] wifi: mac80211: don't send encap offload frames unencrypted Johannes Berg
@ 2026-08-02 8:57 ` Johannes Berg
3 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2026-08-02 8:57 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
When a key is tainted, which happens in some WoWLAN and extended
key ID scenarios, frames that would use it should be dropped.
Fix that for encapsulation offload frames.
Fixes: 50ff477a8639 ("mac80211: add 802.11 encapsulation offloading support")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/tx.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index c6e1171876f9..d16c58dc09b3 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -617,7 +617,13 @@ ieee80211_select_key_8023(struct ieee80211_tx_data *tx)
tx->key = rcu_dereference(tx->sdata->deflink.default_multicast_key);
}
- if (tx->key && tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
+ if (!tx->key)
+ return TX_CONTINUE;
+
+ if (unlikely(tx->key->flags & KEY_FLAG_TAINTED))
+ return TX_DROP;
+
+ if (tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
info->control.hw_key = &tx->key->conf;
return TX_CONTINUE;
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] mac80211: tx: Use info->flags in ieee80211_tx_h_select_key()
2026-08-02 8:57 ` [PATCH wireless-next 2/4] wifi: mac80211: fix key selection for encap offload frames Johannes Berg
@ 2026-09-08 9:43 ` Bert Karwatzki
0 siblings, 0 replies; 6+ messages in thread
From: Bert Karwatzki @ 2026-09-08 9:43 UTC (permalink / raw)
To: Johannes Berg
Cc: Bert Karwatzki, linux-wireless, linux-next, linux-kernel,
Mark Brown, johannes
Without this ieee80211_select_key_8023() is never called and wifi never
connects.
Fixes: 0e80db08668b ("wifi: mac80211: fix key selection for encap offload frames")
Signed-off-by: Bert Karwatzki <spasswolf@web.de>
---
net/mac80211/tx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 13a51a0a0358..d1d3266697b1 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -648,7 +648,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb);
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;
- if (info->control.flags & IEEE80211_TX_CTL_HW_80211_ENCAP)
+ if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP)
return ieee80211_select_key_8023(tx);
if (unlikely(info->flags & IEEE80211_TX_INTFL_DONT_ENCRYPT)) {
--
2.55.0
I noticed that in next-20260907 my wifi adapter fails to connect to the
wireless network. As this still worked in v7.3-rc2 I bisected the issue
and found the offending commit to be this merge:
commit d1352d1b277913736903eff185191c4f9723e0de
Merge: 7e615d9c216c 1b60ed34f712
Author: Mark Brown <broonie@kernel.org>
Date: Mon Sep 7 13:26:24 2026 +0100
Merge branch 'for-next' of https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git
So I examined the patch created by
git diff 7e615d9c216c d1352d1b2779
by applying it piece by piece to commit 7e615d9c216c.
The result of this procedure was the patch above as a minimal fix in
next-20260907.
The wirless hardware used is this:
09:00.0 Network controller [0280]: MEDIATEK Corp. MT7925 802.11be 160MHz 2x2 PCIe Wireless Network Adapter [Filogic 360] [14c3:7925]
Using printk()s in ieee80211_select_key_8023() (in next-20260907) I
noticed that ieee80211_select_key_8023() is never called when using
the info->control.flags test.
Bert Karwatzki
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-08 9:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-02 8:57 [PATCH wireless-next 0/4] wifi: mac80211: encap offload fixes Johannes Berg
2026-08-02 8:57 ` [PATCH wireless-next 1/4] wifi: mac80211: fix unauthorised port check for encap offload Johannes Berg
2026-08-02 8:57 ` [PATCH wireless-next 2/4] wifi: mac80211: fix key selection for encap offload frames Johannes Berg
2026-09-08 9:43 ` [PATCH] mac80211: tx: Use info->flags in ieee80211_tx_h_select_key() Bert Karwatzki
2026-08-02 8:57 ` [PATCH wireless-next 3/4] wifi: mac80211: don't send encap offload frames unencrypted Johannes Berg
2026-08-02 8:57 ` [PATCH wireless-next 4/4] wifi: mac80211: drop encap offload frames with a tainted key Johannes Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox