linux-wpan.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.14 01/25] net: ieee802154: nl-mac: fix check on panid
@ 2021-04-12 16:26 Sasha Levin
  2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 06/25] drivers: net: fix memory leak in atusb_probe Sasha Levin
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Sasha Levin @ 2021-04-12 16:26 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Alexander Aring, syzbot+d4c07de0144f6f63be3a, Stefan Schmidt,
	Sasha Levin, linux-wpan, netdev

From: Alexander Aring <aahringo@redhat.com>

[ Upstream commit 6f7f657f24405f426212c09260bf7fe8a52cef33 ]

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>
Link: https://lore.kernel.org/r/20210228151817.95700-4-aahringo@redhat.com
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 d3cbb3258718..c0930b9fe848 100644
--- a/net/ieee802154/nl-mac.c
+++ b/net/ieee802154/nl-mac.c
@@ -559,9 +559,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]);
@@ -570,6 +568,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]);
 		}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-04-12 16:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-12 16:26 [PATCH AUTOSEL 4.14 01/25] net: ieee802154: nl-mac: fix check on panid Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 06/25] drivers: net: fix memory leak in atusb_probe Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 10/25] net: ieee802154: forbid monitor for set llsec params Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 11/25] net: ieee802154: stop dump llsec keys for monitors Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 12/25] net: ieee802154: stop dump llsec devs " Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 13/25] net: ieee802154: forbid monitor for add llsec dev Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 14/25] net: ieee802154: stop dump llsec devkeys for monitors Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 15/25] net: ieee802154: forbid monitor for add llsec devkey Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 16/25] net: ieee802154: stop dump llsec seclevels for monitors Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 17/25] net: ieee802154: forbid monitor for add llsec seclevel Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 18/25] net: ieee802154: forbid monitor for del " Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 19/25] net: ieee802154: stop dump llsec params for monitors Sasha Levin
2021-04-12 16:26 ` [PATCH AUTOSEL 4.14 20/25] net: mac802154: Fix general protection fault Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).