cfg80211: Unprotected Beacon frame RX indication
Subsystems (2)
PATCH 1/2 cfg80211: Unprotected Beacon frame RX indication
Extend cfg80211_rx_unprot_mlme_mgmt() to cover indication of unprotected Beacon frames in addition to the previously used Deauthentication and Disassociation frames. The Beacon frame case is quite similar, but has couple of exceptions: this is used both with fully unprotected and also incorrectly protected frames and there is a rate limit on the events to avoid unnecessary flooding netlink events in case something goes wrong.
Signed-off-by Jouni Malinen <[email protected]>
--- include/net/cfg80211.h | 10 ++++++++-- include/uapi/linux/nl80211.h | 7 +++++++ net/wireless/nl80211.c | 13 +++++++++++-- net/wireless/sme.c | 2 ++ 4 files changed, 28 insertions(+), 4 deletions(-)
include/net/cfg80211.h +8 -2
@@ -5111,6 +5111,8 @@ struct wireless_dev {struct list_head pmsr_list;spinlock_t pmsr_lock;struct work_struct pmsr_free_wk; + +unsigned long unprot_beacon_reported; };static inline u8 *wdev_address (struct wireless_dev *wdev)
@@ -6125,12 +6127,16 @@ void cfg80211_tx_mlme_mgmt(struct net_device *dev, const u8 *buf, size_t len);/** * cfg80211_rx_unprot_mlme_mgmt - notification of unprotected mlme mgmt frame * @dev: network device -* @buf: deauthentication frame (header + body) +* @buf: received management frame (header + body) * @len: length of the frame data * * This function is called whenever a received deauthentication or dissassoc * frame has been dropped in station mode because of MFP being used but the -* frame was not protected. This function may sleep. +* frame was not protected. This is also used to notify reception of a Beacon +* frame that was dropped because it did not include a valid MME MIC while +* beacon protection was enabled (BIGTK configured in station mode). +* +* This function may sleep. */ void cfg80211_rx_unprot_mlme_mgmt (struct net_device *dev,const u8 *buf,size_t len);
include/uapi/linux/nl80211.h +7 -0
@@ -1151,6 +1151,11 @@* @NL80211_CMD_SET_TID_CONFIG: Data frame TID specific configuration * is passed using %NL80211_ATTR_TID_CONFIG attribute. * +* @NL80211_CMD_UNPROT_BEACON: Unprotected or incorrectly protected Beacon +* frame. This event is used to indicate that a received Beacon frame was +* dropped because it did not include a valid MME MIC while beacon +* protection was enabled (BIGTK configured in station mode). +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -1377,6 +1382,8 @@ enum nl80211_commands {NL80211_CMD_SET_TID_CONFIG , + NL80211_CMD_UNPROT_BEACON, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
net/wireless/nl80211.c +11 -2
@@ -15544,10 +15544,19 @@ void cfg80211_rx_unprot_mlme_mgmt(struct net_device *dev, const u8 *buf,if (WARN_ON (len <2 ))return ; -if (ieee80211_is_deauth (mgmt->frame_control)) +if (ieee80211_is_deauth (mgmt->frame_control)) { cmd =NL80211_CMD_UNPROT_DEAUTHENTICATE ; -else + }else if (ieee80211_is_disassoc (mgmt->frame_control)) { cmd =NL80211_CMD_UNPROT_DISASSOCIATE ; + }else if (ieee80211_is_beacon (mgmt->frame_control)) { +if (wdev->unprot_beacon_reported && +elapsed_jiffies_msecs (wdev->unprot_beacon_reported) <10000 ) +return ; + cmd =NL80211_CMD_UNPROT_BEACON ; + wdev->unprot_beacon_reported = jiffies; + }else { +return ; + }trace_cfg80211_rx_unprot_mlme_mgmt (dev, buf, len); nl80211_send_mlme_event(rdev, dev, buf, len, cmd, GFP_ATOMIC, -1,
net/wireless/sme.c +2 -0
@@ -694,6 +694,7 @@ void __cfg80211_connect_result(struct net_device *dev,return ; } + wdev->unprot_beacon_reported =0 ;nl80211_send_connect_result (wiphy_to_rdev (wdev->wiphy), dev, cr,GFP_KERNEL );
@@ -921,6 +922,7 @@ void __cfg80211_roamed(struct wireless_dev *wdev,cfg80211_hold_bss (bss_from_pub (info->bss)); wdev->current_bss =bss_from_pub (info->bss); + wdev->unprot_beacon_reported =0 ;nl80211_send_roamed (wiphy_to_rdev (wdev->wiphy), wdev->netdev, info,GFP_KERNEL );
Signature · 1 line
2.20.1
PATCH 2/2 mac80211: Report beacon protection failures to user space
Report received Beacon frames that do not have a valid MME MIC when beacon protection is enabled. This covers both the cases of no MME in the received frame and invalid MIC in the MME.
Signed-off-by Jouni Malinen <[email protected]>
--- net/mac80211/rx.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
net/mac80211/rx.c +14 -2
@@ -1984,8 +1984,12 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)if (mmie_keyidx <NUM_DEFAULT_KEYS +NUM_DEFAULT_MGMT_KEYS || mmie_keyidx >=NUM_DEFAULT_KEYS +NUM_DEFAULT_MGMT_KEYS + -NUM_DEFAULT_BEACON_KEYS ) +NUM_DEFAULT_BEACON_KEYS ) { +cfg80211_rx_unprot_mlme_mgmt (rx->sdata->dev, + skb->data, + skb->len);return RX_DROP_MONITOR ;/* unexpected BIP keyidx */ + } rx->key =ieee80211_rx_get_bigtk (rx, mmie_keyidx);if (!rx->key)
@@ -2131,6 +2135,10 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)/* either the frame has been decrypted or will be dropped */ status->flag |=RX_FLAG_DECRYPTED ; +if (unlikely (ieee80211_is_beacon (fc) && result ==RX_DROP_UNUSABLE )) +cfg80211_rx_unprot_mlme_mgmt (rx->sdata->dev, + skb->data, skb->len); +return result; }
@@ -2411,8 +2419,12 @@ static int ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx)return -EACCES ; }if (unlikely (ieee80211_is_beacon (fc) && rx->key && -ieee80211_get_mmie_keyidx (rx->skb) <0 )) +ieee80211_get_mmie_keyidx (rx->skb) <0 )) { +cfg80211_rx_unprot_mlme_mgmt (rx->sdata->dev, + rx->skb->data, + rx->skb->len);return -EACCES ; + }/* * When using MFP, Action frames are not allowed prior to * having configured keys.
Signature · 1 line
2.20.1