Skip to content

Commit 538c9eb

Browse files
committed
cfg80211: clear wext keys when freeing and removing them
When freeing the keys stored for wireless extensions, clear the memory to avoid having the key material stick around in memory "forever". Similarly, when userspace overwrites a key, actually clear it instead of just setting the key length to zero. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 29c3f9c commit 538c9eb

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎net/wireless/core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
10071007
rdev->devlist_generation++;
10081008
cfg80211_mlme_purge_registrations(wdev);
10091009
#ifdef CONFIG_CFG80211_WEXT
1010-
kfree(wdev->wext.keys);
1010+
kzfree(wdev->wext.keys);
10111011
#endif
10121012
}
10131013
/*

‎net/wireless/wext-compat.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
496496
err = 0;
497497
if (!err) {
498498
if (!addr) {
499+
memset(wdev->wext.keys->data[idx], 0,
500+
sizeof(wdev->wext.keys->data[idx]));
499501
wdev->wext.keys->params[idx].key_len = 0;
500502
wdev->wext.keys->params[idx].cipher = 0;
501503
}

0 commit comments

Comments
 (0)