Skip to content

Commit 333ba73

Browse files
elplinvjw
authored andcommitted
cfg80211: don't drop p2p probe responses
Commit 0a35d36 ("cfg80211: Use capability info to detect mesh beacons") assumed that probe response with both ESS and IBSS bits cleared means that the frame was sent by a mesh sta. However, these capabilities are also being used in the p2p_find phase, and the mesh-validation broke it. Rename the WLAN_CAPABILITY_IS_MBSS macro, and verify that mesh ies exist before assuming this frame was sent by a mesh sta. Signed-off-by: Eliad Peller <eliad@wizery.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 1144181 commit 333ba73

2 files changed

Lines changed: 30 additions & 21 deletions

File tree

‎include/linux/ieee80211.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,12 @@ struct ieee80211_ht_info {
10031003
#define WLAN_CAPABILITY_ESS (1<<0)
10041004
#define WLAN_CAPABILITY_IBSS (1<<1)
10051005

1006-
/* A mesh STA sets the ESS and IBSS capability bits to zero */
1007-
#define WLAN_CAPABILITY_IS_MBSS(cap) \
1006+
/*
1007+
* A mesh STA sets the ESS and IBSS capability bits to zero.
1008+
* however, this holds true for p2p probe responses (in the p2p_find
1009+
* phase) as well.
1010+
*/
1011+
#define WLAN_CAPABILITY_IS_STA_BSS(cap) \
10081012
(!((cap) & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)))
10091013

10101014
#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)

‎net/wireless/scan.c‎

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,35 @@ static bool is_bss(struct cfg80211_bss *a,
267267
return memcmp(ssidie + 2, ssid, ssid_len) == 0;
268268
}
269269

270+
static bool is_mesh_bss(struct cfg80211_bss *a)
271+
{
272+
const u8 *ie;
273+
274+
if (!WLAN_CAPABILITY_IS_STA_BSS(a->capability))
275+
return false;
276+
277+
ie = cfg80211_find_ie(WLAN_EID_MESH_ID,
278+
a->information_elements,
279+
a->len_information_elements);
280+
if (!ie)
281+
return false;
282+
283+
ie = cfg80211_find_ie(WLAN_EID_MESH_CONFIG,
284+
a->information_elements,
285+
a->len_information_elements);
286+
if (!ie)
287+
return false;
288+
289+
return true;
290+
}
291+
270292
static bool is_mesh(struct cfg80211_bss *a,
271293
const u8 *meshid, size_t meshidlen,
272294
const u8 *meshcfg)
273295
{
274296
const u8 *ie;
275297

276-
if (!WLAN_CAPABILITY_IS_MBSS(a->capability))
298+
if (!WLAN_CAPABILITY_IS_STA_BSS(a->capability))
277299
return false;
278300

279301
ie = cfg80211_find_ie(WLAN_EID_MESH_ID,
@@ -311,7 +333,7 @@ static int cmp_bss(struct cfg80211_bss *a,
311333
if (a->channel != b->channel)
312334
return b->channel->center_freq - a->channel->center_freq;
313335

314-
if (WLAN_CAPABILITY_IS_MBSS(a->capability | b->capability)) {
336+
if (is_mesh_bss(a) && is_mesh_bss(b)) {
315337
r = cmp_ies(WLAN_EID_MESH_ID,
316338
a->information_elements,
317339
a->len_information_elements,
@@ -457,7 +479,6 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev,
457479
struct cfg80211_internal_bss *res)
458480
{
459481
struct cfg80211_internal_bss *found = NULL;
460-
const u8 *meshid, *meshcfg;
461482

462483
/*
463484
* The reference to "res" is donated to this function.
@@ -470,22 +491,6 @@ cfg80211_bss_update(struct cfg80211_registered_device *dev,
470491

471492
res->ts = jiffies;
472493

473-
if (WLAN_CAPABILITY_IS_MBSS(res->pub.capability)) {
474-
/* must be mesh, verify */
475-
meshid = cfg80211_find_ie(WLAN_EID_MESH_ID,
476-
res->pub.information_elements,
477-
res->pub.len_information_elements);
478-
meshcfg = cfg80211_find_ie(WLAN_EID_MESH_CONFIG,
479-
res->pub.information_elements,
480-
res->pub.len_information_elements);
481-
if (!meshid || !meshcfg ||
482-
meshcfg[1] != sizeof(struct ieee80211_meshconf_ie)) {
483-
/* bogus mesh */
484-
kref_put(&res->ref, bss_release);
485-
return NULL;
486-
}
487-
}
488-
489494
spin_lock_bh(&dev->bss_lock);
490495

491496
found = rb_find_bss(dev, res);

0 commit comments

Comments
 (0)