Skip to contentSkip to conversation

net: ieee802154: fix nl802154 del llsec key

PATCH In review Alexander Aring 3 participants 10 messages Feb 21, 2021 – Feb 24, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 net: ieee802154: fix nl802154 del llsec key

This patch fixes a nullpointer dereference if NL802154_ATTR_SEC_KEY is not set by the user. If this is the case nl802154 will return -EINVAL.

---
 net/ieee802154/nl802154.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ieee802154/nl802154.c +2 -1
index 7c5a1aa5adb4..2f0a138bd5eb 100644
@@ -1592,7 +1592,8 @@ static int nl802154_del_llsec_key(struct sk_buff *skb, struct genl_info *info)
 	struct nlattr *attrs[NL802154_KEY_ATTR_MAX + 1];
 	struct ieee802154_llsec_key_id id;
 
-	if (nla_parse_nested_deprecated(attrs, NL802154_KEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_KEY], nl802154_key_policy, info->extack))
+	if (!info->attrs[NL802154_ATTR_SEC_KEY] ||
+	    nla_parse_nested_deprecated(attrs, NL802154_KEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_KEY], nl802154_key_policy, info->extack))
 		return -EINVAL;
 
 	if (ieee802154_llsec_parse_key_id(attrs[NL802154_KEY_ATTR_ID], &id) < 0)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 2/4 net: ieee802154: fix nl802154 del llsec dev

This patch fixes a nullpointer dereference if NL802154_ATTR_SEC_DEVICE is not set by the user. If this is the case nl802154 will return -EINVAL.

---
 net/ieee802154/nl802154.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ieee802154/nl802154.c +2 -1
index 2f0a138bd5eb..063b12cba71f 100644
@@ -1758,7 +1758,8 @@ static int nl802154_del_llsec_dev(struct sk_buff *skb, struct genl_info *info)
 	struct nlattr *attrs[NL802154_DEV_ATTR_MAX + 1];
 	__le64 extended_addr;
 
-	if (nla_parse_nested_deprecated(attrs, NL802154_DEV_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_DEVICE], nl802154_dev_policy, info->extack))
+	if (!info->attrs[NL802154_ATTR_SEC_DEVICE] ||
+	    nla_parse_nested_deprecated(attrs, NL802154_DEV_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_DEVICE], nl802154_dev_policy, info->extack))
 		return -EINVAL;
 
 	if (!attrs[NL802154_DEV_ATTR_EXTENDED_ADDR])
Signature · 1 line
2.26.2
maintainer
#2 lore raw

Re: [PATCH wpan 2/4] net: ieee802154: fix nl802154 del llsec dev

Hello.

Quoted 15 lines · Alexander Aring

This patch fixes a nullpointer dereference if NL802154_ATTR_SEC_DEVICE is not set by the user. If this is the case nl802154 will return -EINVAL.

---
  net/ieee802154/nl802154.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
net/ieee802154/nl802154.c +0 -0
index 2f0a138bd5eb..063b12cba71f 100644

net/ieee802154/nl802154.c static int nl802154_del_llsec_dev(struct sk_buff *skb, struct genl_info *info) · line 1765

Quoted 9 lines
net/ieee802154/nl802154.c +2 -1
@@ -1758,7 +1758,8 @@ static int nl802154_del_llsec_dev(struct sk_buff *skb, struct genl_info *info)
  	struct nlattr *attrs[NL802154_DEV_ATTR_MAX + 1];
  	__le64 extended_addr;
 
-	if (nla_parse_nested_deprecated(attrs, NL802154_DEV_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_DEVICE], nl802154_dev_policy, info->extack))
+	if (!info->attrs[NL802154_ATTR_SEC_DEVICE] ||
+	    nla_parse_nested_deprecated(attrs, NL802154_DEV_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_DEVICE], nl802154_dev_policy, info->extack))
  		return -EINVAL;
 
  	if (!attrs[NL802154_DEV_ATTR_EXTENDED_ADDR])

This patch has been applied to the wpan tree and will be part of the next pull request to net. Thanks!

regards
Stefan Schmidt

#3 lore raw

PATCH 3/4 net: ieee802154: fix nl802154 add llsec key

In reply to Alexander Aring

This patch fixes a nullpointer dereference if NL802154_ATTR_SEC_KEY is not set by the user. If this is the case nl802154 will return -EINVAL.

