* [PATCH] mac80211: make ieee802_11_parse_elems return void
@ 2007-10-17 2:38 John W. Linville
2007-10-17 3:17 ` Michael Wu
2007-10-17 8:15 ` Johannes Berg
0 siblings, 2 replies; 6+ messages in thread
From: John W. Linville @ 2007-10-17 2:38 UTC (permalink / raw)
To: linux-wireless; +Cc: John W. Linville
Some APs send management frames with junk padding after the last IE.
We already account for a similar problem with some Apple Airport
devices, but at least one device is known to send more than a single
extra byte. The device in question is the Draytek Vigor2900:
http://www.draytek.com.au/products/Vigor2900.php
The junk in question looks like an IE that runs off the end of the
frame. This cause us to return ParseFailed. Since the frame in
question is an association response, this causes us to fail to associate
with this AP.
The return code from ieee802_11_parse_elems is superfluous.
All callers still check for the presence of the specific IEs that
interest them anyway. So, remove the return code so the parse never
"fails".
Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
net/mac80211/ieee80211_sta.c | 53 ++++++++----------------------------------
1 files changed, 10 insertions(+), 43 deletions(-)
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
index db81aef..7f873b3 100644
--- a/net/mac80211/ieee80211_sta.c
+++ b/net/mac80211/ieee80211_sta.c
@@ -108,14 +108,11 @@ struct ieee802_11_elems {
u8 wmm_param_len;
};
-enum ParseRes { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 };
-
-static enum ParseRes ieee802_11_parse_elems(u8 *start, size_t len,
- struct ieee802_11_elems *elems)
+static void ieee802_11_parse_elems(u8 *start, size_t len,
+ struct ieee802_11_elems *elems)
{
size_t left = len;
u8 *pos = start;
- int unknown = 0;
memset(elems, 0, sizeof(*elems));
@@ -126,15 +123,8 @@ static enum ParseRes ieee802_11_parse_elems(u8 *start, size_t len,
elen = *pos++;
left -= 2;
- if (elen > left) {
-#if 0
- if (net_ratelimit())
- printk(KERN_DEBUG "IEEE 802.11 element parse "
- "failed (id=%d elen=%d left=%d)\n",
- id, elen, left);
-#endif
- return ParseFailed;
- }
+ if (elen > left)
+ return;
switch (id) {
case WLAN_EID_SSID:
@@ -201,12 +191,6 @@ static enum ParseRes ieee802_11_parse_elems(u8 *start, size_t len,
elems->ext_supp_rates_len = elen;
break;
default:
-#if 0
- printk(KERN_DEBUG "IEEE 802.11 element parse ignored "
- "unknown element (id=%d elen=%d)\n",
- id, elen);
-#endif
- unknown++;
break;
}
@@ -214,10 +198,7 @@ static enum ParseRes ieee802_11_parse_elems(u8 *start, size_t len,
pos += elen;
}
- /* Do not trigger error if left == 1 as Apple Airport base stations
- * send AssocResps that are one spurious byte too long. */
-
- return unknown ? ParseUnknown : ParseOK;
+ return;
}
@@ -931,12 +912,7 @@ static void ieee80211_auth_challenge(struct net_device *dev,
printk(KERN_DEBUG "%s: replying to auth challenge\n", dev->name);
pos = mgmt->u.auth.variable;
- if (ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems)
- == ParseFailed) {
- printk(KERN_DEBUG "%s: failed to parse Auth(challenge)\n",
- dev->name);
- return;
- }
+ ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
if (!elems.challenge) {
printk(KERN_DEBUG "%s: no challenge IE in shared key auth "
"frame\n", dev->name);
@@ -1230,12 +1206,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct net_device *dev,
aid &= ~(BIT(15) | BIT(14));
pos = mgmt->u.assoc_resp.variable;
- if (ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems)
- == ParseFailed) {
- printk(KERN_DEBUG "%s: failed to parse AssocResp\n",
- dev->name);
- return;
- }
+ ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
if (!elems.supp_rates) {
printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n",
@@ -1459,7 +1430,7 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
struct ieee802_11_elems elems;
size_t baselen;
- int channel, invalid = 0, clen;
+ int channel, clen;
struct ieee80211_sta_bss *bss;
struct sta_info *sta;
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
@@ -1505,9 +1476,7 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
#endif /* CONFIG_MAC80211_IBSS_DEBUG */
}
- if (ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen,
- &elems) == ParseFailed)
- invalid = 1;
+ ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems);
if (sdata->type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates &&
memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 &&
@@ -1724,9 +1693,7 @@ static void ieee80211_rx_mgmt_beacon(struct net_device *dev,
if (baselen > len)
return;
- if (ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen,
- &elems) == ParseFailed)
- return;
+ ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems);
if (elems.erp_info && elems.erp_info_len >= 1)
ieee80211_handle_erp_ie(dev, elems.erp_info[0]);
--
1.5.2.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mac80211: make ieee802_11_parse_elems return void
2007-10-17 2:38 [PATCH] mac80211: make ieee802_11_parse_elems return void John W. Linville
@ 2007-10-17 3:17 ` Michael Wu
2007-10-17 8:15 ` Johannes Berg
1 sibling, 0 replies; 6+ messages in thread
From: Michael Wu @ 2007-10-17 3:17 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 951 bytes --]
On Tuesday 16 October 2007 22:38:43 John W. Linville wrote:
> Some APs send management frames with junk padding after the last IE.
> We already account for a similar problem with some Apple Airport
> devices, but at least one device is known to send more than a single
> extra byte. The device in question is the Draytek Vigor2900:
>
> http://www.draytek.com.au/products/Vigor2900.php
>
> The junk in question looks like an IE that runs off the end of the
> frame. This cause us to return ParseFailed. Since the frame in
> question is an association response, this causes us to fail to associate
> with this AP.
>
> The return code from ieee802_11_parse_elems is superfluous.
> All callers still check for the presence of the specific IEs that
> interest them anyway. So, remove the return code so the parse never
> "fails".
>
> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Acked-by: Michael Wu <flamingice@sourmilk.net>
-Michael Wu
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mac80211: make ieee802_11_parse_elems return void
2007-10-17 2:38 [PATCH] mac80211: make ieee802_11_parse_elems return void John W. Linville
2007-10-17 3:17 ` Michael Wu
@ 2007-10-17 8:15 ` Johannes Berg
2007-10-17 14:04 ` John W. Linville
1 sibling, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2007-10-17 8:15 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 308 bytes --]
On Tue, 2007-10-16 at 22:38 -0400, John W. Linville wrote:
Looks good to me, but
> - /* Do not trigger error if left == 1 as Apple Airport base stations
> - * send AssocResps that are one spurious byte too long. */
> -
> - return unknown ? ParseUnknown : ParseOK;
> + return;
huh?
johannes
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mac80211: make ieee802_11_parse_elems return void
2007-10-17 8:15 ` Johannes Berg
@ 2007-10-17 14:04 ` John W. Linville
2007-10-18 11:56 ` Johannes Berg
0 siblings, 1 reply; 6+ messages in thread
From: John W. Linville @ 2007-10-17 14:04 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless
On Wed, Oct 17, 2007 at 10:15:11AM +0200, Johannes Berg wrote:
> On Tue, 2007-10-16 at 22:38 -0400, John W. Linville wrote:
>
> Looks good to me, but
>
> > - /* Do not trigger error if left == 1 as Apple Airport base stations
> > - * send AssocResps that are one spurious byte too long. */
> > -
> > - return unknown ? ParseUnknown : ParseOK;
> > + return;
>
> huh?
You don't like the bare return at the end? Or are you questioning
something else?
John
--
John W. Linville
linville@tuxdriver.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mac80211: make ieee802_11_parse_elems return void
2007-10-17 14:04 ` John W. Linville
@ 2007-10-18 11:56 ` Johannes Berg
0 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2007-10-18 11:56 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
[-- Attachment #1: Type: text/plain, Size: 636 bytes --]
On Wed, 2007-10-17 at 10:04 -0400, John W. Linville wrote:
> On Wed, Oct 17, 2007 at 10:15:11AM +0200, Johannes Berg wrote:
> > On Tue, 2007-10-16 at 22:38 -0400, John W. Linville wrote:
> >
> > Looks good to me, but
> >
> > > - /* Do not trigger error if left == 1 as Apple Airport base stations
> > > - * send AssocResps that are one spurious byte too long. */
> > > -
> > > - return unknown ? ParseUnknown : ParseOK;
> > > + return;
> >
> > huh?
>
> You don't like the bare return at the end? Or are you questioning
> something else?
Bare return at the end of a void functions seems.. pointless.
johannes
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] mac80211: make ieee802_11_parse_elems return void
2007-10-26 21:04 ` [PATCH] mac80211: only honor IW_SCAN_THIS_ESSID in STA, IBSS, and AP modes John W. Linville
@ 2007-10-26 21:04 ` John W. Linville
0 siblings, 0 replies; 6+ messages in thread
From: John W. Linville @ 2007-10-26 21:04 UTC (permalink / raw)
To: stable; +Cc: linux-wireless, John W. Linville
From: John W. Linville <linville@tuxdriver.com>
Some APs send management frames with junk padding after the last IE.
We already account for a similar problem with some Apple Airport
devices, but at least one device is known to send more than a single
extra byte. The device in question is the Draytek Vigor2900:
http://www.draytek.com.au/products/Vigor2900.php
The junk in question looks like an IE that runs off the end of the
frame. This cause us to return ParseFailed. Since the frame in
question is an association response, this causes us to fail to associate
with this AP.
The return code from ieee802_11_parse_elems is superfluous.
All callers still check for the presence of the specific IEs that
interest them anyway. So, remove the return code so the parse never
"fails".
Acked-by: Michael Wu <flamingice@sourmilk.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
net/mac80211/ieee80211_sta.c | 56 ++++++-----------------------------------
1 files changed, 9 insertions(+), 47 deletions(-)
diff --git a/net/mac80211/ieee80211_sta.c b/net/mac80211/ieee80211_sta.c
index e78b51e..73d39e1 100644
--- a/net/mac80211/ieee80211_sta.c
+++ b/net/mac80211/ieee80211_sta.c
@@ -108,15 +108,11 @@ struct ieee802_11_elems {
u8 wmm_param_len;
};
-typedef enum { ParseOK = 0, ParseUnknown = 1, ParseFailed = -1 } ParseRes;
-
-
-static ParseRes ieee802_11_parse_elems(u8 *start, size_t len,
- struct ieee802_11_elems *elems)
+static void ieee802_11_parse_elems(u8 *start, size_t len,
+ struct ieee802_11_elems *elems)
{
size_t left = len;
u8 *pos = start;
- int unknown = 0;
memset(elems, 0, sizeof(*elems));
@@ -127,15 +123,8 @@ static ParseRes ieee802_11_parse_elems(u8 *start, size_t len,
elen = *pos++;
left -= 2;
- if (elen > left) {
-#if 0
- if (net_ratelimit())
- printk(KERN_DEBUG "IEEE 802.11 element parse "
- "failed (id=%d elen=%d left=%d)\n",
- id, elen, left);
-#endif
- return ParseFailed;
- }
+ if (elen > left)
+ return;
switch (id) {
case WLAN_EID_SSID:
@@ -202,28 +191,15 @@ static ParseRes ieee802_11_parse_elems(u8 *start, size_t len,
elems->ext_supp_rates_len = elen;
break;
default:
-#if 0
- printk(KERN_DEBUG "IEEE 802.11 element parse ignored "
- "unknown element (id=%d elen=%d)\n",
- id, elen);
-#endif
- unknown++;
break;
}
left -= elen;
pos += elen;
}
-
- /* Do not trigger error if left == 1 as Apple Airport base stations
- * send AssocResps that are one spurious byte too long. */
-
- return unknown ? ParseUnknown : ParseOK;
}
-
-
static int ecw2cw(int ecw)
{
int cw = 1;
@@ -907,12 +883,7 @@ static void ieee80211_auth_challenge(struct net_device *dev,
printk(KERN_DEBUG "%s: replying to auth challenge\n", dev->name);
pos = mgmt->u.auth.variable;
- if (ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems)
- == ParseFailed) {
- printk(KERN_DEBUG "%s: failed to parse Auth(challenge)\n",
- dev->name);
- return;
- }
+ ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
if (!elems.challenge) {
printk(KERN_DEBUG "%s: no challenge IE in shared key auth "
"frame\n", dev->name);
@@ -1200,12 +1171,7 @@ static void ieee80211_rx_mgmt_assoc_resp(struct net_device *dev,
aid &= ~(BIT(15) | BIT(14));
pos = mgmt->u.assoc_resp.variable;
- if (ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems)
- == ParseFailed) {
- printk(KERN_DEBUG "%s: failed to parse AssocResp\n",
- dev->name);
- return;
- }
+ ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems);
if (!elems.supp_rates) {
printk(KERN_DEBUG "%s: no SuppRates element in AssocResp\n",
@@ -1434,7 +1400,7 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
struct ieee802_11_elems elems;
size_t baselen;
- int channel, invalid = 0, clen;
+ int channel, clen;
struct ieee80211_sta_bss *bss;
struct sta_info *sta;
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
@@ -1478,9 +1444,7 @@ static void ieee80211_rx_bss_info(struct net_device *dev,
#endif /* CONFIG_MAC80211_IBSS_DEBUG */
}
- if (ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen,
- &elems) == ParseFailed)
- invalid = 1;
+ ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems);
if (sdata->type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates &&
memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 &&
@@ -1699,9 +1663,7 @@ static void ieee80211_rx_mgmt_beacon(struct net_device *dev,
if (baselen > len)
return;
- if (ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen,
- &elems) == ParseFailed)
- return;
+ ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems);
if (elems.erp_info && elems.erp_info_len >= 1)
ieee80211_handle_erp_ie(dev, elems.erp_info[0]);
--
1.5.2.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-10-26 21:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-17 2:38 [PATCH] mac80211: make ieee802_11_parse_elems return void John W. Linville
2007-10-17 3:17 ` Michael Wu
2007-10-17 8:15 ` Johannes Berg
2007-10-17 14:04 ` John W. Linville
2007-10-18 11:56 ` Johannes Berg
-- strict thread matches above, loose matches on Subject: below --
2007-10-26 21:04 [PATCH] Add get_unaligned to ieee80211_get_radiotap_len John W. Linville
2007-10-26 21:04 ` [PATCH] Improve sanity checks on injected packets John W. Linville
2007-10-26 21:04 ` [PATCH] mac80211: filter locally-originated multicast frames John W. Linville
2007-10-26 21:04 ` [PATCH] libertas: fix endianness breakage John W. Linville
2007-10-26 21:04 ` [PATCH] libertas: more " John W. Linville
2007-10-26 21:04 ` [PATCH] ieee80211: fix TKIP QoS bug John W. Linville
2007-10-26 21:04 ` [PATCH] mac80211: reorder association debug output John W. Linville
2007-10-26 21:04 ` [PATCH] mac80211: store channel info in sta_bss_list John W. Linville
2007-10-26 21:04 ` [PATCH] mac80211: store SSID " John W. Linville
2007-10-26 21:04 ` [PATCH] mac80211: honor IW_SCAN_THIS_ESSID in siwscan ioctl John W. Linville
2007-10-26 21:04 ` [PATCH] mac80211: only honor IW_SCAN_THIS_ESSID in STA, IBSS, and AP modes John W. Linville
2007-10-26 21:04 ` [PATCH] mac80211: make ieee802_11_parse_elems return void John W. Linville
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).