diff mbox series

[wpan,03/17] net: ieee802154: nl-mac: fix check on panid

Message ID 20210228151817.95700-4-aahringo@redhat.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series ieee802154: syzbot fixes | expand

Checks

Context Check Description
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Alexander Aring Feb. 28, 2021, 3:18 p.m. UTC
This patch fixes a null pointer derefence for panid handle by move the
check for the netlink variable directly before accessing them.

Reported-by: syzbot+d4c07de0144f6f63be3a@syzkaller.appspotmail.com
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 net/ieee802154/nl-mac.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Stefan Schmidt March 2, 2021, 9:33 p.m. UTC | #1
Hello.

On 28.02.21 16:18, Alexander Aring wrote:
> This patch fixes a null pointer derefence for panid handle by move the
> check for the netlink variable directly before accessing them.
> 
> Reported-by: syzbot+d4c07de0144f6f63be3a@syzkaller.appspotmail.com
> Signed-off-by: Alexander Aring <aahringo@redhat.com>
> ---
>   net/ieee802154/nl-mac.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
> index 9c640d670ffe..0c1b0770c59e 100644
> --- a/net/ieee802154/nl-mac.c
> +++ b/net/ieee802154/nl-mac.c
> @@ -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]);
>   		}
> 

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

regards
Stefan Schmidt
diff mbox series

Patch

diff --git a/net/ieee802154/nl-mac.c b/net/ieee802154/nl-mac.c
index 9c640d670ffe..0c1b0770c59e 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -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]);
 		}