Skip to content

Commit 208c72f

Browse files
Luciano Coelholinvjw
authored andcommitted
nl80211: fix check for valid SSID size in scan operations
In both trigger_scan and sched_scan operations, we were checking for the SSID length before assigning the value correctly. Since the memory was just kzalloc'ed, the check was always failing and SSID with over 32 characters were allowed to go through. This was causing a buffer overflow when copying the actual SSID to the proper place. This bug has been there since 2.6.29-rc4. Cc: stable@kernel.org Signed-off-by: Luciano Coelho <coelho@ti.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 21bc7af commit 208c72f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/wireless/nl80211.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3406,12 +3406,12 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
34063406
i = 0;
34073407
if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) {
34083408
nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp) {
3409+
request->ssids[i].ssid_len = nla_len(attr);
34093410
if (request->ssids[i].ssid_len > IEEE80211_MAX_SSID_LEN) {
34103411
err = -EINVAL;
34113412
goto out_free;
34123413
}
34133414
memcpy(request->ssids[i].ssid, nla_data(attr), nla_len(attr));
3414-
request->ssids[i].ssid_len = nla_len(attr);
34153415
i++;
34163416
}
34173417
}
@@ -3572,14 +3572,14 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
35723572
if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) {
35733573
nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS],
35743574
tmp) {
3575+
request->ssids[i].ssid_len = nla_len(attr);
35753576
if (request->ssids[i].ssid_len >
35763577
IEEE80211_MAX_SSID_LEN) {
35773578
err = -EINVAL;
35783579
goto out_free;
35793580
}
35803581
memcpy(request->ssids[i].ssid, nla_data(attr),
35813582
nla_len(attr));
3582-
request->ssids[i].ssid_len = nla_len(attr);
35833583
i++;
35843584
}
35853585
}

0 commit comments

Comments
 (0)