Skip to contentSkip to conversation

net: ieee802154: forbid sec params for monitors

PATCH RESEND In review Alexander Aring 3 participants 18 messages Apr 5, 2021 – Apr 6, 2021

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

cover net: ieee802154: forbid sec params for monitors

Hi,

this patch series contains fixes to forbid various security parameters settings for monitor types. Monitor types doesn't use the llsec security currently and we don't support it. With this patch series the user will be notified with a EOPNOTSUPP error that for monitor interfaces security is not supported yet. However there might be a possibility in future that the kernel will decrypt frames with llsec information for sniffing frames and deliver plaintext to userspace, but this isn't supported yet.

- Alex

Alexander Aring (15):
net: ieee802154: nl-mac: fix check on panid
net: ieee802154: forbid monitor for set llsec params
net: ieee802154: stop dump llsec keys for monitors
net: ieee802154: forbid monitor for add llsec key
net: ieee802154: forbid monitor for del llsec key
net: ieee802154: stop dump llsec devs for monitors
net: ieee802154: forbid monitor for add llsec dev
net: ieee802154: forbid monitor for del llsec dev
net: ieee802154: stop dump llsec devkeys for monitors
net: ieee802154: forbid monitor for add llsec devkey
net: ieee802154: forbid monitor for del llsec devkey
net: ieee802154: stop dump llsec seclevels for monitors
net: ieee802154: forbid monitor for add llsec seclevel
net: ieee802154: forbid monitor for del llsec seclevel
net: ieee802154: stop dump llsec params for monitors

 net/ieee802154/nl-mac.c   |  7 +++---
 net/ieee802154/nl802154.c | 52 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 3 deletions(-)
Signature · 1 line
2.26.3
#1 lore raw

PATCH RESEND 1/15 net: ieee802154: nl-mac: fix check on panid

This patch fixes a null pointer derefence for panid handle by move the check for the netlink variable directly before accessing them.

---
 net/ieee802154/nl-mac.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
