Skip to content

Commit 0ff207b

Browse files
committed
net: ieee802154: fix null deref in parse dev addr
jira LE-1907 cve CVE-2021-47257 Rebuild_History Non-Buildable kernel-4.18.0-553.16.1.el8_10 commit-author Dan Robertson <[email protected]> commit 9fdd049 Fix a logic error that could result in a null deref if the user sets the mode incorrectly for the given addr type. Signed-off-by: Dan Robertson <[email protected]> Acked-by: Alexander Aring <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stefan Schmidt <[email protected]> (cherry picked from commit 9fdd049) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 4e4f225 commit 0ff207b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

net/ieee802154/nl802154.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,19 +1299,20 @@ ieee802154_llsec_parse_dev_addr(struct nlattr *nla,
12991299
if (!nla || nla_parse_nested_deprecated(attrs, NL802154_DEV_ADDR_ATTR_MAX, nla, nl802154_dev_addr_policy, NULL))
13001300
return -EINVAL;
13011301

1302-
if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] ||
1303-
!attrs[NL802154_DEV_ADDR_ATTR_MODE] ||
1304-
!(attrs[NL802154_DEV_ADDR_ATTR_SHORT] ||
1305-
attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]))
1302+
if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] || !attrs[NL802154_DEV_ADDR_ATTR_MODE])
13061303
return -EINVAL;
13071304

13081305
addr->pan_id = nla_get_le16(attrs[NL802154_DEV_ADDR_ATTR_PAN_ID]);
13091306
addr->mode = nla_get_u32(attrs[NL802154_DEV_ADDR_ATTR_MODE]);
13101307
switch (addr->mode) {
13111308
case NL802154_DEV_ADDR_SHORT:
1309+
if (!attrs[NL802154_DEV_ADDR_ATTR_SHORT])
1310+
return -EINVAL;
13121311
addr->short_addr = nla_get_le16(attrs[NL802154_DEV_ADDR_ATTR_SHORT]);
13131312
break;
13141313
case NL802154_DEV_ADDR_EXTENDED:
1314+
if (!attrs[NL802154_DEV_ADDR_ATTR_EXTENDED])
1315+
return -EINVAL;
13151316
addr->extended_addr = nla_get_le64(attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]);
13161317
break;
13171318
default:

0 commit comments

Comments
 (0)