Skip to content

Commit eb50790

Browse files
committed
Merge tag 'mac80211-for-net-2020-01-15' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211
Johannes Berg says: ==================== A few fixes: * -O3 enablement fallout, thanks to Arnd who ran this * fixes for a few leaks, thanks to Felix * channel 12 regulatory fix for custom regdomains * check for a crash reported by syzbot (NULL function is called on drivers that don't have it) * fix TKIP replay protection after setup with some APs (from Jouni) * restrict obtaining some mesh data to avoid WARN_ONs * fix deadlocks with auto-disconnect (socket owner) * fix radar detection events with multiple devices ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 8c4df83 + 81c044f commit eb50790

11 files changed

Lines changed: 106 additions & 12 deletions

File tree

‎include/net/cfg80211.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3548,6 +3548,9 @@ struct cfg80211_update_owe_info {
35483548
*
35493549
* @start_radar_detection: Start radar detection in the driver.
35503550
*
3551+
* @end_cac: End running CAC, probably because a related CAC
3552+
* was finished on another phy.
3553+
*
35513554
* @update_ft_ies: Provide updated Fast BSS Transition information to the
35523555
* driver. If the SME is in the driver/firmware, this information can be
35533556
* used in building Authentication and Reassociation Request frames.
@@ -3874,6 +3877,8 @@ struct cfg80211_ops {
38743877
struct net_device *dev,
38753878
struct cfg80211_chan_def *chandef,
38763879
u32 cac_time_ms);
3880+
void (*end_cac)(struct wiphy *wiphy,
3881+
struct net_device *dev);
38773882
int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev,
38783883
struct cfg80211_update_ft_ies_params *ftie);
38793884
int (*crit_proto_start)(struct wiphy *wiphy,

‎net/mac80211/cfg.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,6 +2954,28 @@ static int ieee80211_start_radar_detection(struct wiphy *wiphy,
29542954
return err;
29552955
}
29562956

2957+
static void ieee80211_end_cac(struct wiphy *wiphy,
2958+
struct net_device *dev)
2959+
{
2960+
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2961+
struct ieee80211_local *local = sdata->local;
2962+
2963+
mutex_lock(&local->mtx);
2964+
list_for_each_entry(sdata, &local->interfaces, list) {
2965+
/* it might be waiting for the local->mtx, but then
2966+
* by the time it gets it, sdata->wdev.cac_started
2967+
* will no longer be true
2968+
*/
2969+
cancel_delayed_work(&sdata->dfs_cac_timer_work);
2970+
2971+
if (sdata->wdev.cac_started) {
2972+
ieee80211_vif_release_channel(sdata);
2973+
sdata->wdev.cac_started = false;
2974+
}
2975+
}
2976+
mutex_unlock(&local->mtx);
2977+
}
2978+
29572979
static struct cfg80211_beacon_data *
29582980
cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
29592981
{
@@ -4023,6 +4045,7 @@ const struct cfg80211_ops mac80211_config_ops = {
40234045
#endif
40244046
.get_channel = ieee80211_cfg_get_channel,
40254047
.start_radar_detection = ieee80211_start_radar_detection,
4048+
.end_cac = ieee80211_end_cac,
40264049
.channel_switch = ieee80211_channel_switch,
40274050
.set_qos_map = ieee80211_set_qos_map,
40284051
.set_ap_chanwidth = ieee80211_set_ap_chanwidth,

‎net/mac80211/mesh_hwmp.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ u32 airtime_link_metric_get(struct ieee80211_local *local,
328328
unsigned long fail_avg =
329329
ewma_mesh_fail_avg_read(&sta->mesh->fail_avg);
330330

331+
if (sta->mesh->plink_state != NL80211_PLINK_ESTAB)
332+
return MAX_METRIC;
333+
331334
/* Try to get rate based on HW/SW RC algorithm.
332335
* Rate is returned in units of Kbps, correct this
333336
* to comply with airtime calculation units

‎net/mac80211/tkip.c‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,21 @@ int ieee80211_tkip_decrypt_data(struct arc4_ctx *ctx,
263263
if ((keyid >> 6) != key->conf.keyidx)
264264
return TKIP_DECRYPT_INVALID_KEYIDX;
265265

266-
if (rx_ctx->ctx.state != TKIP_STATE_NOT_INIT &&
267-
(iv32 < rx_ctx->iv32 ||
268-
(iv32 == rx_ctx->iv32 && iv16 <= rx_ctx->iv16)))
266+
/* Reject replays if the received TSC is smaller than or equal to the
267+
* last received value in a valid message, but with an exception for
268+
* the case where a new key has been set and no valid frame using that
269+
* key has yet received and the local RSC was initialized to 0. This
270+
* exception allows the very first frame sent by the transmitter to be
271+
* accepted even if that transmitter were to use TSC 0 (IEEE 802.11
272+
* described TSC to be initialized to 1 whenever a new key is taken into
273+
* use).
274+
*/
275+
if (iv32 < rx_ctx->iv32 ||
276+
(iv32 == rx_ctx->iv32 &&
277+
(iv16 < rx_ctx->iv16 ||
278+
(iv16 == rx_ctx->iv16 &&
279+
(rx_ctx->iv32 || rx_ctx->iv16 ||
280+
rx_ctx->ctx.state != TKIP_STATE_NOT_INIT)))))
269281
return TKIP_DECRYPT_REPLAY;
270282

271283
if (only_iv) {

‎net/wireless/nl80211.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10843,6 +10843,7 @@ static int cfg80211_cqm_rssi_update(struct cfg80211_registered_device *rdev,
1084310843
if (err)
1084410844
return err;
1084510845

10846+
cfg80211_sinfo_release_content(&sinfo);
1084610847
if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_BEACON_SIGNAL_AVG))
1084710848
wdev->cqm_config->last_rssi_event_value =
1084810849
(s8) sinfo.rx_beacon_signal_avg;
@@ -13796,6 +13797,8 @@ static int nl80211_probe_mesh_link(struct sk_buff *skb, struct genl_info *info)
1379613797
if (err)
1379713798
return err;
1379813799

13800+
cfg80211_sinfo_release_content(&sinfo);
13801+
1379913802
return rdev_probe_mesh_link(rdev, dev, dest, buf, len);
1380013803
}
1380113804

‎net/wireless/rdev-ops.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,10 @@ static inline int
538538
rdev_set_wiphy_params(struct cfg80211_registered_device *rdev, u32 changed)
539539
{
540540
int ret;
541+
542+
if (!rdev->ops->set_wiphy_params)
543+
return -EOPNOTSUPP;
544+
541545
trace_rdev_set_wiphy_params(&rdev->wiphy, changed);
542546
ret = rdev->ops->set_wiphy_params(&rdev->wiphy, changed);
543547
trace_rdev_return_int(&rdev->wiphy, ret);
@@ -1167,6 +1171,16 @@ rdev_start_radar_detection(struct cfg80211_registered_device *rdev,
11671171
return ret;
11681172
}
11691173

1174+
static inline void
1175+
rdev_end_cac(struct cfg80211_registered_device *rdev,
1176+
struct net_device *dev)
1177+
{
1178+
trace_rdev_end_cac(&rdev->wiphy, dev);
1179+
if (rdev->ops->end_cac)
1180+
rdev->ops->end_cac(&rdev->wiphy, dev);
1181+
trace_rdev_return_void(&rdev->wiphy);
1182+
}
1183+
11701184
static inline int
11711185
rdev_set_mcast_rate(struct cfg80211_registered_device *rdev,
11721186
struct net_device *dev,

‎net/wireless/reg.c‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,14 +2261,15 @@ static void update_all_wiphy_regulatory(enum nl80211_reg_initiator initiator)
22612261

22622262
static void handle_channel_custom(struct wiphy *wiphy,
22632263
struct ieee80211_channel *chan,
2264-
const struct ieee80211_regdomain *regd)
2264+
const struct ieee80211_regdomain *regd,
2265+
u32 min_bw)
22652266
{
22662267
u32 bw_flags = 0;
22672268
const struct ieee80211_reg_rule *reg_rule = NULL;
22682269
const struct ieee80211_power_rule *power_rule = NULL;
22692270
u32 bw;
22702271

2271-
for (bw = MHZ_TO_KHZ(20); bw >= MHZ_TO_KHZ(5); bw = bw / 2) {
2272+
for (bw = MHZ_TO_KHZ(20); bw >= min_bw; bw = bw / 2) {
22722273
reg_rule = freq_reg_info_regd(MHZ_TO_KHZ(chan->center_freq),
22732274
regd, bw);
22742275
if (!IS_ERR(reg_rule))
@@ -2324,8 +2325,14 @@ static void handle_band_custom(struct wiphy *wiphy,
23242325
if (!sband)
23252326
return;
23262327

2328+
/*
2329+
* We currently assume that you always want at least 20 MHz,
2330+
* otherwise channel 12 might get enabled if this rule is
2331+
* compatible to US, which permits 2402 - 2472 MHz.
2332+
*/
23272333
for (i = 0; i < sband->n_channels; i++)
2328-
handle_channel_custom(wiphy, &sband->channels[i], regd);
2334+
handle_channel_custom(wiphy, &sband->channels[i], regd,
2335+
MHZ_TO_KHZ(20));
23292336
}
23302337

23312338
/* Used by drivers prior to wiphy registration */
@@ -3885,6 +3892,25 @@ bool regulatory_pre_cac_allowed(struct wiphy *wiphy)
38853892
}
38863893
EXPORT_SYMBOL(regulatory_pre_cac_allowed);
38873894

3895+
static void cfg80211_check_and_end_cac(struct cfg80211_registered_device *rdev)
3896+
{
3897+
struct wireless_dev *wdev;
3898+
/* If we finished CAC or received radar, we should end any
3899+
* CAC running on the same channels.
3900+
* the check !cfg80211_chandef_dfs_usable contain 2 options:
3901+
* either all channels are available - those the CAC_FINISHED
3902+
* event has effected another wdev state, or there is a channel
3903+
* in unavailable state in wdev chandef - those the RADAR_DETECTED
3904+
* event has effected another wdev state.
3905+
* In both cases we should end the CAC on the wdev.
3906+
*/
3907+
list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
3908+
if (wdev->cac_started &&
3909+
!cfg80211_chandef_dfs_usable(&rdev->wiphy, &wdev->chandef))
3910+
rdev_end_cac(rdev, wdev->netdev);
3911+
}
3912+
}
3913+
38883914
void regulatory_propagate_dfs_state(struct wiphy *wiphy,
38893915
struct cfg80211_chan_def *chandef,
38903916
enum nl80211_dfs_state dfs_state,
@@ -3911,8 +3937,10 @@ void regulatory_propagate_dfs_state(struct wiphy *wiphy,
39113937
cfg80211_set_dfs_state(&rdev->wiphy, chandef, dfs_state);
39123938

39133939
if (event == NL80211_RADAR_DETECTED ||
3914-
event == NL80211_RADAR_CAC_FINISHED)
3940+
event == NL80211_RADAR_CAC_FINISHED) {
39153941
cfg80211_sched_dfs_chan_update(rdev);
3942+
cfg80211_check_and_end_cac(rdev);
3943+
}
39163944

39173945
nl80211_radar_notify(rdev, chandef, event, NULL, GFP_KERNEL);
39183946
}

‎net/wireless/sme.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,14 +1307,14 @@ void cfg80211_autodisconnect_wk(struct work_struct *work)
13071307
if (wdev->conn_owner_nlportid) {
13081308
switch (wdev->iftype) {
13091309
case NL80211_IFTYPE_ADHOC:
1310-
cfg80211_leave_ibss(rdev, wdev->netdev, false);
1310+
__cfg80211_leave_ibss(rdev, wdev->netdev, false);
13111311
break;
13121312
case NL80211_IFTYPE_AP:
13131313
case NL80211_IFTYPE_P2P_GO:
1314-
cfg80211_stop_ap(rdev, wdev->netdev, false);
1314+
__cfg80211_stop_ap(rdev, wdev->netdev, false);
13151315
break;
13161316
case NL80211_IFTYPE_MESH_POINT:
1317-
cfg80211_leave_mesh(rdev, wdev->netdev);
1317+
__cfg80211_leave_mesh(rdev, wdev->netdev);
13181318
break;
13191319
case NL80211_IFTYPE_STATION:
13201320
case NL80211_IFTYPE_P2P_CLIENT:

‎net/wireless/trace.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,11 @@ DEFINE_EVENT(wiphy_netdev_evt, rdev_flush_pmksa,
646646
TP_ARGS(wiphy, netdev)
647647
);
648648

649+
DEFINE_EVENT(wiphy_netdev_evt, rdev_end_cac,
650+
TP_PROTO(struct wiphy *wiphy, struct net_device *netdev),
651+
TP_ARGS(wiphy, netdev)
652+
);
653+
649654
DECLARE_EVENT_CLASS(station_add_change,
650655
TP_PROTO(struct wiphy *wiphy, struct net_device *netdev, u8 *mac,
651656
struct station_parameters *params),

‎net/wireless/util.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ __frame_add_frag(struct sk_buff *skb, struct page *page,
564564
struct skb_shared_info *sh = skb_shinfo(skb);
565565
int page_offset;
566566

567-
page_ref_inc(page);
567+
get_page(page);
568568
page_offset = ptr - page_address(page);
569569
skb_add_rx_frag(skb, sh->nr_frags, page, page_offset, len, size);
570570
}

0 commit comments

Comments
 (0)