]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
wireless: restrict to 32 legacy rates
authorJohannes Berg <johannes@sipsolutions.net>
Wed, 21 Jan 2009 14:13:48 +0000 (15:13 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 29 Jan 2009 21:01:09 +0000 (16:01 -0500)
Since the standards only define 12 legacy rates, 32 is certainly
a sane upper limit and we don't need to use u64 everywhere. Add
sanity checking that no more than 32 rates are registered and
change the variables to u32 throughout.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
14 files changed:
drivers/net/wireless/b43/main.c
drivers/net/wireless/b43legacy/main.c
drivers/net/wireless/p54/p54.h
drivers/net/wireless/rt2x00/rt2x00.h
include/net/mac80211.h
include/net/wireless.h
net/mac80211/ieee80211_i.h
net/mac80211/mesh.c
net/mac80211/mesh.h
net/mac80211/mesh_plink.c
net/mac80211/mlme.c
net/mac80211/util.c
net/wireless/core.c
net/wireless/util.c

index 8bb6659c0b3f858c0508c10df03b6a9261f62ddc..675a73a98072f81752dc60803fa547e56ca152d9 100644 (file)
@@ -3398,7 +3398,7 @@ out_unlock_mutex:
        return err;
 }
 
-static void b43_update_basic_rates(struct b43_wldev *dev, u64 brates)
+static void b43_update_basic_rates(struct b43_wldev *dev, u32 brates)
 {
        struct ieee80211_supported_band *sband =
                dev->wl->hw->wiphy->bands[b43_current_band(dev->wl)];
index fb996c27a19b4b3340b7e682f319eae0a627631e..879edc786713710fdde14c61257a61e5c4798645 100644 (file)
@@ -2650,7 +2650,7 @@ out_unlock_mutex:
        return err;
 }
 
-static void b43legacy_update_basic_rates(struct b43legacy_wldev *dev, u64 brates)
+static void b43legacy_update_basic_rates(struct b43legacy_wldev *dev, u32 brates)
 {
        struct ieee80211_supported_band *sband =
                dev->wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ];
