cfg80211: clear connect keys when freeing them
authorJohannes Berg <johannes.berg@intel.com>
Wed, 10 Sep 2014 10:39:54 +0000 (13:39 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 11 Sep 2014 10:07:18 +0000 (12:07 +0200)
When freeing the connect keys, clear the memory to avoid
having the key material stick around in memory "forever".

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/ibss.c
net/wireless/nl80211.c
net/wireless/sme.c
net/wireless/util.c
net/wireless/wext-sme.c

index 8f345da3ea5f4e0767ae6b1de539f18954707148..e24fc585c8834782295558481f0f592be743e6dc 100644 (file)
@@ -115,7 +115,7 @@ static int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
        }
 
        if (WARN_ON(wdev->connect_keys))
-               kfree(wdev->connect_keys);
+               kzfree(wdev->connect_keys);
        wdev->connect_keys = connkeys;
 
        wdev->ibss_fixed = params->channel_fixed;
@@ -161,7 +161,7 @@ static void __cfg80211_clear_ibss(struct net_device *dev, bool nowext)
 
        ASSERT_WDEV_LOCK(wdev);
 
-       kfree(wdev->connect_keys);
+       kzfree(wdev->connect_keys);
        wdev->connect_keys = NULL;
 
        rdev_set_qos_map(rdev, dev, NULL);
index cf178d2b621da5f7c6838684267505f7889bb192..e388a9f2889504511dc0e9880e30b654ff6ba4be 100644 (file)
@@ -6866,7 +6866,7 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
 
        err = cfg80211_join_ibss(rdev, dev, &ibss, connkeys);
        if (err)
-               kfree(connkeys);
+               kzfree(connkeys);
        return err;
 }
 
@@ -7235,7 +7235,7 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
 
        if (info->attrs[NL80211_ATTR_HT_CAPABILITY]) {
                if (!info->attrs[NL80211_ATTR_HT_CAPABILITY_MASK]) {
-                       kfree(connkeys);
+                       kzfree(connkeys);
                        return -EINVAL;
                }
                memcpy(&connect.ht_capa,
@@ -7253,7 +7253,7 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
 
        if (info->attrs[NL80211_ATTR_VHT_CAPABILITY]) {
                if (!info->attrs[NL80211_ATTR_VHT_CAPABILITY_MASK]) {
-                       kfree(connkeys);
+                       kzfree(connkeys);
                        return -EINVAL;
                }
                memcpy(&connect.vht_capa,
@@ -7273,7 +7273,7 @@ static int nl80211_connect(struct sk_buff *skb, struct genl_info *info)
        err = cfg80211_connect(rdev, dev, &connect, connkeys, NULL);
        wdev_unlock(dev->ieee80211_ptr);
        if (err)
-               kfree(connkeys);
+               kzfree(connkeys);
        return err;
 }
 
index 8bbeeb302216223a260085634bf6b5627c209783..dc1668ff543b90927d9cb4e08b38897ac8e97f6c 100644 (file)
@@ -641,7 +641,7 @@ void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid,
        }
 
        if (status != WLAN_STATUS_SUCCESS) {
-               kfree(wdev->connect_keys);
+               kzfree(wdev->connect_keys);
                wdev->connect_keys = NULL;
                wdev->ssid_len = 0;
                if (bss) {
@@ -918,7 +918,7 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev,
        ASSERT_WDEV_LOCK(wdev);
 
        if (WARN_ON(wdev->connect_keys)) {
-               kfree(wdev->connect_keys);
+               kzfree(wdev->connect_keys);
                wdev->connect_keys = NULL;
        }
 
@@ -978,7 +978,7 @@ int cfg80211_disconnect(struct cfg80211_registered_device *rdev,
 
        ASSERT_WDEV_LOCK(wdev);
 
-       kfree(wdev->connect_keys);
+       kzfree(wdev->connect_keys);
        wdev->connect_keys = NULL;
 
        if (wdev->conn)
index a8b2816ffcb906edb46c76460476055e68f96157..5e233a577d0fcd15e39b5eebc5678598c37637df 100644 (file)
@@ -797,7 +797,7 @@ void cfg80211_upload_connect_keys(struct wireless_dev *wdev)
                                netdev_err(dev, "failed to set mgtdef %d\n", i);
        }
 
-       kfree(wdev->connect_keys);
+       kzfree(wdev->connect_keys);
        wdev->connect_keys = NULL;
 }
 
index c7e5c8eb4f24708a27d90ae298a85c825ee81e38..368611c0573997e45f433c68a0a2c0e9de17270b 100644 (file)
@@ -57,7 +57,7 @@ int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev,
        err = cfg80211_connect(rdev, wdev->netdev,
                               &wdev->wext.connect, ck, prev_bssid);
        if (err)
-               kfree(ck);
+               kzfree(ck);
 
        return err;
 }