Skip to content

Commit f8af764

Browse files
Jouni Malinenjmberg-intel
authored andcommitted
cfg80211: More error messages for key addition failures
These were helpful while working with extensions to NL80211_CMD_NEW_KEY, so add more explicit error reporting for additional cases that can fail while that command is being processed. Signed-off-by: Jouni Malinen <jouni@codeaurora.org> Link: https://lore.kernel.org/r/20200222132548.20835-1-jouni@codeaurora.org Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent cd9b52b commit f8af764

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

‎net/wireless/nl80211.c‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3978,8 +3978,10 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
39783978
if (err)
39793979
return err;
39803980

3981-
if (!key.p.key)
3981+
if (!key.p.key) {
3982+
GENL_SET_ERR_MSG(info, "no key");
39823983
return -EINVAL;
3984+
}
39833985

39843986
if (info->attrs[NL80211_ATTR_MAC])
39853987
mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
@@ -3993,8 +3995,10 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
39933995

39943996
/* for now */
39953997
if (key.type != NL80211_KEYTYPE_PAIRWISE &&
3996-
key.type != NL80211_KEYTYPE_GROUP)
3998+
key.type != NL80211_KEYTYPE_GROUP) {
3999+
GENL_SET_ERR_MSG(info, "key type not pairwise or group");
39974000
return -EINVAL;
4001+
}
39984002

39994003
if (key.type == NL80211_KEYTYPE_GROUP &&
40004004
info->attrs[NL80211_ATTR_VLAN_ID])
@@ -4005,15 +4009,22 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
40054009

40064010
if (cfg80211_validate_key_settings(rdev, &key.p, key.idx,
40074011
key.type == NL80211_KEYTYPE_PAIRWISE,
4008-
mac_addr))
4012+
mac_addr)) {
4013+
GENL_SET_ERR_MSG(info, "key setting validation failed");
40094014
return -EINVAL;
4015+
}
40104016

40114017
wdev_lock(dev->ieee80211_ptr);
40124018
err = nl80211_key_allowed(dev->ieee80211_ptr);
4013-
if (!err)
4019+
if (err)
4020+
GENL_SET_ERR_MSG(info, "key not allowed");
4021+
if (!err) {
40144022
err = rdev_add_key(rdev, dev, key.idx,
40154023
key.type == NL80211_KEYTYPE_PAIRWISE,
40164024
mac_addr, &key.p);
4025+
if (err)
4026+
GENL_SET_ERR_MSG(info, "key addition failed");
4027+
}
40174028
wdev_unlock(dev->ieee80211_ptr);
40184029

40194030
return err;

0 commit comments

Comments
 (0)