net/ieee802154/nl-mac.c +4 -3
index 9c640d670ffe..0c1b0770c59e 100644
@@ -551,9 +551,7 @@ ieee802154_llsec_parse_key_id(struct genl_info *info,
 	desc->mode = nla_get_u8(info->attrs[IEEE802154_ATTR_LLSEC_KEY_MODE]);
 
 	if (desc->mode == IEEE802154_SCF_KEY_IMPLICIT) {
-		if (!info->attrs[IEEE802154_ATTR_PAN_ID] &&
-		    !(info->attrs[IEEE802154_ATTR_SHORT_ADDR] ||
-		      info->attrs[IEEE802154_ATTR_HW_ADDR]))
+		if (!info->attrs[IEEE802154_ATTR_PAN_ID])
 			return -EINVAL;
 
 		desc->device_addr.pan_id = nla_get_shortaddr(info->attrs[IEEE802154_ATTR_PAN_ID]);
@@ -562,6 +560,9 @@ ieee802154_llsec_parse_key_id(struct genl_info *info,
 			desc->device_addr.mode = IEEE802154_ADDR_SHORT;
 			desc->device_addr.short_addr = nla_get_shortaddr(info->attrs[IEEE802154_ATTR_SHORT_ADDR]);
 		} else {
+			if (!info->attrs[IEEE802154_ATTR_HW_ADDR])
+				return -EINVAL;
+
 			desc->device_addr.mode = IEEE802154_ADDR_LONG;
 			desc->device_addr.extended_addr = nla_get_hwaddr(info->attrs[IEEE802154_ATTR_HW_ADDR]);
 		}
Signature · 1 line
2.26.3
#2 lore raw

PATCH RESEND 2/15 net: ieee802154: forbid monitor for set llsec params

In reply to Alexander Aring

This patch forbids to set llsec params for monitor interfaces which we don't support yet.

---
 net/ieee802154/nl802154.c | 3 +++
 1 file changed, 3 insertions(+)
net/ieee802154/nl802154.c +3 -0
index 1600edb98107..ce8956f31ef9 100644
@@ -1384,6 +1384,9 @@ static int nl802154_set_llsec_params(struct sk_buff *skb,
 	u32 changed = 0;
 	int ret;
 
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+		return -EOPNOTSUPP;
+
 	if (info->attrs[NL802154_ATTR_SEC_ENABLED]) {
 		u8 enabled;
 
Signature · 1 line
2.26.3
#3 lore raw

PATCH RESEND 3/15 net: ieee802154: stop dump llsec keys for monitors

In reply to Alexander Aring

This patch stops dumping llsec keys for monitors which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 5 +++++
 1 file changed, 5 insertions(+)
net/ieee802154/nl802154.c +5 -0
index ce8956f31ef9..7815f253c8a3 100644
@@ -1493,6 +1493,11 @@ nl802154_dump_llsec_key(struct sk_buff *skb, struct netlink_callback *cb)
 	if (err)
 		return err;
 
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR) {
+		err = skb->len;
+		goto out_err;
+	}
+
 	if (!wpan_dev->netdev) {
 		err = -EINVAL;
 		goto out_err;
Signature · 1 line
2.26.3
#4 lore raw

PATCH RESEND 4/15 net: ieee802154: forbid monitor for add llsec key

In reply to Alexander Aring

This patch forbids to add llsec key for monitor interfaces which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 3 +++
 1 file changed, 3 insertions(+)
net/ieee802154/nl802154.c +3 -0
index 7815f253c8a3..42a246b6f9cb 100644
@@ -1552,6 +1552,9 @@ 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 (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+		return -EOPNOTSUPP;
+
 	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;
Signature · 1 line
2.26.3
#5 lore raw

PATCH RESEND 5/15 net: ieee802154: forbid monitor for del llsec key

In reply to Alexander Aring

This patch forbids to del llsec key for monitor interfaces which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 3 +++
 1 file changed, 3 insertions(+)
net/ieee802154/nl802154.c +3 -0
index 42a246b6f9cb..bfc0eca774e3 100644
@@ -1604,6 +1604,9 @@ 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 (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+		return -EOPNOTSUPP;
+
 	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;
Signature · 1 line
2.26.3
#6 lore raw

PATCH RESEND 6/15 net: ieee802154: stop dump llsec devs for monitors

In reply to Alexander Aring

This patch stops dumping llsec devs for monitors which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 5 +++++
 1 file changed, 5 insertions(+)
net/ieee802154/nl802154.c +5 -0
index bfc0eca774e3..ef0becc9faa7 100644
@@ -1672,6 +1672,11 @@ nl802154_dump_llsec_dev(struct sk_buff *skb, struct netlink_callback *cb)
 	if (err)
 		return err;
 
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR) {
+		err = skb->len;
+		goto out_err;
+	}
+
 	if (!wpan_dev->netdev) {
 		err = -EINVAL;
 		goto out_err;
Signature · 1 line
2.26.3
#7 lore raw

PATCH RESEND 7/15 net: ieee802154: forbid monitor for add llsec dev

In reply to Alexander Aring

This patch forbids to add llsec dev for monitor interfaces which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 3 +++
 1 file changed, 3 insertions(+)
net/ieee802154/nl802154.c +3 -0
index ef0becc9faa7..0d7dc9478b56 100644
@@ -1763,6 +1763,9 @@ static int nl802154_add_llsec_dev(struct sk_buff *skb, struct genl_info *info)
 	struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
 	struct ieee802154_llsec_device dev_desc;
 
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+		return -EOPNOTSUPP;
+
 	if (ieee802154_llsec_parse_device(info->attrs[NL802154_ATTR_SEC_DEVICE],
 					  &dev_desc) < 0)
 		return -EINVAL;
Signature · 1 line
2.26.3
#8 lore raw

PATCH RESEND 8/15 net: ieee802154: forbid monitor for del llsec dev

In reply to Alexander Aring

This patch forbids to del llsec dev for monitor interfaces which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 3 +++
 1 file changed, 3 insertions(+)
net/ieee802154/nl802154.c +3 -0
index 0d7dc9478b56..17c782d4cdae 100644
@@ -1781,6 +1781,9 @@ 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 (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+		return -EOPNOTSUPP;
+
 	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;
Signature · 1 line
2.26.3
#9 lore raw

PATCH RESEND 9/15 net: ieee802154: stop dump llsec devkeys for monitors

In reply to Alexander Aring

This patch stops dumping llsec devkeys for monitors which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 5 +++++
 1 file changed, 5 insertions(+)
net/ieee802154/nl802154.c +5 -0
index 17c782d4cdae..6f9cb6c0cafc 100644
@@ -1853,6 +1853,11 @@ nl802154_dump_llsec_devkey(struct sk_buff *skb, struct netlink_callback *cb)
 	if (err)
 		return err;
 
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR) {
+		err = skb->len;
+		goto out_err;
+	}
+
 	if (!wpan_dev->netdev) {
 		err = -EINVAL;
 		goto out_err;
Signature · 1 line
2.26.3
#10 lore raw

PATCH RESEND 10/15 net: ieee802154: forbid monitor for add llsec devkey

In reply to Alexander Aring

This patch forbids to add llsec devkey for monitor interfaces which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 3 +++
 1 file changed, 3 insertions(+)
net/ieee802154/nl802154.c +3 -0
index 6f9cb6c0cafc..c3f9bff7a557 100644
@@ -1915,6 +1915,9 @@ static int nl802154_add_llsec_devkey(struct sk_buff *skb, struct genl_info *info
 	struct ieee802154_llsec_device_key key;
 	__le64 extended_addr;
 
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+		return -EOPNOTSUPP;
+
 	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) < 0)
 		return -EINVAL;
Signature · 1 line
2.26.3
#11 lore raw

PATCH RESEND 11/15 net: ieee802154: forbid monitor for del llsec devkey

In reply to Alexander Aring

This patch forbids to del llsec devkey for monitor interfaces which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 3 +++
 1 file changed, 3 insertions(+)
net/ieee802154/nl802154.c +3 -0
index c3f9bff7a557..88735f03b73e 100644
@@ -1949,6 +1949,9 @@ static int nl802154_del_llsec_devkey(struct sk_buff *skb, struct genl_info *info
 	struct ieee802154_llsec_device_key key;
 	__le64 extended_addr;
 
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+		return -EOPNOTSUPP;
+
 	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;
Signature · 1 line
2.26.3
#12 lore raw

PATCH RESEND 12/15 net: ieee802154: stop dump llsec seclevels for monitors

In reply to Alexander Aring

This patch stops dumping llsec seclevels for monitors which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 5 +++++
 1 file changed, 5 insertions(+)
net/ieee802154/nl802154.c +5 -0
index 88735f03b73e..9158b095ccf9 100644
@@ -2026,6 +2026,11 @@ nl802154_dump_llsec_seclevel(struct sk_buff *skb, struct netlink_callback *cb)
 	if (err)
 		return err;
 
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR) {
+		err = skb->len;
+		goto out_err;
+	}
+
 	if (!wpan_dev->netdev) {
 		err = -EINVAL;
 		goto out_err;
Signature · 1 line
2.26.3
#13 lore raw

PATCH RESEND 13/15 net: ieee802154: forbid monitor for add llsec seclevel

In reply to Alexander Aring

This patch forbids to add llsec seclevel for monitor interfaces which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 3 +++
 1 file changed, 3 insertions(+)
net/ieee802154/nl802154.c +3 -0
index 9158b095ccf9..28427ce52a9b 100644
@@ -2115,6 +2115,9 @@ static int nl802154_add_llsec_seclevel(struct sk_buff *skb,
 	struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
 	struct ieee802154_llsec_seclevel sl;
 
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+		return -EOPNOTSUPP;
+
 	if (llsec_parse_seclevel(info->attrs[NL802154_ATTR_SEC_LEVEL],
 				 &sl) < 0)
 		return -EINVAL;
Signature · 1 line
2.26.3
#14 lore raw

PATCH RESEND 14/15 net: ieee802154: forbid monitor for del llsec seclevel

In reply to Alexander Aring

This patch forbids to del llsec seclevel for monitor interfaces which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 3 +++
 1 file changed, 3 insertions(+)
net/ieee802154/nl802154.c +3 -0
index 28427ce52a9b..effc4c1a4780 100644
@@ -2133,6 +2133,9 @@ static int nl802154_del_llsec_seclevel(struct sk_buff *skb,
 	struct wpan_dev *wpan_dev = dev->ieee802154_ptr;
 	struct ieee802154_llsec_seclevel sl;
 
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+		return -EOPNOTSUPP;
+
 	if (!info->attrs[NL802154_ATTR_SEC_LEVEL] ||
 	    llsec_parse_seclevel(info->attrs[NL802154_ATTR_SEC_LEVEL],
 				 &sl) < 0)
Signature · 1 line
2.26.3
#15 lore raw

PATCH RESEND 15/15 net: ieee802154: stop dump llsec params for monitors

In reply to Alexander Aring

This patch stops dumping llsec params for monitors which we don't support yet. Otherwise we will access llsec mib which isn't initialized for monitors.

---
 net/ieee802154/nl802154.c | 5 +++++
 1 file changed, 5 insertions(+)
net/ieee802154/nl802154.c +5 -0
index effc4c1a4780..05f6bd89a7dd 100644
@@ -820,8 +820,13 @@ nl802154_send_iface(struct sk_buff *msg, u32 portid, u32 seq, int flags,
 		goto nla_put_failure;
 
 #ifdef CONFIG_IEEE802154_NL802154_EXPERIMENTAL
+	if (wpan_dev->iftype == NL802154_IFTYPE_MONITOR)
+		goto out;
+
 	if (nl802154_get_llsec_params(msg, rdev, wpan_dev) < 0)
 		goto nla_put_failure;
+
+out:
 #endif /* CONFIG_IEEE802154_NL802154_EXPERIMENTAL */
 
 	genlmsg_end(msg, hdr);
Signature · 1 line
2.26.3
maintainer
#16 lore raw
In reply to Alexander Aring

Hi,

Quoted 11 lines · Alexander Aring

Hi,

this patch series contains fixes to forbid various security parameters settings for monitor types. Monitor types doesn't use the llsec security currently and we don't support it. With this patch series the user will be notified with a EOPNOTSUPP error that for monitor interfaces security is not supported yet. However there might be a possibility in future that the kernel will decrypt frames with llsec information for sniffing frames and deliver plaintext to userspace, but this isn't supported yet.

cc Du Cheng by request.

- Alex

maintainer
#17 lore raw
In reply to Alexander Aring

Hello.

Quoted 29 lines · Alexander Aring

Hi,

this patch series contains fixes to forbid various security parameters settings for monitor types. Monitor types doesn't use the llsec security currently and we don't support it. With this patch series the user will be notified with a EOPNOTSUPP error that for monitor interfaces security is not supported yet. However there might be a possibility in future that the kernel will decrypt frames with llsec information for sniffing frames and deliver plaintext to userspace, but this isn't supported yet.

- Alex

Alexander Aring (15):
net: ieee802154: nl-mac: fix check on panid
net: ieee802154: forbid monitor for set llsec params
net: ieee802154: stop dump llsec keys for monitors
net: ieee802154: forbid monitor for add llsec key
net: ieee802154: forbid monitor for del llsec key
net: ieee802154: stop dump llsec devs for monitors
net: ieee802154: forbid monitor for add llsec dev
net: ieee802154: forbid monitor for del llsec dev
net: ieee802154: stop dump llsec devkeys for monitors
net: ieee802154: forbid monitor for add llsec devkey
net: ieee802154: forbid monitor for del llsec devkey
net: ieee802154: stop dump llsec seclevels for monitors
net: ieee802154: forbid monitor for add llsec seclevel
net: ieee802154: forbid monitor for del llsec seclevel
net: ieee802154: stop dump llsec params for monitors

Quoted 4 lines
  net/ieee802154/nl-mac.c   |  7 +++---
  net/ieee802154/nl802154.c | 52 +++++++++++++++++++++++++++++++++++++++
  2 files changed, 56 insertions(+), 3 deletions(-)

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

regards
Stefan Schmidt