Skip to content

Commit

Permalink
mac80211: fix encryption key selection for 802.3 xmit
Browse files Browse the repository at this point in the history
When using WEP, the default unicast key needs to be selected, instead of
the STA PTK.

Signed-off-by: Felix Fietkau <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
nbd168 authored and jmberg-intel committed Jan 14, 2021
1 parent 622d3b4 commit b101dd2
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions net/mac80211/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -4251,7 +4251,6 @@ netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb,
struct ethhdr *ehdr = (struct ethhdr *)skb->data;
struct ieee80211_key *key;
struct sta_info *sta;
bool offload = true;

if (unlikely(skb->len < ETH_HLEN)) {
kfree_skb(skb);
Expand All @@ -4267,18 +4266,22 @@ netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb,

if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded ||
!test_sta_flag(sta, WLAN_STA_AUTHORIZED) ||
sdata->control_port_protocol == ehdr->h_proto))
offload = false;
else if ((key = rcu_dereference(sta->ptk[sta->ptk_idx])) &&
(!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) ||
key->conf.cipher == WLAN_CIPHER_SUITE_TKIP))
offload = false;

if (offload)
ieee80211_8023_xmit(sdata, dev, sta, key, skb);
else
ieee80211_subif_start_xmit(skb, dev);
sdata->control_port_protocol == ehdr->h_proto))
goto skip_offload;

key = rcu_dereference(sta->ptk[sta->ptk_idx]);
if (!key)
key = rcu_dereference(sdata->default_unicast_key);

if (key && (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) ||
key->conf.cipher == WLAN_CIPHER_SUITE_TKIP))
goto skip_offload;

ieee80211_8023_xmit(sdata, dev, sta, key, skb);
goto out;

skip_offload:
ieee80211_subif_start_xmit(skb, dev);
out:
rcu_read_unlock();

Expand Down

0 comments on commit b101dd2

Please sign in to comment.