Commit f8af764b authored by Jouni Malinen's avatar Jouni Malinen Committed by Johannes Berg

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: default avatarJouni Malinen <jouni@codeaurora.org>
Link: https://lore.kernel.org/r/20200222132548.20835-1-jouni@codeaurora.orgSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent cd9b52bf
...@@ -3978,8 +3978,10 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info) ...@@ -3978,8 +3978,10 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
if (err) if (err)
return err; return err;
if (!key.p.key) if (!key.p.key) {
GENL_SET_ERR_MSG(info, "no key");
return -EINVAL; return -EINVAL;
}
if (info->attrs[NL80211_ATTR_MAC]) if (info->attrs[NL80211_ATTR_MAC])
mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); 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) ...@@ -3993,8 +3995,10 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
/* for now */ /* for now */
if (key.type != NL80211_KEYTYPE_PAIRWISE && if (key.type != NL80211_KEYTYPE_PAIRWISE &&
key.type != NL80211_KEYTYPE_GROUP) key.type != NL80211_KEYTYPE_GROUP) {
GENL_SET_ERR_MSG(info, "key type not pairwise or group");
return -EINVAL; return -EINVAL;
}
if (key.type == NL80211_KEYTYPE_GROUP && if (key.type == NL80211_KEYTYPE_GROUP &&
info->attrs[NL80211_ATTR_VLAN_ID]) info->attrs[NL80211_ATTR_VLAN_ID])
...@@ -4005,15 +4009,22 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info) ...@@ -4005,15 +4009,22 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info)
if (cfg80211_validate_key_settings(rdev, &key.p, key.idx, if (cfg80211_validate_key_settings(rdev, &key.p, key.idx,
key.type == NL80211_KEYTYPE_PAIRWISE, key.type == NL80211_KEYTYPE_PAIRWISE,
mac_addr)) mac_addr)) {
GENL_SET_ERR_MSG(info, "key setting validation failed");
return -EINVAL; return -EINVAL;
}
wdev_lock(dev->ieee80211_ptr); wdev_lock(dev->ieee80211_ptr);
err = nl80211_key_allowed(dev->ieee80211_ptr); err = nl80211_key_allowed(dev->ieee80211_ptr);
if (!err) if (err)
GENL_SET_ERR_MSG(info, "key not allowed");
if (!err) {
err = rdev_add_key(rdev, dev, key.idx, err = rdev_add_key(rdev, dev, key.idx,
key.type == NL80211_KEYTYPE_PAIRWISE, key.type == NL80211_KEYTYPE_PAIRWISE,
mac_addr, &key.p); mac_addr, &key.p);
if (err)
GENL_SET_ERR_MSG(info, "key addition failed");
}
wdev_unlock(dev->ieee80211_ptr); wdev_unlock(dev->ieee80211_ptr);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment