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

net: arp_ioctl() must hold RTNL

Commit 941666c2 "net: RCU conversion of dev_getbyhwaddr() and
arp_ioctl()" introduced a regression, reported by Jamie Heilman.
"arp -Ds 192.168.2.41 eth0 pub" triggered the ASSERT_RTNL() assert
in pneigh_lookup()

Removing RTNL requirement from arp_ioctl() was a mistake, just revert
that part.
Reported-by: default avatarJamie Heilman <jamie@audible.transient.net>
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0a0b7a5f
...@@ -749,7 +749,8 @@ EXPORT_SYMBOL(dev_get_by_index); ...@@ -749,7 +749,8 @@ EXPORT_SYMBOL(dev_get_by_index);
* @ha: hardware address * @ha: hardware address
* *
* Search for an interface by MAC address. Returns NULL if the device * Search for an interface by MAC address. Returns NULL if the device
* is not found or a pointer to the device. The caller must hold RCU * is not found or a pointer to the device.
* The caller must hold RCU or RTNL.
* The returned device has not had its ref count increased * The returned device has not had its ref count increased
* and the caller must therefore be careful about locking * and the caller must therefore be careful about locking
* *
......
...@@ -1017,14 +1017,13 @@ static int arp_req_set_proxy(struct net *net, struct net_device *dev, int on) ...@@ -1017,14 +1017,13 @@ static int arp_req_set_proxy(struct net *net, struct net_device *dev, int on)
IPV4_DEVCONF_ALL(net, PROXY_ARP) = on; IPV4_DEVCONF_ALL(net, PROXY_ARP) = on;
return 0; return 0;
} }
if (__in_dev_get_rcu(dev)) { if (__in_dev_get_rtnl(dev)) {
IN_DEV_CONF_SET(__in_dev_get_rcu(dev), PROXY_ARP, on); IN_DEV_CONF_SET(__in_dev_get_rtnl(dev), PROXY_ARP, on);
return 0; return 0;
} }
return -ENXIO; return -ENXIO;
} }
/* must be called with rcu_read_lock() */
static int arp_req_set_public(struct net *net, struct arpreq *r, static int arp_req_set_public(struct net *net, struct arpreq *r,
struct net_device *dev) struct net_device *dev)
{ {
...@@ -1233,10 +1232,10 @@ int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg) ...@@ -1233,10 +1232,10 @@ int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg)
if (!(r.arp_flags & ATF_NETMASK)) if (!(r.arp_flags & ATF_NETMASK))
((struct sockaddr_in *)&r.arp_netmask)->sin_addr.s_addr = ((struct sockaddr_in *)&r.arp_netmask)->sin_addr.s_addr =
htonl(0xFFFFFFFFUL); htonl(0xFFFFFFFFUL);
rcu_read_lock(); rtnl_lock();
if (r.arp_dev[0]) { if (r.arp_dev[0]) {
err = -ENODEV; err = -ENODEV;
dev = dev_get_by_name_rcu(net, r.arp_dev); dev = __dev_get_by_name(net, r.arp_dev);
if (dev == NULL) if (dev == NULL)
goto out; goto out;
...@@ -1263,7 +1262,7 @@ int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg) ...@@ -1263,7 +1262,7 @@ int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg)
break; break;
} }
out: out:
rcu_read_unlock(); rtnl_unlock();
if (cmd == SIOCGARP && !err && copy_to_user(arg, &r, sizeof(r))) if (cmd == SIOCGARP && !err && copy_to_user(arg, &r, sizeof(r)))
err = -EFAULT; err = -EFAULT;
return err; return err;
......
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