From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795023042; b=m1nJYgIhjC7p798VizikpNrlCyBhNMDEvs7wPErsJtgs862GHYT3NNef3jaz3bwMRXn4 5PyERwhCSVathfC1csCmZhtg2KiYj1ddaovHSMcC8cIwE3o6hlb7KtBxNoNQHmeF6+MHB 9IfC4bdmvwDRRmHYEXJ/HbjmcpGjb+q43+MU5hrm5GN1KyfMv4lqWAHwsvTKp8pTnBjpy xp8iZCvX6CoaLvL0N1R2JbCQ9ruwuVK8tpg4Ju9hFEiFmpArlkvwlMypm0pC1DUKwGCVA OUBA79PdLLBo6CLn3f5DPm4fQHXNfZPTXoMRZoKH8BlEPCIWWQEhS2nBVH8MuVOJG0A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795023042; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=yqDQlHIPs6EosBlDLcVHpIU7XqMAHX4GWaH+gL75anU=; b=24eZU/XFHMJI602KOeCteUI0l4T0UQyHVhS90DqWy9nqxq35jn0M+299JfG2myJ8LyfS lhRd18fFncBVylX/AJ6LkQ3STVJkNqfRYNYAki62+6rWbD2ltV+vjl3SaDKnmQ0QgVR33 Y+pPMdTixRO5fB1sjI2D68OK5lFJpnrx6vYUzA/pXYzEHlbzeNdNCLYiWpQJhg8mDwfWF DtlLgKli+Hmy7a49IKXgO+nJUjzl5N3Vj1oLWxiw4n5Vm9/f5RWs+b8TBj5dHIBJ6eM1q RRk8VNvCjk71ckANVu4CeotFA7byzrNF5BT9bvQpQXnrvHqXGSGcT7zGGJimBfEqdYQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=g7cG3giG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D96F7606A32C; Wed, 18 Nov 2026 17:30:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=g7cG3giG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F8091F000C4; Wed, 18 Nov 2026 17:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795023042; bh=yqDQlHIPs6EosBlDLcVHpIU7XqMAHX4GWaH+gL75anU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=g7cG3giG/6gAcUPDnXqSPOcHo7pGlE6YByGP1HVl9iHIUvoGz219kOwlgRarVBAFV QGpdyLZq4T05YSsOpwljftzfToypgaTkmAMb07QMCvPymwahmXRBrzIVqPspMR76ue 3DhpRP0ezK8RyBMCWCftW3Q0DudWWim3vbWln0Mk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Johannes Berg , Sasha Levin Subject: [PATCH 6.18 0226/2151] wifi: mac80211: fix key selection for encap offload frames Date: Wed, 18 Nov 2026 15:32:41 +0100 Message-ID: <20261118150130.012526609@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150121.603863898@linuxfoundation.org> References: <20261118150121.603863898@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johannes Berg [ Upstream commit 0e80db08668b560b3522849cb705623148bcd4b5 ] 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") Link: https://patch.msgid.link/20260802105818.0feb7ad61047.Ia506ca211176a3c466bc60e4cc3e506df34a4a67@changeid Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- 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 4f2cf65514a6a..4e7a3e93904b9 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -574,6 +574,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) { @@ -581,6 +609,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; @@ -597,12 +628,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.53.0