提交 40b275b6 编写于 作者: J Johannes Berg 提交者: John W. Linville

mac80211: sparse RCU annotations

This adds sparse RCU annotations to most of
mac80211, only the mesh code remains to be
done.

Due the the previous patches, the annotations
are pretty simple. The only thing that this
actually changes is removing the RCU usage of
key->sta in debugfs since this pointer isn't
actually an RCU-managed pointer (it only has
a single assignment done before the key even
goes live). As that is otherwise harmless, I
decided to make it part of this patch.
Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 ec034b20
...@@ -63,7 +63,8 @@ void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid, ...@@ -63,7 +63,8 @@ void ___ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
lockdep_assert_held(&sta->ampdu_mlme.mtx); lockdep_assert_held(&sta->ampdu_mlme.mtx);
tid_rx = sta->ampdu_mlme.tid_rx[tid]; tid_rx = rcu_dereference_protected(sta->ampdu_mlme.tid_rx[tid],
lockdep_is_held(&sta->ampdu_mlme.mtx));
if (!tid_rx) if (!tid_rx)
return; return;
......
...@@ -157,16 +157,19 @@ int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid, ...@@ -157,16 +157,19 @@ int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
bool tx) bool tx)
{ {
struct ieee80211_local *local = sta->local; struct ieee80211_local *local = sta->local;
struct tid_ampdu_tx *tid_tx = sta->ampdu_mlme.tid_tx[tid]; struct tid_ampdu_tx *tid_tx;
int ret; int ret;
lockdep_assert_held(&sta->ampdu_mlme.mtx); lockdep_assert_held(&sta->ampdu_mlme.mtx);
if (!tid_tx)
return -ENOENT;
spin_lock_bh(&sta->lock); spin_lock_bh(&sta->lock);
tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
if (!tid_tx) {
spin_unlock_bh(&sta->lock);
return -ENOENT;
}
if (test_bit(HT_AGG_STATE_WANT_START, &tid_tx->state)) { if (test_bit(HT_AGG_STATE_WANT_START, &tid_tx->state)) {
/* not even started yet! */ /* not even started yet! */
ieee80211_assign_tid_tx(sta, tid, NULL); ieee80211_assign_tid_tx(sta, tid, NULL);
...@@ -291,13 +294,13 @@ ieee80211_wake_queue_agg(struct ieee80211_local *local, int tid) ...@@ -291,13 +294,13 @@ ieee80211_wake_queue_agg(struct ieee80211_local *local, int tid)
void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid) void ieee80211_tx_ba_session_handle_start(struct sta_info *sta, int tid)
{ {
struct tid_ampdu_tx *tid_tx = sta->ampdu_mlme.tid_tx[tid]; struct tid_ampdu_tx *tid_tx;
struct ieee80211_local *local = sta->local; struct ieee80211_local *local = sta->local;
struct ieee80211_sub_if_data *sdata = sta->sdata; struct ieee80211_sub_if_data *sdata = sta->sdata;
u16 start_seq_num; u16 start_seq_num;
int ret; int ret;
lockdep_assert_held(&sta->ampdu_mlme.mtx); tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
/* /*
* While we're asking the driver about the aggregation, * While we're asking the driver about the aggregation,
...@@ -404,7 +407,7 @@ int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid, ...@@ -404,7 +407,7 @@ int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid,
goto err_unlock_sta; goto err_unlock_sta;
} }
tid_tx = sta->ampdu_mlme.tid_tx[tid]; tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
/* check if the TID is not in aggregation flow already */ /* check if the TID is not in aggregation flow already */
if (tid_tx || sta->ampdu_mlme.tid_start_tx[tid]) { if (tid_tx || sta->ampdu_mlme.tid_start_tx[tid]) {
#ifdef CONFIG_MAC80211_HT_DEBUG #ifdef CONFIG_MAC80211_HT_DEBUG
...@@ -491,16 +494,19 @@ ieee80211_agg_splice_finish(struct ieee80211_local *local, u16 tid) ...@@ -491,16 +494,19 @@ ieee80211_agg_splice_finish(struct ieee80211_local *local, u16 tid)
static void ieee80211_agg_tx_operational(struct ieee80211_local *local, static void ieee80211_agg_tx_operational(struct ieee80211_local *local,
struct sta_info *sta, u16 tid) struct sta_info *sta, u16 tid)
{ {
struct tid_ampdu_tx *tid_tx;
lockdep_assert_held(&sta->ampdu_mlme.mtx); lockdep_assert_held(&sta->ampdu_mlme.mtx);
tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
#ifdef CONFIG_MAC80211_HT_DEBUG #ifdef CONFIG_MAC80211_HT_DEBUG
printk(KERN_DEBUG "Aggregation is on for tid %d\n", tid); printk(KERN_DEBUG "Aggregation is on for tid %d\n", tid);
#endif #endif
drv_ampdu_action(local, sta->sdata, drv_ampdu_action(local, sta->sdata,
IEEE80211_AMPDU_TX_OPERATIONAL, IEEE80211_AMPDU_TX_OPERATIONAL,
&sta->sta, tid, NULL, &sta->sta, tid, NULL, tid_tx->buf_size);
sta->ampdu_mlme.tid_tx[tid]->buf_size);
/* /*
* synchronize with TX path, while splicing the TX path * synchronize with TX path, while splicing the TX path
...@@ -508,13 +514,13 @@ static void ieee80211_agg_tx_operational(struct ieee80211_local *local, ...@@ -508,13 +514,13 @@ static void ieee80211_agg_tx_operational(struct ieee80211_local *local,
*/ */
spin_lock_bh(&sta->lock); spin_lock_bh(&sta->lock);
ieee80211_agg_splice_packets(local, sta->ampdu_mlme.tid_tx[tid], tid); ieee80211_agg_splice_packets(local, tid_tx, tid);
/* /*
* Now mark as operational. This will be visible * Now mark as operational. This will be visible
* in the TX path, and lets it go lock-free in * in the TX path, and lets it go lock-free in
* the common case. * the common case.
*/ */
set_bit(HT_AGG_STATE_OPERATIONAL, &sta->ampdu_mlme.tid_tx[tid]->state); set_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state);
ieee80211_agg_splice_finish(local, tid); ieee80211_agg_splice_finish(local, tid);
spin_unlock_bh(&sta->lock); spin_unlock_bh(&sta->lock);
...@@ -548,7 +554,7 @@ void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid) ...@@ -548,7 +554,7 @@ void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid)
} }
mutex_lock(&sta->ampdu_mlme.mtx); mutex_lock(&sta->ampdu_mlme.mtx);
tid_tx = sta->ampdu_mlme.tid_tx[tid]; tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
if (WARN_ON(!tid_tx)) { if (WARN_ON(!tid_tx)) {
#ifdef CONFIG_MAC80211_HT_DEBUG #ifdef CONFIG_MAC80211_HT_DEBUG
...@@ -626,7 +632,7 @@ int ieee80211_stop_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid) ...@@ -626,7 +632,7 @@ int ieee80211_stop_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid)
return -EINVAL; return -EINVAL;
spin_lock_bh(&sta->lock); spin_lock_bh(&sta->lock);
tid_tx = sta->ampdu_mlme.tid_tx[tid]; tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
if (!tid_tx) { if (!tid_tx) {
ret = -ENOENT; ret = -ENOENT;
...@@ -682,7 +688,7 @@ void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid) ...@@ -682,7 +688,7 @@ void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid)
mutex_lock(&sta->ampdu_mlme.mtx); mutex_lock(&sta->ampdu_mlme.mtx);
spin_lock_bh(&sta->lock); spin_lock_bh(&sta->lock);
tid_tx = sta->ampdu_mlme.tid_tx[tid]; tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
if (!tid_tx || !test_bit(HT_AGG_STATE_STOPPING, &tid_tx->state)) { if (!tid_tx || !test_bit(HT_AGG_STATE_STOPPING, &tid_tx->state)) {
#ifdef CONFIG_MAC80211_HT_DEBUG #ifdef CONFIG_MAC80211_HT_DEBUG
...@@ -763,7 +769,7 @@ void ieee80211_process_addba_resp(struct ieee80211_local *local, ...@@ -763,7 +769,7 @@ void ieee80211_process_addba_resp(struct ieee80211_local *local,
mutex_lock(&sta->ampdu_mlme.mtx); mutex_lock(&sta->ampdu_mlme.mtx);
tid_tx = sta->ampdu_mlme.tid_tx[tid]; tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
if (!tid_tx) if (!tid_tx)
goto out; goto out;
......
...@@ -177,11 +177,11 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, ...@@ -177,11 +177,11 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
goto out_unlock; goto out_unlock;
if (pairwise) if (pairwise)
key = sta->ptk; key = key_mtx_dereference(local, sta->ptk);
else else
key = sta->gtk[key_idx]; key = key_mtx_dereference(local, sta->gtk[key_idx]);
} else } else
key = sdata->keys[key_idx]; key = key_mtx_dereference(local, sdata->keys[key_idx]);
if (!key) { if (!key) {
ret = -ENOENT; ret = -ENOENT;
...@@ -463,7 +463,7 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, ...@@ -463,7 +463,7 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,
int size; int size;
int err = -EINVAL; int err = -EINVAL;
old = sdata->u.ap.beacon; old = rtnl_dereference(sdata->u.ap.beacon);
/* head must not be zero-length */ /* head must not be zero-length */
if (params->head && !params->head_len) if (params->head && !params->head_len)
...@@ -558,8 +558,7 @@ static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, ...@@ -558,8 +558,7 @@ static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev,
sdata = IEEE80211_DEV_TO_SUB_IF(dev); sdata = IEEE80211_DEV_TO_SUB_IF(dev);
old = sdata->u.ap.beacon; old = rtnl_dereference(sdata->u.ap.beacon);
if (old) if (old)
return -EALREADY; return -EALREADY;
...@@ -574,8 +573,7 @@ static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, ...@@ -574,8 +573,7 @@ static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev,
sdata = IEEE80211_DEV_TO_SUB_IF(dev); sdata = IEEE80211_DEV_TO_SUB_IF(dev);
old = sdata->u.ap.beacon; old = rtnl_dereference(sdata->u.ap.beacon);
if (!old) if (!old)
return -ENOENT; return -ENOENT;
...@@ -589,8 +587,7 @@ static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) ...@@ -589,8 +587,7 @@ static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev)
sdata = IEEE80211_DEV_TO_SUB_IF(dev); sdata = IEEE80211_DEV_TO_SUB_IF(dev);
old = sdata->u.ap.beacon; old = rtnl_dereference(sdata->u.ap.beacon);
if (!old) if (!old)
return -ENOENT; return -ENOENT;
......
...@@ -241,16 +241,12 @@ void ieee80211_debugfs_key_add(struct ieee80211_key *key) ...@@ -241,16 +241,12 @@ void ieee80211_debugfs_key_add(struct ieee80211_key *key)
if (!key->debugfs.dir) if (!key->debugfs.dir)
return; return;
rcu_read_lock(); sta = key->sta;
sta = rcu_dereference(key->sta); if (sta) {
if (sta)
sprintf(buf, "../../stations/%pM", sta->sta.addr); sprintf(buf, "../../stations/%pM", sta->sta.addr);
rcu_read_unlock();
/* using sta as a boolean is fine outside RCU lock */
if (sta)
key->debugfs.stalink = key->debugfs.stalink =
debugfs_create_symlink("station", key->debugfs.dir, buf); debugfs_create_symlink("station", key->debugfs.dir, buf);
}
DEBUGFS_ADD(keylen); DEBUGFS_ADD(keylen);
DEBUGFS_ADD(flags); DEBUGFS_ADD(flags);
...@@ -286,7 +282,8 @@ void ieee80211_debugfs_key_update_default(struct ieee80211_sub_if_data *sdata) ...@@ -286,7 +282,8 @@ void ieee80211_debugfs_key_update_default(struct ieee80211_sub_if_data *sdata)
lockdep_assert_held(&sdata->local->key_mtx); lockdep_assert_held(&sdata->local->key_mtx);
if (sdata->default_unicast_key) { if (sdata->default_unicast_key) {
key = sdata->default_unicast_key; key = key_mtx_dereference(sdata->local,
sdata->default_unicast_key);
sprintf(buf, "../keys/%d", key->debugfs.cnt); sprintf(buf, "../keys/%d", key->debugfs.cnt);
sdata->debugfs.default_unicast_key = sdata->debugfs.default_unicast_key =
debugfs_create_symlink("default_unicast_key", debugfs_create_symlink("default_unicast_key",
...@@ -297,7 +294,8 @@ void ieee80211_debugfs_key_update_default(struct ieee80211_sub_if_data *sdata) ...@@ -297,7 +294,8 @@ void ieee80211_debugfs_key_update_default(struct ieee80211_sub_if_data *sdata)
} }
if (sdata->default_multicast_key) { if (sdata->default_multicast_key) {
key = sdata->default_multicast_key; key = key_mtx_dereference(sdata->local,
sdata->default_multicast_key);
sprintf(buf, "../keys/%d", key->debugfs.cnt); sprintf(buf, "../keys/%d", key->debugfs.cnt);
sdata->debugfs.default_multicast_key = sdata->debugfs.default_multicast_key =
debugfs_create_symlink("default_multicast_key", debugfs_create_symlink("default_multicast_key",
...@@ -316,9 +314,8 @@ void ieee80211_debugfs_key_add_mgmt_default(struct ieee80211_sub_if_data *sdata) ...@@ -316,9 +314,8 @@ void ieee80211_debugfs_key_add_mgmt_default(struct ieee80211_sub_if_data *sdata)
if (!sdata->debugfs.dir) if (!sdata->debugfs.dir)
return; return;
/* this is running under the key lock */ key = key_mtx_dereference(sdata->local,
sdata->default_mgmt_key);
key = sdata->default_mgmt_key;
if (key) { if (key) {
sprintf(buf, "../keys/%d", key->debugfs.cnt); sprintf(buf, "../keys/%d", key->debugfs.cnt);
sdata->debugfs.default_mgmt_key = sdata->debugfs.default_mgmt_key =
......
...@@ -160,7 +160,7 @@ void ieee80211_ba_session_work(struct work_struct *work) ...@@ -160,7 +160,7 @@ void ieee80211_ba_session_work(struct work_struct *work)
continue; continue;
} }
tid_tx = sta->ampdu_mlme.tid_tx[tid]; tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
if (tid_tx && test_and_clear_bit(HT_AGG_STATE_WANT_STOP, if (tid_tx && test_and_clear_bit(HT_AGG_STATE_WANT_STOP,
&tid_tx->state)) &tid_tx->state))
___ieee80211_stop_tx_ba_session(sta, tid, ___ieee80211_stop_tx_ba_session(sta, tid,
......
...@@ -662,12 +662,16 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, ...@@ -662,12 +662,16 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
int tx_last_beacon, len = req->len; int tx_last_beacon, len = req->len;
struct sk_buff *skb; struct sk_buff *skb;
struct ieee80211_mgmt *resp; struct ieee80211_mgmt *resp;
struct sk_buff *presp;
u8 *pos, *end; u8 *pos, *end;
lockdep_assert_held(&ifibss->mtx); lockdep_assert_held(&ifibss->mtx);
presp = rcu_dereference_protected(ifibss->presp,
lockdep_is_held(&ifibss->mtx));
if (ifibss->state != IEEE80211_IBSS_MLME_JOINED || if (ifibss->state != IEEE80211_IBSS_MLME_JOINED ||
len < 24 + 2 || !ifibss->presp) len < 24 + 2 || !presp)
return; return;
tx_last_beacon = drv_tx_last_beacon(local); tx_last_beacon = drv_tx_last_beacon(local);
...@@ -705,7 +709,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, ...@@ -705,7 +709,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
} }
/* Reply with ProbeResp */ /* Reply with ProbeResp */
skb = skb_copy(ifibss->presp, GFP_KERNEL); skb = skb_copy(presp, GFP_KERNEL);
if (!skb) if (!skb)
return; return;
...@@ -985,7 +989,8 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) ...@@ -985,7 +989,8 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata)
/* remove beacon */ /* remove beacon */
kfree(sdata->u.ibss.ie); kfree(sdata->u.ibss.ie);
skb = sdata->u.ibss.presp; skb = rcu_dereference_protected(sdata->u.ibss.presp,
lockdep_is_held(&sdata->u.ibss.mtx));
rcu_assign_pointer(sdata->u.ibss.presp, NULL); rcu_assign_pointer(sdata->u.ibss.presp, NULL);
sdata->vif.bss_conf.ibss_joined = false; sdata->vif.bss_conf.ibss_joined = false;
ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED |
......
...@@ -214,7 +214,7 @@ struct beacon_data { ...@@ -214,7 +214,7 @@ struct beacon_data {
}; };
struct ieee80211_if_ap { struct ieee80211_if_ap {
struct beacon_data *beacon; struct beacon_data __rcu *beacon;
struct list_head vlans; struct list_head vlans;
...@@ -237,7 +237,7 @@ struct ieee80211_if_vlan { ...@@ -237,7 +237,7 @@ struct ieee80211_if_vlan {
struct list_head list; struct list_head list;
/* used for all tx if the VLAN is configured to 4-addr mode */ /* used for all tx if the VLAN is configured to 4-addr mode */
struct sta_info *sta; struct sta_info __rcu *sta;
}; };
struct mesh_stats { struct mesh_stats {
...@@ -442,7 +442,8 @@ struct ieee80211_if_ibss { ...@@ -442,7 +442,8 @@ struct ieee80211_if_ibss {
unsigned long ibss_join_req; unsigned long ibss_join_req;
/* probe response/beacon for IBSS */ /* probe response/beacon for IBSS */
struct sk_buff *presp, *skb; struct sk_buff __rcu *presp;
struct sk_buff *skb;
enum { enum {
IEEE80211_IBSS_MLME_SEARCH, IEEE80211_IBSS_MLME_SEARCH,
...@@ -567,9 +568,10 @@ struct ieee80211_sub_if_data { ...@@ -567,9 +568,10 @@ struct ieee80211_sub_if_data {
struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX]; struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
unsigned int fragment_next; unsigned int fragment_next;
struct ieee80211_key *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS]; struct ieee80211_key __rcu *keys[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
struct ieee80211_key *default_unicast_key, *default_multicast_key; struct ieee80211_key __rcu *default_unicast_key;
struct ieee80211_key *default_mgmt_key; struct ieee80211_key __rcu *default_multicast_key;
struct ieee80211_key __rcu *default_mgmt_key;
u16 sequence_number; u16 sequence_number;
__be16 control_port_protocol; __be16 control_port_protocol;
...@@ -805,7 +807,7 @@ struct ieee80211_local { ...@@ -805,7 +807,7 @@ struct ieee80211_local {
spinlock_t sta_lock; spinlock_t sta_lock;
unsigned long num_sta; unsigned long num_sta;
struct list_head sta_list, sta_pending_list; struct list_head sta_list, sta_pending_list;
struct sta_info *sta_hash[STA_HASH_SIZE]; struct sta_info __rcu *sta_hash[STA_HASH_SIZE];
struct timer_list sta_cleanup; struct timer_list sta_cleanup;
struct work_struct sta_finish_work; struct work_struct sta_finish_work;
int sta_generation; int sta_generation;
......
...@@ -449,7 +449,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, ...@@ -449,7 +449,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
/* APs need special treatment */ /* APs need special treatment */
if (sdata->vif.type == NL80211_IFTYPE_AP) { if (sdata->vif.type == NL80211_IFTYPE_AP) {
struct ieee80211_sub_if_data *vlan, *tmpsdata; struct ieee80211_sub_if_data *vlan, *tmpsdata;
struct beacon_data *old_beacon = sdata->u.ap.beacon; struct beacon_data *old_beacon =
rtnl_dereference(sdata->u.ap.beacon);
/* sdata_running will return false, so this will disable */ /* sdata_running will return false, so this will disable */
ieee80211_bss_info_change_notify(sdata, ieee80211_bss_info_change_notify(sdata,
......
...@@ -195,7 +195,7 @@ static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, ...@@ -195,7 +195,7 @@ static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,
assert_key_lock(sdata->local); assert_key_lock(sdata->local);
if (idx >= 0 && idx < NUM_DEFAULT_KEYS) if (idx >= 0 && idx < NUM_DEFAULT_KEYS)
key = sdata->keys[idx]; key = key_mtx_dereference(sdata->local, sdata->keys[idx]);
if (uni) if (uni)
rcu_assign_pointer(sdata->default_unicast_key, key); rcu_assign_pointer(sdata->default_unicast_key, key);
...@@ -222,7 +222,7 @@ __ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata, int idx) ...@@ -222,7 +222,7 @@ __ieee80211_set_default_mgmt_key(struct ieee80211_sub_if_data *sdata, int idx)
if (idx >= NUM_DEFAULT_KEYS && if (idx >= NUM_DEFAULT_KEYS &&
idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS) idx < NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS)
key = sdata->keys[idx]; key = key_mtx_dereference(sdata->local, sdata->keys[idx]);
rcu_assign_pointer(sdata->default_mgmt_key, key); rcu_assign_pointer(sdata->default_mgmt_key, key);
...@@ -266,9 +266,15 @@ static void __ieee80211_key_replace(struct ieee80211_sub_if_data *sdata, ...@@ -266,9 +266,15 @@ static void __ieee80211_key_replace(struct ieee80211_sub_if_data *sdata,
else else
idx = new->conf.keyidx; idx = new->conf.keyidx;
defunikey = old && sdata->default_unicast_key == old; defunikey = old &&
defmultikey = old && sdata->default_multicast_key == old; old == key_mtx_dereference(sdata->local,
defmgmtkey = old && sdata->default_mgmt_key == old; sdata->default_unicast_key);
defmultikey = old &&
old == key_mtx_dereference(sdata->local,
sdata->default_multicast_key);
defmgmtkey = old &&
old == key_mtx_dereference(sdata->local,
sdata->default_mgmt_key);
if (defunikey && !new) if (defunikey && !new)
__ieee80211_set_default_key(sdata, -1, true, false); __ieee80211_set_default_key(sdata, -1, true, false);
...@@ -451,11 +457,11 @@ int ieee80211_key_link(struct ieee80211_key *key, ...@@ -451,11 +457,11 @@ int ieee80211_key_link(struct ieee80211_key *key,
mutex_lock(&sdata->local->key_mtx); mutex_lock(&sdata->local->key_mtx);
if (sta && pairwise) if (sta && pairwise)
old_key = sta->ptk; old_key = key_mtx_dereference(sdata->local, sta->ptk);
else if (sta) else if (sta)
old_key = sta->gtk[idx]; old_key = key_mtx_dereference(sdata->local, sta->gtk[idx]);
else else
old_key = sdata->keys[idx]; old_key = key_mtx_dereference(sdata->local, sdata->keys[idx]);
__ieee80211_key_replace(sdata, sta, pairwise, old_key, key); __ieee80211_key_replace(sdata, sta, pairwise, old_key, key);
__ieee80211_key_destroy(old_key); __ieee80211_key_destroy(old_key);
......
...@@ -146,4 +146,7 @@ void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata); ...@@ -146,4 +146,7 @@ void ieee80211_free_keys(struct ieee80211_sub_if_data *sdata);
void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata); void ieee80211_enable_keys(struct ieee80211_sub_if_data *sdata);
void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata); void ieee80211_disable_keys(struct ieee80211_sub_if_data *sdata);
#define key_mtx_dereference(local, ref) \
rcu_dereference_protected(ref, lockdep_is_held(&((local)->key_mtx)))
#endif /* IEEE80211_KEY_H */ #endif /* IEEE80211_KEY_H */
...@@ -871,8 +871,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) ...@@ -871,8 +871,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
* and we need some headroom for passing the frame to monitor * and we need some headroom for passing the frame to monitor
* interfaces, but never both at the same time. * interfaces, but never both at the same time.
*/ */
#ifndef __CHECKER__
BUILD_BUG_ON(IEEE80211_TX_STATUS_HEADROOM != BUILD_BUG_ON(IEEE80211_TX_STATUS_HEADROOM !=
sizeof(struct ieee80211_tx_status_rtap_hdr)); sizeof(struct ieee80211_tx_status_rtap_hdr));
#endif
local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom, local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom,
sizeof(struct ieee80211_tx_status_rtap_hdr)); sizeof(struct ieee80211_tx_status_rtap_hdr));
......
...@@ -92,7 +92,7 @@ struct mesh_path { ...@@ -92,7 +92,7 @@ struct mesh_path {
u8 dst[ETH_ALEN]; u8 dst[ETH_ALEN];
u8 mpp[ETH_ALEN]; /* used for MPP or MAP */ u8 mpp[ETH_ALEN]; /* used for MPP or MAP */
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
struct sta_info *next_hop; struct sta_info __rcu *next_hop;
struct timer_list timer; struct timer_list timer;
struct sk_buff_head frame_queue; struct sk_buff_head frame_queue;
struct rcu_head rcu; struct rcu_head rcu;
......
...@@ -560,6 +560,14 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, ...@@ -560,6 +560,14 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
} }
static inline struct sta_info *
next_hop_deref_protected(struct mesh_path *mpath)
{
return rcu_dereference_protected(mpath->next_hop,
lockdep_is_held(&mpath->state_lock));
}
static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
struct ieee80211_mgmt *mgmt, struct ieee80211_mgmt *mgmt,
u8 *prep_elem, u32 metric) u8 *prep_elem, u32 metric)
...@@ -599,7 +607,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata, ...@@ -599,7 +607,7 @@ static void hwmp_prep_frame_process(struct ieee80211_sub_if_data *sdata,
spin_unlock_bh(&mpath->state_lock); spin_unlock_bh(&mpath->state_lock);
goto fail; goto fail;
} }
memcpy(next_hop, mpath->next_hop->sta.addr, ETH_ALEN); memcpy(next_hop, next_hop_deref_protected(mpath)->sta.addr, ETH_ALEN);
spin_unlock_bh(&mpath->state_lock); spin_unlock_bh(&mpath->state_lock);
--ttl; --ttl;
flags = PREP_IE_FLAGS(prep_elem); flags = PREP_IE_FLAGS(prep_elem);
...@@ -651,7 +659,8 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata, ...@@ -651,7 +659,8 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
if (mpath) { if (mpath) {
spin_lock_bh(&mpath->state_lock); spin_lock_bh(&mpath->state_lock);
if (mpath->flags & MESH_PATH_ACTIVE && if (mpath->flags & MESH_PATH_ACTIVE &&
memcmp(ta, mpath->next_hop->sta.addr, ETH_ALEN) == 0 && memcmp(ta, next_hop_deref_protected(mpath)->sta.addr,
ETH_ALEN) == 0 &&
(!(mpath->flags & MESH_PATH_SN_VALID) || (!(mpath->flags & MESH_PATH_SN_VALID) ||
SN_GT(target_sn, mpath->sn))) { SN_GT(target_sn, mpath->sn))) {
mpath->flags &= ~MESH_PATH_ACTIVE; mpath->flags &= ~MESH_PATH_ACTIVE;
...@@ -913,6 +922,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb, ...@@ -913,6 +922,7 @@ int mesh_nexthop_lookup(struct sk_buff *skb,
{ {
struct sk_buff *skb_to_free = NULL; struct sk_buff *skb_to_free = NULL;
struct mesh_path *mpath; struct mesh_path *mpath;
struct sta_info *next_hop;
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
u8 *target_addr = hdr->addr3; u8 *target_addr = hdr->addr3;
int err = 0; int err = 0;
...@@ -940,7 +950,11 @@ int mesh_nexthop_lookup(struct sk_buff *skb, ...@@ -940,7 +950,11 @@ int mesh_nexthop_lookup(struct sk_buff *skb,
mesh_queue_preq(mpath, mesh_queue_preq(mpath,
PREQ_Q_F_START | PREQ_Q_F_REFRESH); PREQ_Q_F_START | PREQ_Q_F_REFRESH);
} }
memcpy(hdr->addr1, mpath->next_hop->sta.addr, ETH_ALEN); next_hop = rcu_dereference(mpath->next_hop);
if (next_hop)
memcpy(hdr->addr1, next_hop->sta.addr, ETH_ALEN);
else
err = -ENOENT;
} else { } else {
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
if (!(mpath->flags & MESH_PATH_RESOLVING)) { if (!(mpath->flags & MESH_PATH_RESOLVING)) {
......
...@@ -67,7 +67,8 @@ static int sta_info_hash_del(struct ieee80211_local *local, ...@@ -67,7 +67,8 @@ static int sta_info_hash_del(struct ieee80211_local *local,
{ {
struct sta_info *s; struct sta_info *s;
s = local->sta_hash[STA_HASH(sta->sta.addr)]; s = rcu_dereference_protected(local->sta_hash[STA_HASH(sta->sta.addr)],
lockdep_is_held(&local->sta_lock));
if (!s) if (!s)
return -ENOENT; return -ENOENT;
if (s == sta) { if (s == sta) {
...@@ -76,9 +77,11 @@ static int sta_info_hash_del(struct ieee80211_local *local, ...@@ -76,9 +77,11 @@ static int sta_info_hash_del(struct ieee80211_local *local,
return 0; return 0;
} }
while (s->hnext && s->hnext != sta) while (rcu_access_pointer(s->hnext) &&
s = s->hnext; rcu_access_pointer(s->hnext) != sta)
if (s->hnext) { s = rcu_dereference_protected(s->hnext,
lockdep_is_held(&local->sta_lock));
if (rcu_access_pointer(s->hnext)) {
rcu_assign_pointer(s->hnext, sta->hnext); rcu_assign_pointer(s->hnext, sta->hnext);
return 0; return 0;
} }
...@@ -654,9 +657,9 @@ static int __must_check __sta_info_destroy(struct sta_info *sta) ...@@ -654,9 +657,9 @@ static int __must_check __sta_info_destroy(struct sta_info *sta)
mutex_lock(&local->key_mtx); mutex_lock(&local->key_mtx);
for (i = 0; i < NUM_DEFAULT_KEYS; i++) for (i = 0; i < NUM_DEFAULT_KEYS; i++)
__ieee80211_key_free(sta->gtk[i]); __ieee80211_key_free(key_mtx_dereference(local, sta->gtk[i]));
if (sta->ptk) if (sta->ptk)
__ieee80211_key_free(sta->ptk); __ieee80211_key_free(key_mtx_dereference(local, sta->ptk));
mutex_unlock(&local->key_mtx); mutex_unlock(&local->key_mtx);
sta->dead = true; sta->dead = true;
......
...@@ -164,11 +164,11 @@ struct tid_ampdu_rx { ...@@ -164,11 +164,11 @@ struct tid_ampdu_rx {
struct sta_ampdu_mlme { struct sta_ampdu_mlme {
struct mutex mtx; struct mutex mtx;
/* rx */ /* rx */
struct tid_ampdu_rx *tid_rx[STA_TID_NUM]; struct tid_ampdu_rx __rcu *tid_rx[STA_TID_NUM];
unsigned long tid_rx_timer_expired[BITS_TO_LONGS(STA_TID_NUM)]; unsigned long tid_rx_timer_expired[BITS_TO_LONGS(STA_TID_NUM)];
/* tx */ /* tx */
struct work_struct work; struct work_struct work;
struct tid_ampdu_tx *tid_tx[STA_TID_NUM]; struct tid_ampdu_tx __rcu *tid_tx[STA_TID_NUM];
struct tid_ampdu_tx *tid_start_tx[STA_TID_NUM]; struct tid_ampdu_tx *tid_start_tx[STA_TID_NUM];
u8 addba_req_num[STA_TID_NUM]; u8 addba_req_num[STA_TID_NUM];
u8 dialog_token_allocator; u8 dialog_token_allocator;
...@@ -243,11 +243,11 @@ struct sta_ampdu_mlme { ...@@ -243,11 +243,11 @@ struct sta_ampdu_mlme {
struct sta_info { struct sta_info {
/* General information, mostly static */ /* General information, mostly static */
struct list_head list; struct list_head list;
struct sta_info *hnext; struct sta_info __rcu *hnext;
struct ieee80211_local *local; struct ieee80211_local *local;
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
struct ieee80211_key *gtk[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS]; struct ieee80211_key __rcu *gtk[NUM_DEFAULT_KEYS + NUM_DEFAULT_MGMT_KEYS];
struct ieee80211_key *ptk; struct ieee80211_key __rcu *ptk;
struct rate_control_ref *rate_ctrl; struct rate_control_ref *rate_ctrl;
void *rate_ctrl_priv; void *rate_ctrl_priv;
spinlock_t lock; spinlock_t lock;
...@@ -403,6 +403,13 @@ static inline u32 get_sta_flags(struct sta_info *sta) ...@@ -403,6 +403,13 @@ static inline u32 get_sta_flags(struct sta_info *sta)
void ieee80211_assign_tid_tx(struct sta_info *sta, int tid, void ieee80211_assign_tid_tx(struct sta_info *sta, int tid,
struct tid_ampdu_tx *tid_tx); struct tid_ampdu_tx *tid_tx);
static inline struct tid_ampdu_tx *
rcu_dereference_protected_tid_tx(struct sta_info *sta, int tid)
{
return rcu_dereference_protected(sta->ampdu_mlme.tid_tx[tid],
lockdep_is_held(&sta->lock) ||
lockdep_is_held(&sta->ampdu_mlme.mtx));
}
#define STA_HASH_SIZE 256 #define STA_HASH_SIZE 256
#define STA_HASH(sta) (sta[5]) #define STA_HASH(sta) (sta[5])
......
...@@ -1147,7 +1147,7 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx, ...@@ -1147,7 +1147,7 @@ static bool ieee80211_tx_prep_agg(struct ieee80211_tx_data *tx,
* packet pass through because splicing the frames * packet pass through because splicing the frames
* back is already done. * back is already done.
*/ */
tid_tx = tx->sta->ampdu_mlme.tid_tx[tid]; tid_tx = rcu_dereference_protected_tid_tx(tx->sta, tid);
if (!tid_tx) { if (!tid_tx) {
/* do nothing, let packet pass through */ /* do nothing, let packet pass through */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册