---
 net/ieee802154/nl802154.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ieee802154/nl802154.c +2 -1
index 063b12cba71f..3f6d86d63923 100644
@@ -1544,7 +1544,8 @@ static int nl802154_add_llsec_key(struct sk_buff *skb, struct genl_info *info)
 	struct ieee802154_llsec_key_id id = { };
 	u32 commands[NL802154_CMD_FRAME_NR_IDS / 32] = { };
 
-	if (nla_parse_nested_deprecated(attrs, NL802154_KEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_KEY], nl802154_key_policy, info->extack))
+	if (!info->attrs[NL802154_ATTR_SEC_KEY] ||
+	    nla_parse_nested_deprecated(attrs, NL802154_KEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_KEY], nl802154_key_policy, info->extack))
 		return -EINVAL;
 
 	if (!attrs[NL802154_KEY_ATTR_USAGE_FRAMES] ||
Signature · 1 line
2.26.2
maintainer
#4 lore raw

Re: [PATCH wpan 3/4] net: ieee802154: fix nl802154 add llsec key

Hello.

Quoted 15 lines · Alexander Aring

This patch fixes a nullpointer dereference if NL802154_ATTR_SEC_KEY is not set by the user. If this is the case nl802154 will return -EINVAL.

---
  net/ieee802154/nl802154.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
net/ieee802154/nl802154.c +0 -0
index 063b12cba71f..3f6d86d63923 100644

net/ieee802154/nl802154.c static int nl802154_add_llsec_key(struct sk_buff *skb, struct genl_info *info) · line 1551

Quoted 9 lines
net/ieee802154/nl802154.c +2 -1
@@ -1544,7 +1544,8 @@ static int nl802154_add_llsec_key(struct sk_buff *skb, struct genl_info *info)
  	struct ieee802154_llsec_key_id id = { };
  	u32 commands[NL802154_CMD_FRAME_NR_IDS / 32] = { };
 
-	if (nla_parse_nested_deprecated(attrs, NL802154_KEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_KEY], nl802154_key_policy, info->extack))
+	if (!info->attrs[NL802154_ATTR_SEC_KEY] ||
+	    nla_parse_nested_deprecated(attrs, NL802154_KEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_KEY], nl802154_key_policy, info->extack))
  		return -EINVAL;
 
  	if (!attrs[NL802154_KEY_ATTR_USAGE_FRAMES] ||

This patch has been applied to the wpan tree and will be part of the next pull request to net. Thanks!

regards
Stefan Schmidt

#5 lore raw

PATCH 4/4 net: ieee802154: fix nl802154 del llsec devkey

In reply to Alexander Aring

This patch fixes a nullpointer dereference if NL802154_ATTR_SEC_DEVKEY is not set by the user. If this is the case nl802154 will return -EINVAL.

---
 net/ieee802154/nl802154.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/ieee802154/nl802154.c +2 -1
index 3f6d86d63923..e9e4652cd592 100644
@@ -1916,7 +1916,8 @@ static int nl802154_del_llsec_devkey(struct sk_buff *skb, struct genl_info *info
 	struct ieee802154_llsec_device_key key;
 	__le64 extended_addr;
 
-	if (nla_parse_nested_deprecated(attrs, NL802154_DEVKEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_DEVKEY], nl802154_devkey_policy, info->extack))
+	if (!info->attrs[NL802154_ATTR_SEC_DEVKEY] ||
+	    nla_parse_nested_deprecated(attrs, NL802154_DEVKEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_DEVKEY], nl802154_devkey_policy, info->extack))
 		return -EINVAL;
 
 	if (!attrs[NL802154_DEVKEY_ATTR_EXTENDED_ADDR])
Signature · 1 line
2.26.2
maintainer
#6 lore raw

Re: [PATCH wpan 4/4] net: ieee802154: fix nl802154 del llsec devkey

Hello.

Quoted 15 lines · Alexander Aring

This patch fixes a nullpointer dereference if NL802154_ATTR_SEC_DEVKEY is not set by the user. If this is the case nl802154 will return -EINVAL.

---
  net/ieee802154/nl802154.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
net/ieee802154/nl802154.c +0 -0
index 3f6d86d63923..e9e4652cd592 100644