index 64492feca9b2ca64c0f8710571aae5b3a9ed08b0..94c3acd1fcaf41e0058e53e79537b39c3296df5c 100644 (file)
@@ -144,7 +144,7 @@ struct p54_common {
        unsigned int output_power;
        u32 tsf_low32;
        u32 tsf_high32;
-       u64 basic_rate_mask;
+       u32 basic_rate_mask;
        u16 wakeup_timer;
        u16 aid;
        struct ieee80211_tx_queue_stats tx_stats[8];
index cc56637e73b52f8f59bccb02b77d32dc27b9cdd2..46918deceda13ccd1e30c14bb1e069a0c4a2b1c8 100644 (file)
@@ -396,7 +396,7 @@ struct rt2x00lib_erp {
        int ack_timeout;
        int ack_consume_time;
 
-       u64 basic_rates;
+       u32 basic_rates;
 
        int slot_time;
 
index ef42559694f1f4a67e4b2996dfbf2166a2b7d61c..c76484009baa3b1fe98441819e70c3ab69e29f1e 100644 (file)
@@ -207,7 +207,7 @@ struct ieee80211_bss_conf {
        u16 beacon_int;
        u16 assoc_capability;
        u64 timestamp;
-       u64 basic_rates;
+       u32 basic_rates;
        struct ieee80211_bss_ht_conf ht;
 };
 
@@ -761,7 +761,7 @@ enum set_key_cmd {
  *     sizeof(void *), size is determined in hw information.
  */
 struct ieee80211_sta {
-       u64 supp_rates[IEEE80211_NUM_BANDS];
+       u32 supp_rates[IEEE80211_NUM_BANDS];
        u8 addr[ETH_ALEN];
        u16 aid;
        struct ieee80211_sta_ht_cap ht_cap;
index 9e73aae40c5dadc05bffe63e9ba5c269e190ed1b..6c5b0820423220991986908653f684028436d0e3 100644 (file)
@@ -367,7 +367,7 @@ ieee80211_get_channel(struct wiphy *wiphy, int freq)
  */
 struct ieee80211_rate *
 ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
-                           u64 basic_rates, int bitrate);
+                           u32 basic_rates, int bitrate);
 
 /**
  * regulatory_hint - driver hint to the wireless core a regulatory domain
index a8c72742a8b1cdc45aad49cf5bdf4a05d33eb50d..70366efc792efdcda233c1296b011a9749b425e0 100644 (file)
@@ -909,11 +909,11 @@ int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid);
 void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata,
                            struct ieee80211_if_sta *ifsta);
 struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
-                                       u8 *bssid, u8 *addr, u64 supp_rates);
+                                       u8 *bssid, u8 *addr, u32 supp_rates);
 int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason);
 int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason);
 u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata);
-u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
+u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
                            struct ieee802_11_elems *elems,
                            enum ieee80211_band band);
 void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst,
@@ -1026,7 +1026,7 @@ void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb,
 void ieee802_11_parse_elems(u8 *start, size_t len,
                            struct ieee802_11_elems *elems);
 int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freq);
-u64 ieee80211_mandatory_rates(struct ieee80211_local *local,
+u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
                              enum ieee80211_band band);
 
 void ieee80211_dynamic_ps_enable_work(struct work_struct *work);
index 82f568e943657c2c5114ef111f57e53292011edc..2d573f8470d00dcbf912756a8841bcc6ce23e04d 100644 (file)
@@ -476,7 +476,7 @@ static void ieee80211_mesh_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_local *local = sdata->local;
        struct ieee802_11_elems elems;
        struct ieee80211_channel *channel;
-       u64 supp_rates = 0;
+       u32 supp_rates = 0;
        size_t baselen;
        int freq;
        enum ieee80211_band band = rx_status->band;
index f1196f5c3efeb487770322189abe715a885c6f5f..9e064ee98ee0040f1a2546361869ada96889e226 100644 (file)
@@ -236,7 +236,7 @@ void mesh_rx_path_sel_frame(struct ieee80211_sub_if_data *sdata,
                struct ieee80211_mgmt *mgmt, size_t len);
 int mesh_path_add(u8 *dst, struct ieee80211_sub_if_data *sdata);
 /* Mesh plinks */
-void mesh_neighbour_update(u8 *hw_addr, u64 rates,
+void mesh_neighbour_update(u8 *hw_addr, u32 rates,
                struct ieee80211_sub_if_data *sdata, bool add);
 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
 void mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
index c140a1b71a5e1d55768fe06a21df43839e61d202..a8bbdeca013a1b3caf8c928226b7877b88a57cf6 100644 (file)
@@ -93,7 +93,7 @@ static inline void mesh_plink_fsm_restart(struct sta_info *sta)
  *       on it in the lifecycle management section!
  */
 static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata,
-                                        u8 *hw_addr, u64 rates)
+                                        u8 *hw_addr, u32 rates)
 {
        struct ieee80211_local *local = sdata->local;
        struct sta_info *sta;
@@ -222,7 +222,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
        return 0;
 }
 
-void mesh_neighbour_update(u8 *hw_addr, u64 rates, struct ieee80211_sub_if_data *sdata,
+void mesh_neighbour_update(u8 *hw_addr, u32 rates, struct ieee80211_sub_if_data *sdata,
                           bool peer_accepting_plinks)
 {
        struct ieee80211_local *local = sdata->local;
@@ -447,7 +447,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m
                spin_lock_bh(&sta->lock);
        } else if (!sta) {
                /* ftype == PLINK_OPEN */
-               u64 rates;
+               u32 rates;
                if (!mesh_plink_free_count(sdata)) {
                        mpl_dbg("Mesh plink error: no more free plinks\n");
                        rcu_read_unlock();
index b9e4b93089c48c3f79b1fe499815eb8d36917e0b..9852da54f5e7d02379fff5a8bec18fcf353fbf2e 100644 (file)
@@ -73,7 +73,7 @@ static u8 *ieee80211_bss_get_ie(struct ieee80211_bss *bss, u8 ie)
 
 static int ieee80211_compatible_rates(struct ieee80211_bss *bss,
                                      struct ieee80211_supported_band *sband,
-                                     u64 *rates)
+                                     u32 *rates)
 {
        int i, j, count;
        *rates = 0;
@@ -93,14 +93,14 @@ static int ieee80211_compatible_rates(struct ieee80211_bss *bss,
 }
 
 /* also used by mesh code */
-u64 ieee80211_sta_get_rates(struct ieee80211_local *local,
+u32 ieee80211_sta_get_rates(struct ieee80211_local *local,
                            struct ieee802_11_elems *elems,
                            enum ieee80211_band band)
 {
        struct ieee80211_supported_band *sband;
        struct ieee80211_rate *bitrates;
        size_t num_rates;
-       u64 supp_rates;
+       u32 supp_rates;
        int i, j;
        sband = local->hw.wiphy->bands[band];
 
@@ -253,7 +253,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_bss *bss;
        int wmm = 0;
        struct ieee80211_supported_band *sband;
-       u64 rates = 0;
+       u32 rates = 0;
        size_t e_ies_len;
 
        if (ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) {
@@ -1282,7 +1282,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
        struct ieee80211_local *local = sdata->local;
        struct ieee80211_supported_band *sband;
        struct sta_info *sta;
-       u64 rates, basic_rates;
+       u32 rates, basic_rates;
        u16 capab_info, status_code, aid;
        struct ieee802_11_elems elems;
        struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf;
@@ -1639,7 +1639,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
        struct sta_info *sta;
        struct ieee80211_channel *channel;
        u64 beacon_timestamp, rx_timestamp;
-       u64 supp_rates = 0;
+       u32 supp_rates = 0;
        enum ieee80211_band band = rx_status->band;
 
        if (elems->ds_params && elems->ds_params_len == 1)
@@ -1660,7 +1660,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
 
                sta = sta_info_get(local, mgmt->sa);
                if (sta) {
-                       u64 prev_rates;
+                       u32 prev_rates;
 
                        prev_rates = sta->sta.supp_rates[band];
                        /* make sure mandatory rates are always added */
@@ -2526,7 +2526,7 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
  * must be callable in atomic context.
  */
 struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
-                                       u8 *bssid,u8 *addr, u64 supp_rates)
+                                       u8 *bssid,u8 *addr, u32 supp_rates)
 {
        struct ieee80211_local *local = sdata->local;
        struct sta_info *sta;
index 3f559e3d0a7cfbcd5b71bafb27fa14906fc08b3c..ede96c4fea2e2edada0b5e7a710eb5d827a88beb 100644 (file)
@@ -731,12 +731,12 @@ int ieee80211_set_freq(struct ieee80211_sub_if_data *sdata, int freqMHz)
        return ret;
 }
 
-u64 ieee80211_mandatory_rates(struct ieee80211_local *local,
+u32 ieee80211_mandatory_rates(struct ieee80211_local *local,
                              enum ieee80211_band band)
 {
        struct ieee80211_supported_band *sband;
        struct ieee80211_rate *bitrates;
-       u64 mandatory_rates;
+       u32 mandatory_rates;
        enum ieee80211_rate_flags mandatory_flag;
        int i;
 
index b96fc0c3f1c446132cf71e3e0464a6a2ff4edd84..12522647608917c400d2fb905f04863930f65bcc 100644 (file)
@@ -273,10 +273,16 @@ int wiphy_register(struct wiphy *wiphy)
 
                sband->band = band;
 
-               if (!sband->n_channels || !sband->n_bitrates) {
-                       WARN_ON(1);
+               if (WARN_ON(!sband->n_channels || !sband->n_bitrates))
+                       return -EINVAL;
+
+               /*
+                * Since we use a u32 for rate bitmaps in
+                * ieee80211_get_response_rate, we cannot
+                * have more than 32 legacy rates.
+                */
+               if (WARN_ON(sband->n_bitrates > 32))
                        return -EINVAL;
-               }
 
                for (i = 0; i < sband->n_channels; i++) {
                        sband->channels[i].orig_flags =
index e76cc28b034557fc1dfcadbae21a09307f6fee5c..487cdd9bcffcb0137fb3f6dd04db210c005eae06 100644 (file)
@@ -9,7 +9,7 @@
 
 struct ieee80211_rate *
 ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
-                           u64 basic_rates, int bitrate)
+                           u32 basic_rates, int bitrate)
 {
        struct ieee80211_rate *result = &sband->bitrates[0];
        int i;