Skip to content

Commit

Permalink
ieee802154: 6lowpan: fix possible NULL deref in lowpan_device_event()
Browse files Browse the repository at this point in the history
A tun device type can trivially be set to arbitrary value using
TUNSETLINK ioctl().

Therefore, lowpan_device_event() must really check that ieee802154_ptr
is not NULL.

Fixes: 2c88b52 ("ieee802154: 6lowpan: remove check on null")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Stefan Schmidt <stefan@osg.samsung.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Acked-by: Stefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and davem330 committed Mar 9, 2018
1 parent 9f62c15 commit ca0edb1
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions net/ieee802154/6lowpan/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,13 @@ static inline void lowpan_netlink_fini(void)
static int lowpan_device_event(struct notifier_block *unused,
unsigned long event, void *ptr)
{
struct net_device *wdev = netdev_notifier_info_to_dev(ptr);
struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
struct wpan_dev *wpan_dev;

if (wdev->type != ARPHRD_IEEE802154)
if (ndev->type != ARPHRD_IEEE802154)
return NOTIFY_DONE;
wpan_dev = ndev->ieee802154_ptr;
if (!wpan_dev)
return NOTIFY_DONE;

switch (event) {
Expand All @@ -217,8 +221,8 @@ static int lowpan_device_event(struct notifier_block *unused,
* also delete possible lowpan interfaces which belongs
* to the wpan interface.
*/
if (wdev->ieee802154_ptr->lowpan_dev)
lowpan_dellink(wdev->ieee802154_ptr->lowpan_dev, NULL);
if (wpan_dev->lowpan_dev)
lowpan_dellink(wpan_dev->lowpan_dev, NULL);
break;
default:
return NOTIFY_DONE;
Expand Down

0 comments on commit ca0edb1

Please sign in to comment.