5ae9ca8b933c5b320574d20f901f05110ed3ea2a
[openwrt/staging/jow.git] /
1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Wed, 16 Dec 2020 21:23:24 +0100
3 Subject: [PATCH] mac80211: fix encryption key selection for 802.3 xmit
4
5 When using WEP, the default unicast key needs to be selected, instead of
6 the STA PTK.
7
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 ---
10
11 --- a/net/mac80211/tx.c
12 +++ b/net/mac80211/tx.c
13 @@ -4262,7 +4262,6 @@ netdev_tx_t ieee80211_subif_start_xmit_8
14 struct ethhdr *ehdr = (struct ethhdr *)skb->data;
15 struct ieee80211_key *key;
16 struct sta_info *sta;
17 - bool offload = true;
18
19 if (unlikely(skb->len < ETH_HLEN)) {
20 kfree_skb(skb);
21 @@ -4278,18 +4277,22 @@ netdev_tx_t ieee80211_subif_start_xmit_8
22
23 if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded ||
24 !test_sta_flag(sta, WLAN_STA_AUTHORIZED) ||
25 - sdata->control_port_protocol == ehdr->h_proto))
26 - offload = false;
27 - else if ((key = rcu_dereference(sta->ptk[sta->ptk_idx])) &&
28 - (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) ||
29 - key->conf.cipher == WLAN_CIPHER_SUITE_TKIP))
30 - offload = false;
31 + sdata->control_port_protocol == ehdr->h_proto))
32 + goto skip_offload;
33
34 - if (offload)
35 - ieee80211_8023_xmit(sdata, dev, sta, key, skb);
36 - else
37 - ieee80211_subif_start_xmit(skb, dev);
38 + key = rcu_dereference(sta->ptk[sta->ptk_idx]);
39 + if (!key)
40 + key = rcu_dereference(sdata->default_unicast_key);
41 +
42 + if (key && (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) ||
43 + key->conf.cipher == WLAN_CIPHER_SUITE_TKIP))
44 + goto skip_offload;
45 +
46 + ieee80211_8023_xmit(sdata, dev, sta, key, skb);
47 + goto out;
48
49 +skip_offload:
50 + ieee80211_subif_start_xmit(skb, dev);
51 out:
52 rcu_read_unlock();
53