ieee802154: 6lowpan: fix possible NULL deref in lowpan_device_event()
Subsystems (3)
PATCH 1/1 ieee802154: 6lowpan: fix possible NULL deref in lowpan_device_event()
From: Eric Dumazet <[email protected]>
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.
---
net/ieee802154/6lowpan/core.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
net/ieee802154/6lowpan/core.c +8 -4
@@ -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) {
@@ -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 ;
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Mon, 05 Mar 2018 08:51:03 -0800
Quoted 5 lines
From: Eric Dumazet <[email protected]>
A tun device type can trivially be set to arbitrary value using TUNSETLINK
ioctl().
Quoted 8 lines
Therefore,
lowpan_device_event()must really check thatieee802154_ptris not NULL.Fixes 2c88b5283f60d ("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]>
Adding linux-wpan list.
Quoted 36 lines
---
net/ieee802154/6lowpan/core.c | 12 ++++++++----1 file changed, 8 insertions(+), 4 deletions(-)net/ieee802154/6lowpan/core.c +8
-4@@ -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) {@@ -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 ;
Hello.
Quoted 22 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
A tun device type can trivially be set to arbitrary value using TUNSETLINK
ioctl().Therefore,
lowpan_device_event()must really check thatieee802154_ptris not NULL.Fixes 2c88b5283f60d ("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]>---
net/ieee802154/6lowpan/core.c | 12 ++++++++----1 file changed, 8 insertions(+), 4 deletions(-)net/ieee802154/6lowpan/core.c +0
-0
net/ieee802154/6lowpan/core.c static inline void lowpan_netlink_fini(void) · line 209
Quoted 5 lines
net/ieee802154/6lowpan/core.c +1
-1@@ -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);
Not sure why you think there is a rename from wdev to ndev necessary.
I see this more of a rolled in cosmetic change, but its not a real problem from my side.
Quoted 12 lines
net/ieee802154/6lowpan/core.c +5
-1+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) {
net/ieee802154/6lowpan/core.c static int lowpan_device_event(struct notifier_block *unused, · line 228
Quoted 10 lines
net/ieee802154/6lowpan/core.c +2
-2@@ -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 ;
Thanks a lot for fixing this and syzbot for finding it.
Dave, could you take this one directly? I have no other patches pending for your net tree (only net-next) and having a pull request for just this patch does not make much sense.
regards
Stefan Schmidt
Hello Dave.
Quoted 59 lines · Stefan Schmidt
Hello.
Quoted 22 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
A tun device type can trivially be set to arbitrary value using TUNSETLINK
ioctl().Therefore,
lowpan_device_event()must really check thatieee802154_ptris not NULL.Fixes 2c88b5283f60d ("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]>---
net/ieee802154/6lowpan/core.c | 12 ++++++++----1 file changed, 8 insertions(+), 4 deletions(-)net/ieee802154/6lowpan/core.c +0
-0net/ieee802154/6lowpan/core.c static inline void lowpan_netlink_fini(void) · line 209
Quoted 5 lines
net/ieee802154/6lowpan/core.c +1
-1@@ -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);Not sure why you think there is a rename from wdev to ndev necessary.
I see this more of a rolled in cosmetic change, but its not a real problem from my side.Quoted 12 lines
net/ieee802154/6lowpan/core.c +5
-1+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) {net/ieee802154/6lowpan/core.c static int lowpan_device_event(struct notifier_block *unused, · line 228
Quoted 10 lines
net/ieee802154/6lowpan/core.c +2
-2@@ -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 ;Thanks a lot for fixing this and syzbot for finding it.
Quoted 5 lines
Acked-by Stefan Schmidt <[email protected]>Dave, could you take this one directly? I have no other patches pending for your net tree (only net-next) and having a pull request for just this patch does not make much sense.
Did you miss this or would you prefer if I do a pull request for this single patch? Either way would be fine with me.
regards
Stefan Schmidt
David Miller
maintainerFrom: Stefan Schmidt <[email protected]>
Date: Thu, 8 Mar 2018 17:21:49 +0100
Quoted 2 lines
Did you miss this or would you prefer if I do a pull request for this single patch? Either way would be fine with me.
Sorry, this escaped me.
Applied and queued up for -stable, thanks.