Commit e4e32459 authored by Michal Kazior's avatar Michal Kazior Committed by Johannes Berg

cfg80211: respect iface combinations when starting operation

devlist_mtx locking is changed to accomodate changes.
Signed-off-by: default avatarMichal Kazior <michal.kazior@tieto.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent d4e50c59
...@@ -990,7 +990,9 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, ...@@ -990,7 +990,9 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
return notifier_from_errno(-EOPNOTSUPP); return notifier_from_errno(-EOPNOTSUPP);
if (rfkill_blocked(rdev->rfkill)) if (rfkill_blocked(rdev->rfkill))
return notifier_from_errno(-ERFKILL); return notifier_from_errno(-ERFKILL);
mutex_lock(&rdev->devlist_mtx);
ret = cfg80211_can_add_interface(rdev, wdev->iftype); ret = cfg80211_can_add_interface(rdev, wdev->iftype);
mutex_unlock(&rdev->devlist_mtx);
if (ret) if (ret)
return notifier_from_errno(ret); return notifier_from_errno(ret);
cfg80211_lock_rdev(rdev); cfg80211_lock_rdev(rdev);
......
...@@ -118,6 +118,16 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev, ...@@ -118,6 +118,16 @@ int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
wdev->wext.ibss.channel = params->channel; wdev->wext.ibss.channel = params->channel;
#endif #endif
wdev->sme_state = CFG80211_SME_CONNECTING; wdev->sme_state = CFG80211_SME_CONNECTING;
err = cfg80211_can_use_chan(rdev, wdev, params->channel,
params->channel_fixed
? CHAN_MODE_SHARED
: CHAN_MODE_EXCLUSIVE);
if (err) {
wdev->connect_keys = NULL;
return err;
}
err = rdev->ops->join_ibss(&rdev->wiphy, dev, params); err = rdev->ops->join_ibss(&rdev->wiphy, dev, params);
if (err) { if (err) {
wdev->connect_keys = NULL; wdev->connect_keys = NULL;
......
...@@ -155,6 +155,11 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev, ...@@ -155,6 +155,11 @@ int __cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
setup->channel_type)) setup->channel_type))
return -EINVAL; return -EINVAL;
err = cfg80211_can_use_chan(rdev, wdev, setup->channel,
CHAN_MODE_SHARED);
if (err)
return err;
err = rdev->ops->join_mesh(&rdev->wiphy, dev, conf, setup); err = rdev->ops->join_mesh(&rdev->wiphy, dev, conf, setup);
if (!err) { if (!err) {
memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len); memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len);
...@@ -173,9 +178,11 @@ int cfg80211_join_mesh(struct cfg80211_registered_device *rdev, ...@@ -173,9 +178,11 @@ int cfg80211_join_mesh(struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev = dev->ieee80211_ptr; struct wireless_dev *wdev = dev->ieee80211_ptr;
int err; int err;
mutex_lock(&rdev->devlist_mtx);
wdev_lock(wdev); wdev_lock(wdev);
err = __cfg80211_join_mesh(rdev, dev, setup, conf); err = __cfg80211_join_mesh(rdev, dev, setup, conf);
wdev_unlock(wdev); wdev_unlock(wdev);
mutex_unlock(&rdev->devlist_mtx);
return err; return err;
} }
...@@ -208,6 +215,11 @@ int cfg80211_set_mesh_freq(struct cfg80211_registered_device *rdev, ...@@ -208,6 +215,11 @@ int cfg80211_set_mesh_freq(struct cfg80211_registered_device *rdev,
if (!netif_running(wdev->netdev)) if (!netif_running(wdev->netdev))
return -ENETDOWN; return -ENETDOWN;
err = cfg80211_can_use_chan(rdev, wdev, channel,
CHAN_MODE_SHARED);
if (err)
return err;
err = rdev->ops->libertas_set_mesh_channel(&rdev->wiphy, err = rdev->ops->libertas_set_mesh_channel(&rdev->wiphy,
wdev->netdev, wdev->netdev,
channel); channel);
......
...@@ -302,8 +302,14 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, ...@@ -302,8 +302,14 @@ int __cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
if (!req.bss) if (!req.bss)
return -ENOENT; return -ENOENT;
err = cfg80211_can_use_chan(rdev, wdev, req.bss->channel,
CHAN_MODE_SHARED);
if (err)
goto out;
err = rdev->ops->auth(&rdev->wiphy, dev, &req); err = rdev->ops->auth(&rdev->wiphy, dev, &req);
out:
cfg80211_put_bss(req.bss); cfg80211_put_bss(req.bss);
return err; return err;
} }
...@@ -317,11 +323,13 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev, ...@@ -317,11 +323,13 @@ int cfg80211_mlme_auth(struct cfg80211_registered_device *rdev,
{ {
int err; int err;
mutex_lock(&rdev->devlist_mtx);
wdev_lock(dev->ieee80211_ptr); wdev_lock(dev->ieee80211_ptr);
err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid, err = __cfg80211_mlme_auth(rdev, dev, chan, auth_type, bssid,
ssid, ssid_len, ie, ie_len, ssid, ssid_len, ie, ie_len,
key, key_len, key_idx); key, key_len, key_idx);
wdev_unlock(dev->ieee80211_ptr); wdev_unlock(dev->ieee80211_ptr);
mutex_unlock(&rdev->devlist_mtx);
return err; return err;
} }
...@@ -397,8 +405,14 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, ...@@ -397,8 +405,14 @@ int __cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
return -ENOENT; return -ENOENT;
} }
err = cfg80211_can_use_chan(rdev, wdev, req.bss->channel,
CHAN_MODE_SHARED);
if (err)
goto out;
err = rdev->ops->assoc(&rdev->wiphy, dev, &req); err = rdev->ops->assoc(&rdev->wiphy, dev, &req);
out:
if (err) { if (err) {
if (was_connected) if (was_connected)
wdev->sme_state = CFG80211_SME_CONNECTED; wdev->sme_state = CFG80211_SME_CONNECTED;
...@@ -421,11 +435,13 @@ int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev, ...@@ -421,11 +435,13 @@ int cfg80211_mlme_assoc(struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev = dev->ieee80211_ptr; struct wireless_dev *wdev = dev->ieee80211_ptr;
int err; int err;
mutex_lock(&rdev->devlist_mtx);
wdev_lock(wdev); wdev_lock(wdev);
err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid, err = __cfg80211_mlme_assoc(rdev, dev, chan, bssid, prev_bssid,
ssid, ssid_len, ie, ie_len, use_mfp, crypt, ssid, ssid_len, ie, ie_len, use_mfp, crypt,
assoc_flags, ht_capa, ht_capa_mask); assoc_flags, ht_capa, ht_capa_mask);
wdev_unlock(wdev); wdev_unlock(wdev);
mutex_unlock(&rdev->devlist_mtx);
return err; return err;
} }
......
...@@ -2478,6 +2478,14 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info) ...@@ -2478,6 +2478,14 @@ static int nl80211_start_ap(struct sk_buff *skb, struct genl_info *info)
params.channel_type)) params.channel_type))
return -EINVAL; return -EINVAL;
mutex_lock(&rdev->devlist_mtx);
err = cfg80211_can_use_chan(rdev, wdev, params.channel,
CHAN_MODE_SHARED);
mutex_unlock(&rdev->devlist_mtx);
if (err)
return err;
err = rdev->ops->start_ap(&rdev->wiphy, dev, &params); err = rdev->ops->start_ap(&rdev->wiphy, dev, &params);
if (!err) { if (!err) {
wdev->preset_chan = params.channel; wdev->preset_chan = params.channel;
......
...@@ -805,8 +805,10 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev, ...@@ -805,8 +805,10 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
return -EBUSY; return -EBUSY;
if (ntype != otype && netif_running(dev)) { if (ntype != otype && netif_running(dev)) {
mutex_lock(&rdev->devlist_mtx);
err = cfg80211_can_change_interface(rdev, dev->ieee80211_ptr, err = cfg80211_can_change_interface(rdev, dev->ieee80211_ptr,
ntype); ntype);
mutex_unlock(&rdev->devlist_mtx);
if (err) if (err)
return err; return err;
...@@ -956,6 +958,7 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, ...@@ -956,6 +958,7 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
int i, j; int i, j;
ASSERT_RTNL(); ASSERT_RTNL();
lockdep_assert_held(&rdev->devlist_mtx);
/* Always allow software iftypes */ /* Always allow software iftypes */
if (rdev->wiphy.software_iftypes & BIT(iftype)) if (rdev->wiphy.software_iftypes & BIT(iftype))
...@@ -979,7 +982,6 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, ...@@ -979,7 +982,6 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
break; break;
} }
mutex_lock(&rdev->devlist_mtx);
list_for_each_entry(wdev_iter, &rdev->netdev_list, list) { list_for_each_entry(wdev_iter, &rdev->netdev_list, list) {
if (wdev_iter == wdev) if (wdev_iter == wdev)
continue; continue;
...@@ -999,10 +1001,8 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, ...@@ -999,10 +1001,8 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
if (!used_channels[i] || used_channels[i] == ch) if (!used_channels[i] || used_channels[i] == ch)
break; break;
if (i == CFG80211_MAX_NUM_DIFFERENT_CHANNELS) { if (i == CFG80211_MAX_NUM_DIFFERENT_CHANNELS)
mutex_unlock(&rdev->devlist_mtx);
return -EBUSY; return -EBUSY;
}
if (used_channels[i] == NULL) { if (used_channels[i] == NULL) {
used_channels[i] = ch; used_channels[i] = ch;
...@@ -1018,7 +1018,6 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev, ...@@ -1018,7 +1018,6 @@ int cfg80211_can_use_iftype_chan(struct cfg80211_registered_device *rdev,
total++; total++;
used_iftypes |= BIT(wdev_iter->iftype); used_iftypes |= BIT(wdev_iter->iftype);
} }
mutex_unlock(&rdev->devlist_mtx);
if (total == 1) if (total == 1)
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment