Skip to content

Commit a8c4d76

Browse files
committed
mac80211: do not accept/forward invalid EAPOL frames
EAPOL frames are used for authentication and key management between the AP and each individual STA associated in the BSS. Those frames are not supposed to be sent by one associated STA to another associated STA (either unicast for broadcast/multicast). Similarly, in 802.11 they're supposed to be sent to the authenticator (AP) address. Since it is possible for unexpected EAPOL frames to result in misbehavior in supplicant implementations, it is better for the AP to not allow such cases to be forwarded to other clients either directly, or indirectly if the AP interface is part of a bridge. Accept EAPOL (control port) frames only if they're transmitted to the own address, or, due to interoperability concerns, to the PAE group address. Disable forwarding of EAPOL (or well, the configured control port protocol) frames back to wireless medium in all cases. Previously, these frames were accepted from fully authenticated and authorized stations and also from unauthenticated stations for one of the cases. Additionally, to avoid forwarding by the bridge, rewrite the PAE group address case to the local MAC address. Cc: stable@vger.kernel.org Co-developed-by: Jouni Malinen <jouni@codeaurora.org> Signed-off-by: Jouni Malinen <jouni@codeaurora.org> Link: https://lore.kernel.org/r/20210511200110.cb327ed0cabe.Ib7dcffa2a31f0913d660de65ba3c8aca75b1d10f@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 7e44a0b commit a8c4d76

1 file changed

Lines changed: 27 additions & 6 deletions

File tree

‎net/mac80211/rx.c‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,13 +2531,13 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc)
25312531
struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data;
25322532

25332533
/*
2534-
* Allow EAPOL frames to us/the PAE group address regardless
2535-
* of whether the frame was encrypted or not.
2534+
* Allow EAPOL frames to us/the PAE group address regardless of
2535+
* whether the frame was encrypted or not, and always disallow
2536+
* all other destination addresses for them.
25362537
*/
2537-
if (ehdr->h_proto == rx->sdata->control_port_protocol &&
2538-
(ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) ||
2539-
ether_addr_equal(ehdr->h_dest, pae_group_addr)))
2540-
return true;
2538+
if (unlikely(ehdr->h_proto == rx->sdata->control_port_protocol))
2539+
return ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) ||
2540+
ether_addr_equal(ehdr->h_dest, pae_group_addr);
25412541

25422542
if (ieee80211_802_1x_port_control(rx) ||
25432543
ieee80211_drop_unencrypted(rx, fc))
@@ -2562,8 +2562,28 @@ static void ieee80211_deliver_skb_to_local_stack(struct sk_buff *skb,
25622562
cfg80211_rx_control_port(dev, skb, noencrypt);
25632563
dev_kfree_skb(skb);
25642564
} else {
2565+
struct ethhdr *ehdr = (void *)skb_mac_header(skb);
2566+
25652567
memset(skb->cb, 0, sizeof(skb->cb));
25662568

2569+
/*
2570+
* 802.1X over 802.11 requires that the authenticator address
2571+
* be used for EAPOL frames. However, 802.1X allows the use of
2572+
* the PAE group address instead. If the interface is part of
2573+
* a bridge and we pass the frame with the PAE group address,
2574+
* then the bridge will forward it to the network (even if the
2575+
* client was not associated yet), which isn't supposed to
2576+
* happen.
2577+
* To avoid that, rewrite the destination address to our own
2578+
* address, so that the authenticator (e.g. hostapd) will see
2579+
* the frame, but bridge won't forward it anywhere else. Note
2580+
* that due to earlier filtering, the only other address can
2581+
* be the PAE group address.
2582+
*/
2583+
if (unlikely(skb->protocol == sdata->control_port_protocol &&
2584+
!ether_addr_equal(ehdr->h_dest, sdata->vif.addr)))
2585+
ether_addr_copy(ehdr->h_dest, sdata->vif.addr);
2586+
25672587
/* deliver to local stack */
25682588
if (rx->list)
25692589
list_add_tail(&skb->list, rx->list);
@@ -2603,6 +2623,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
26032623
if ((sdata->vif.type == NL80211_IFTYPE_AP ||
26042624
sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
26052625
!(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) &&
2626+
ehdr->h_proto != rx->sdata->control_port_protocol &&
26062627
(sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->u.vlan.sta)) {
26072628
if (is_multicast_ether_addr(ehdr->h_dest) &&
26082629
ieee80211_vif_get_num_mcast_if(sdata) != 0) {

0 commit comments

Comments
 (0)