net/ieee802154/nl802154.c static int nl802154_del_llsec_devkey(struct sk_buff *skb, struct genl_info *info · line 1923

Quoted 9 lines
net/ieee802154/nl802154.c +2 -1
@@ -1916,7 +1916,8 @@ static int nl802154_del_llsec_devkey(struct sk_buff *skb, struct genl_info *info
  	struct ieee802154_llsec_device_key key;
  	__le64 extended_addr;
 
-	if (nla_parse_nested_deprecated(attrs, NL802154_DEVKEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_DEVKEY], nl802154_devkey_policy, info->extack))
+	if (!info->attrs[NL802154_ATTR_SEC_DEVKEY] ||
+	    nla_parse_nested_deprecated(attrs, NL802154_DEVKEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_DEVKEY], nl802154_devkey_policy, info->extack))
  		return -EINVAL;
 
  	if (!attrs[NL802154_DEVKEY_ATTR_EXTENDED_ADDR])

This patch has been applied to the wpan tree and will be part of the next pull request to net. Thanks!

regards
Stefan Schmidt

maintainer
#7 lore raw

Re: [PATCH wpan 4/4] net: ieee802154: fix nl802154 del llsec devkey

In reply to Alexander Aring

Hello.

Quoted 24 lines · Alexander Aring

This patch fixes a nullpointer dereference if NL802154_ATTR_SEC_DEVKEY is not set by the user. If this is the case nl802154 will return -EINVAL.

---
  net/ieee802154/nl802154.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
net/ieee802154/nl802154.c +2 -1
index 3f6d86d63923..e9e4652cd592 100644
@@ -1916,7 +1916,8 @@ static int nl802154_del_llsec_devkey(struct sk_buff *skb, struct genl_info *info
  	struct ieee802154_llsec_device_key key;
  	__le64 extended_addr;
 
-	if (nla_parse_nested_deprecated(attrs, NL802154_DEVKEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_DEVKEY], nl802154_devkey_policy, info->extack))
+	if (!info->attrs[NL802154_ATTR_SEC_DEVKEY] ||
+	    nla_parse_nested_deprecated(attrs, NL802154_DEVKEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_DEVKEY], nl802154_devkey_policy, info->extack))
  		return -EINVAL;
 
  	if (!attrs[NL802154_DEVKEY_ATTR_EXTENDED_ADDR])
maintainer
#8 lore raw
In reply to Alexander Aring
Quoted 5 lines · On Sun, 21 Feb 2021 12:43:18 -0500 Alexander Aring wrote:

This patch fixes a nullpointer dereference if NL802154_ATTR_SEC_KEY is not set by the user. If this is the case nl802154 will return -EINVAL.

Looks like there is a wpan tree, but in recent years Dave just applies ieee802154 patches directly. I'm going to apply these directly as well, please let me know if I shouldn't, or more review time is needed.

maintainer
#9 lore raw
In reply to Alexander Aring

Hello.

Quoted 15 lines · Alexander Aring

This patch fixes a nullpointer dereference if NL802154_ATTR_SEC_KEY is not set by the user. If this is the case nl802154 will return -EINVAL.

---
  net/ieee802154/nl802154.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
net/ieee802154/nl802154.c +0 -0
index 7c5a1aa5adb4..2f0a138bd5eb 100644

net/ieee802154/nl802154.c static int nl802154_del_llsec_key(struct sk_buff *skb, struct genl_info *info) · line 1599

Quoted 9 lines
net/ieee802154/nl802154.c +2 -1
@@ -1592,7 +1592,8 @@ static int nl802154_del_llsec_key(struct sk_buff *skb, struct genl_info *info)
  	struct nlattr *attrs[NL802154_KEY_ATTR_MAX + 1];
  	struct ieee802154_llsec_key_id id;
 
-	if (nla_parse_nested_deprecated(attrs, NL802154_KEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_KEY], nl802154_key_policy, info->extack))
+	if (!info->attrs[NL802154_ATTR_SEC_KEY] ||
+	    nla_parse_nested_deprecated(attrs, NL802154_KEY_ATTR_MAX, info->attrs[NL802154_ATTR_SEC_KEY], nl802154_key_policy, info->extack))
  		return -EINVAL;
 
  	if (ieee802154_llsec_parse_key_id(attrs[NL802154_KEY_ATTR_ID], &id) < 0)

This patch has been applied to the wpan tree and will be part of the next pull request to net. Thanks!

regards
Stefan Schmidt