ieee802154: check device type
authorvegard.nossum@oracle.com <vegard.nossum@oracle.com>
Wed, 20 Jul 2016 08:43:11 +0000 (10:43 +0200)
committerStefan Schmidt <stefan@osg.samsung.com>
Wed, 30 Nov 2016 11:33:07 +0000 (12:33 +0100)
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: Vegard Nossum <vegard.nossum@oracle.com>
Acked-by: Alexander Aring <aar@pengutronix.de>
Signed-off-by: Stefan Schmidt <stefan@osg.samsung.com>
net/ieee802154/nl-phy.c

index 77d73014bde31ed285f3a11c40dd3ebaf82a8f2f..dc2960be51e0a6161d921bb3e3235926a15c3a82 100644 (file)
@@ -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')
                return -EINVAL; /* name should be null-terminated */
 
+       rc = -ENODEV;
        dev = dev_get_by_name(genl_info_net(info), name);
        if (!dev)
-               return -ENODEV;
+               return rc;
+       if (dev->type != ARPHRD_IEEE802154)
+               goto out;
 
        phy = dev->ieee802154_ptr->wpan_phy;
        BUG_ON(!phy);
@@ -342,6 +345,7 @@ nla_put_failure:
        nlmsg_free(msg);
 out_dev:
        wpan_phy_put(phy);
+out:
        if (dev)
                dev_put(dev);