Commit ca0edb13 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

ieee802154: 6lowpan: fix possible NULL deref in lowpan_device_event()

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: 2c88b528 ("ieee802154: 6lowpan: remove check on null")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Stefan Schmidt <stefan@osg.samsung.com>
Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
Acked-by: default avatarStefan Schmidt <stefan@osg.samsung.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9f62c15f
...@@ -206,9 +206,13 @@ static inline void lowpan_netlink_fini(void) ...@@ -206,9 +206,13 @@ static inline void lowpan_netlink_fini(void)
static int lowpan_device_event(struct notifier_block *unused, static int lowpan_device_event(struct notifier_block *unused,
unsigned long event, void *ptr) 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; return NOTIFY_DONE;
switch (event) { switch (event) {
...@@ -217,8 +221,8 @@ static int lowpan_device_event(struct notifier_block *unused, ...@@ -217,8 +221,8 @@ static int lowpan_device_event(struct notifier_block *unused,
* also delete possible lowpan interfaces which belongs * also delete possible lowpan interfaces which belongs
* to the wpan interface. * to the wpan interface.
*/ */
if (wdev->ieee802154_ptr->lowpan_dev) if (wpan_dev->lowpan_dev)
lowpan_dellink(wdev->ieee802154_ptr->lowpan_dev, NULL); lowpan_dellink(wpan_dev->lowpan_dev, NULL);
break; break;
default: default:
return NOTIFY_DONE; return NOTIFY_DONE;
......
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