]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
nl80211: fix check for valid SSID size in scan operations
authorLuciano Coelho <coelho@ti.com>
Wed, 18 May 2011 21:43:38 +0000 (00:43 +0300)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 26 May 2011 19:43:28 +0000 (15:43 -0400)
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>
net/wireless/nl80211.c

index ec83f413a7ed19d41b3a37a0a7e0b1d7b1ce9988..88a565f130a5a2e2e0f72fca3c204505a810a652 100644 (file)
@@ -3406,12 +3406,12 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
        i = 0;
        if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) {
                nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS], tmp) {
+                       request->ssids[i].ssid_len = nla_len(attr);
                        if (request->ssids[i].ssid_len > IEEE80211_MAX_SSID_LEN) {
                                err = -EINVAL;
                                goto out_free;
                        }
                        memcpy(request->ssids[i].ssid, nla_data(attr), nla_len(attr));
-                       request->ssids[i].ssid_len = nla_len(attr);
                        i++;
                }
        }
@@ -3572,6 +3572,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
        if (info->attrs[NL80211_ATTR_SCAN_SSIDS]) {
                nla_for_each_nested(attr, info->attrs[NL80211_ATTR_SCAN_SSIDS],
                                    tmp) {
+                       request->ssids[i].ssid_len = nla_len(attr);
                        if (request->ssids[i].ssid_len >
                            IEEE80211_MAX_SSID_LEN) {
                                err = -EINVAL;
@@ -3579,7 +3580,6 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
                        }
                        memcpy(request->ssids[i].ssid, nla_data(attr),
                               nla_len(attr));
-                       request->ssids[i].ssid_len = nla_len(attr);
                        i++;
                }
        }