Skip to content

Commit ca0edb1

Browse files
Eric Dumazetdavem330
authored andcommitted
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: 2c88b52 ("ieee802154: 6lowpan: remove check on null") Signed-off-by: Eric Dumazet <[email protected]> Cc: Alexander Aring <[email protected]> Cc: Stefan Schmidt <[email protected]> Reported-by: syzbot <[email protected]> Acked-by: Stefan Schmidt <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9f62c15 commit ca0edb1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

net/ieee802154/6lowpan/core.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,13 @@ static inline void lowpan_netlink_fini(void)
206206
static int lowpan_device_event(struct notifier_block *unused,
207207
unsigned long event, void *ptr)
208208
{
209-
struct net_device *wdev = netdev_notifier_info_to_dev(ptr);
209+
struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
210+
struct wpan_dev *wpan_dev;
210211

211-
if (wdev->type != ARPHRD_IEEE802154)
212+
if (ndev->type != ARPHRD_IEEE802154)
213+
return NOTIFY_DONE;
214+
wpan_dev = ndev->ieee802154_ptr;
215+
if (!wpan_dev)
212216
return NOTIFY_DONE;
213217

214218
switch (event) {
@@ -217,8 +221,8 @@ static int lowpan_device_event(struct notifier_block *unused,
217221
* also delete possible lowpan interfaces which belongs
218222
* to the wpan interface.
219223
*/
220-
if (wdev->ieee802154_ptr->lowpan_dev)
221-
lowpan_dellink(wdev->ieee802154_ptr->lowpan_dev, NULL);
224+
if (wpan_dev->lowpan_dev)
225+
lowpan_dellink(wpan_dev->lowpan_dev, NULL);
222226
break;
223227
default:
224228
return NOTIFY_DONE;

0 commit comments

Comments
 (0)