Skip to contentSkip to conversation

mac802154: Avoid rtnl deadlock in mac802154_wpan_ioctl().

PATCH In review Lennert Buytenhek 2 participants 2 messages May 26, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac802154: Avoid rtnl deadlock in mac802154_wpan_ioctl().

->ndo_do_ioctl() can be entered with the rtnl lock already held, for example when sending a wext ioctl to a device (in which case the rtnl lock is taken by wext_ioctl_dispatch()), but mac802154_wpan_ioctl() currently unconditionally takes the rtnl lock on entry, which can cause deadlocks.

To fix this, bail out of mac802154_wpan_ioctl() before taking the rtnl lock if the ioctl cmd is not one of the cmds we implement.

---
 net/mac802154/iface.c | 3 +++
 1 file changed, 3 insertions(+)
net/mac802154/iface.c +3 -0
index f30788d..b544b5d 100644
@@ -62,6 +62,9 @@ mac802154_wpan_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 		(struct sockaddr_ieee802154 *)&ifr->ifr_addr;
 	int err = -ENOIOCTLCMD;
 
+	if (cmd != SIOCGIFADDR && cmd != SIOCSIFADDR)
+		return err;
+
 	rtnl_lock();
 
 	switch (cmd) {
Signature · 1 line
2.1.0
#1 lore raw

Hi Lennert,

Quoted 6 lines

->ndo_do_ioctl() can be entered with the rtnl lock already held, for example when sending a wext ioctl to a device (in which case the rtnl lock is taken by wext_ioctl_dispatch()), but mac802154_wpan_ioctl() currently unconditionally takes the rtnl lock on entry, which can cause deadlocks.

Quoted 8 lines

To fix this, bail out of mac802154_wpan_ioctl() before taking the rtnl lock if the ioctl cmd is not one of the cmds we implement.

---
net/mac802154/iface.c | 3 +++

1 file changed, 3 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel