Skip to content

Commit 2b9b07b

Browse files
jmberg-intelgregkh
authored andcommitted
mac80211: do not accept/forward invalid EAPOL frames
commit a8c4d76 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bf710b6 commit 2b9b07b

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
@@ -2541,13 +2541,13 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc)
25412541
struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data;
25422542

25432543
/*
2544-
* Allow EAPOL frames to us/the PAE group address regardless
2545-
* of whether the frame was encrypted or not.
2544+
* Allow EAPOL frames to us/the PAE group address regardless of
2545+
* whether the frame was encrypted or not, and always disallow
2546+
* all other destination addresses for them.
25462547
*/
2547-
if (ehdr->h_proto == rx->sdata->control_port_protocol &&
2548-
(ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) ||
2549-
ether_addr_equal(ehdr->h_dest, pae_group_addr)))
2550-
return true;
2548+
if (unlikely(ehdr->h_proto == rx->sdata->control_port_protocol))
2549+
return ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) ||
2550+
ether_addr_equal(ehdr->h_dest, pae_group_addr);
25512551

25522552
if (ieee80211_802_1x_port_control(rx) ||
25532553
ieee80211_drop_unencrypted(rx, fc))
@@ -2572,8 +2572,28 @@ static void ieee80211_deliver_skb_to_local_stack(struct sk_buff *skb,
25722572
cfg80211_rx_control_port(dev, skb, noencrypt);
25732573
dev_kfree_skb(skb);
25742574
} else {
2575+
struct ethhdr *ehdr = (void *)skb_mac_header(skb);
2576+
25752577
memset(skb->cb, 0, sizeof(skb->cb));
25762578

2579+
/*
2580+
* 802.1X over 802.11 requires that the authenticator address
2581+
* be used for EAPOL frames. However, 802.1X allows the use of
2582+
* the PAE group address instead. If the interface is part of
2583+
* a bridge and we pass the frame with the PAE group address,
2584+
* then the bridge will forward it to the network (even if the
2585+
* client was not associated yet), which isn't supposed to
2586+
* happen.
2587+
* To avoid that, rewrite the destination address to our own
2588+
* address, so that the authenticator (e.g. hostapd) will see
2589+
* the frame, but bridge won't forward it anywhere else. Note
2590+
* that due to earlier filtering, the only other address can
2591+
* be the PAE group address.
2592+
*/
2593+
if (unlikely(skb->protocol == sdata->control_port_protocol &&
2594+
!ether_addr_equal(ehdr->h_dest, sdata->vif.addr)))
2595+
ether_addr_copy(ehdr->h_dest, sdata->vif.addr);
2596+
25772597
/* deliver to local stack */
25782598
if (rx->list)
25792599
list_add_tail(&skb->list, rx->list);
@@ -2613,6 +2633,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
26132633
if ((sdata->vif.type == NL80211_IFTYPE_AP ||
26142634
sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
26152635
!(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) &&
2636+
ehdr->h_proto != rx->sdata->control_port_protocol &&
26162637
(sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->u.vlan.sta)) {
26172638
if (is_multicast_ether_addr(ehdr->h_dest) &&
26182639
ieee80211_vif_get_num_mcast_if(sdata) != 0) {

0 commit comments

Comments
 (0)