Commit 5b3211dc authored by vegard.nossum@oracle.com's avatar vegard.nossum@oracle.com Committed by Stefan Schmidt

ieee802154: check device type

I've observed a NULL pointer dereference in ieee802154_del_iface() during
netlink fuzzing. It's the ->wpan_phy dereference here:

        phy = dev->ieee802154_ptr->wpan_phy;

My bet is that we're not checking that this is an IEEE802154 interface,
so let's do what ieee802154_nl_get_dev() is doing. (Maybe we should even
be calling this directly?)

Cc: Lennert Buytenhek <buytenh@wantstofly.org>
Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Sergey Lapin <slapin@ossfans.org>
Signed-off-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
Acked-by: default avatarAlexander Aring <aar@pengutronix.de>
Signed-off-by: default avatarStefan Schmidt <stefan@osg.samsung.com>
parent 1ae6d00a
...@@ -286,9 +286,12 @@ int ieee802154_del_iface(struct sk_buff *skb, struct genl_info *info) ...@@ -286,9 +286,12 @@ int ieee802154_del_iface(struct sk_buff *skb, struct genl_info *info)
if (name[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1] != '\0') if (name[nla_len(info->attrs[IEEE802154_ATTR_DEV_NAME]) - 1] != '\0')
return -EINVAL; /* name should be null-terminated */ return -EINVAL; /* name should be null-terminated */
rc = -ENODEV;
dev = dev_get_by_name(genl_info_net(info), name); dev = dev_get_by_name(genl_info_net(info), name);
if (!dev) if (!dev)
return -ENODEV; return rc;
if (dev->type != ARPHRD_IEEE802154)
goto out;
phy = dev->ieee802154_ptr->wpan_phy; phy = dev->ieee802154_ptr->wpan_phy;
BUG_ON(!phy); BUG_ON(!phy);
...@@ -342,6 +345,7 @@ int ieee802154_del_iface(struct sk_buff *skb, struct genl_info *info) ...@@ -342,6 +345,7 @@ int ieee802154_del_iface(struct sk_buff *skb, struct genl_info *info)
nlmsg_free(msg); nlmsg_free(msg);
out_dev: out_dev:
wpan_phy_put(phy); wpan_phy_put(phy);
out:
if (dev) if (dev)
dev_put(dev); dev_put(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment