aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-01-23 10:20:29 -0500
committerJohannes Berg <johannes.berg@intel.com>2014-02-04 15:58:07 -0500
commitd8ca16db6bb23d03fcb794df44bae64ae976f27c (patch)
treef577a829374c0f9daba8bf70e1ea3d6ac107089c /net
parentae811e21df28deb4c2adab0a47fc3da4f56d777b (diff)
mac80211: add length check in ieee80211_is_robust_mgmt_frame()
A few places weren't checking that the frame passed to the function actually has enough data even though the function clearly documents it must have a payload byte. Make this safer by changing the function to take an skb and checking the length inside. The old version is preserved for now as the rtl* drivers use it and don't have a correct skb. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net')
-rw-r--r--net/mac80211/rx.c13
-rw-r--r--net/mac80211/tx.c9
-rw-r--r--net/mac80211/wpa.c2
3 files changed, 11 insertions, 13 deletions
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index c24ca0d0f469..3b7a750ebc70 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -599,10 +599,10 @@ static int ieee80211_is_unicast_robust_mgmt_frame(struct sk_buff *skb)
599{ 599{
600 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 600 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
601 601
602 if (skb->len < 24 || is_multicast_ether_addr(hdr->addr1)) 602 if (is_multicast_ether_addr(hdr->addr1))
603 return 0; 603 return 0;
604 604
605 return ieee80211_is_robust_mgmt_frame(hdr); 605 return ieee80211_is_robust_mgmt_frame(skb);
606} 606}
607 607
608 608
@@ -610,10 +610,10 @@ static int ieee80211_is_multicast_robust_mgmt_frame(struct sk_buff *skb)
610{ 610{
611 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 611 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
612 612
613 if (skb->len < 24 || !is_multicast_ether_addr(hdr->addr1)) 613 if (!is_multicast_ether_addr(hdr->addr1))
614 return 0; 614 return 0;
615 615
616 return ieee80211_is_robust_mgmt_frame(hdr); 616 return ieee80211_is_robust_mgmt_frame(skb);
617} 617}
618 618
619 619
@@ -626,7 +626,7 @@ static int ieee80211_get_mmie_keyidx(struct sk_buff *skb)
626 if (skb->len < 24 + sizeof(*mmie) || !is_multicast_ether_addr(hdr->da)) 626 if (skb->len < 24 + sizeof(*mmie) || !is_multicast_ether_addr(hdr->da))
627 return -1; 627 return -1;
628 628
629 if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *) hdr)) 629 if (!ieee80211_is_robust_mgmt_frame(skb))
630 return -1; /* not a robust management frame */ 630 return -1; /* not a robust management frame */
631 631
632 mmie = (struct ieee80211_mmie *) 632 mmie = (struct ieee80211_mmie *)
@@ -1845,8 +1845,7 @@ static int ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx)
1845 * having configured keys. 1845 * having configured keys.
1846 */ 1846 */
1847 if (unlikely(ieee80211_is_action(fc) && !rx->key && 1847 if (unlikely(ieee80211_is_action(fc) && !rx->key &&
1848 ieee80211_is_robust_mgmt_frame( 1848 ieee80211_is_robust_mgmt_frame(rx->skb)))
1849 (struct ieee80211_hdr *) rx->skb->data)))
1850 return -EACCES; 1849 return -EACCES;
1851 } 1850 }
1852 1851
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index bb990ecfa655..07a7f38dc348 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -452,8 +452,7 @@ static int ieee80211_use_mfp(__le16 fc, struct sta_info *sta,
452 if (sta == NULL || !test_sta_flag(sta, WLAN_STA_MFP)) 452 if (sta == NULL || !test_sta_flag(sta, WLAN_STA_MFP))
453 return 0; 453 return 0;
454 454
455 if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *) 455 if (!ieee80211_is_robust_mgmt_frame(skb))
456 skb->data))
457 return 0; 456 return 0;
458 457
459 return 1; 458 return 1;
@@ -567,7 +566,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
567 tx->key = key; 566 tx->key = key;
568 else if (ieee80211_is_mgmt(hdr->frame_control) && 567 else if (ieee80211_is_mgmt(hdr->frame_control) &&
569 is_multicast_ether_addr(hdr->addr1) && 568 is_multicast_ether_addr(hdr->addr1) &&
570 ieee80211_is_robust_mgmt_frame(hdr) && 569 ieee80211_is_robust_mgmt_frame(tx->skb) &&
571 (key = rcu_dereference(tx->sdata->default_mgmt_key))) 570 (key = rcu_dereference(tx->sdata->default_mgmt_key)))
572 tx->key = key; 571 tx->key = key;
573 else if (is_multicast_ether_addr(hdr->addr1) && 572 else if (is_multicast_ether_addr(hdr->addr1) &&
@@ -582,12 +581,12 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)
582 tx->key = NULL; 581 tx->key = NULL;
583 else if (tx->skb->protocol == tx->sdata->control_port_protocol) 582 else if (tx->skb->protocol == tx->sdata->control_port_protocol)
584 tx->key = NULL; 583 tx->key = NULL;
585 else if (ieee80211_is_robust_mgmt_frame(hdr) && 584 else if (ieee80211_is_robust_mgmt_frame(tx->skb) &&
586 !(ieee80211_is_action(hdr->frame_control) && 585 !(ieee80211_is_action(hdr->frame_control) &&
587 tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP))) 586 tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP)))
588 tx->key = NULL; 587 tx->key = NULL;
589 else if (ieee80211_is_mgmt(hdr->frame_control) && 588 else if (ieee80211_is_mgmt(hdr->frame_control) &&
590 !ieee80211_is_robust_mgmt_frame(hdr)) 589 !ieee80211_is_robust_mgmt_frame(tx->skb))
591 tx->key = NULL; 590 tx->key = NULL;
592 else { 591 else {
593 I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); 592 I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 4aed45c8ee3b..b8600e3c29c8 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -494,7 +494,7 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
494 hdrlen = ieee80211_hdrlen(hdr->frame_control); 494 hdrlen = ieee80211_hdrlen(hdr->frame_control);
495 495
496 if (!ieee80211_is_data(hdr->frame_control) && 496 if (!ieee80211_is_data(hdr->frame_control) &&
497 !ieee80211_is_robust_mgmt_frame(hdr)) 497 !ieee80211_is_robust_mgmt_frame(skb))
498 return RX_CONTINUE; 498 return RX_CONTINUE;
499 499
500 data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN - 500 data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN -