net: Fix IP_MULTICAST_IF
authorEric Dumazet <eric.dumazet@gmail.com>
Mon, 19 Oct 2009 06:41:58 +0000 (06:41 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 20 Oct 2009 04:34:20 +0000 (21:34 -0700)
commit55b8050353c4a212c94d7156e2bd5885225b869b
tree013778c4d48b946b2c565f8b55f40e505ec255ce
parent45054dc1bf2367ccb0e7c0486037907cd9395f8b
net: Fix IP_MULTICAST_IF

ipv4/ipv6 setsockopt(IP_MULTICAST_IF) have dubious __dev_get_by_index() calls.

This function should be called only with RTNL or dev_base_lock held, or reader
could see a corrupt hash chain and eventually enter an endless loop.

Fix is to call dev_get_by_index()/dev_put().

If this happens to be performance critical, we could define a new dev_exist_by_index()
function to avoid touching dev refcount.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_sockglue.c
net/ipv6/ipv6_sockglue.c