ipv6: fix rtnl locking in setsockopt for anycast and multicast
Calling setsockopt with IPV6_JOIN_ANYCAST or IPV6_LEAVE_ANYCAST triggers the assertion in addrconf_join_solict()/addrconf_leave_solict() ipv6_sock_ac_join(), ipv6_sock_ac_drop(), ipv6_sock_ac_close() need to take RTNL before calling ipv6_dev_ac_inc/dec. Same thing with ipv6_sock_mc_join(), ipv6_sock_mc_drop(), ipv6_sock_mc_close() before calling ipv6_dev_mc_inc/dec. This patch moves ASSERT_RTNL() up a level in the call stack. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Reported-by: Tommi Rantala <tt.rantala@gmail.com> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
4ad9a64f53
commit
a9ed4a2986
@@ -1690,14 +1690,12 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp)
|
||||
addrconf_mod_dad_work(ifp, 0);
|
||||
}
|
||||
|
||||
/* Join to solicited addr multicast group. */
|
||||
|
||||
/* Join to solicited addr multicast group.
|
||||
* caller must hold RTNL */
|
||||
void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr)
|
||||
{
|
||||
struct in6_addr maddr;
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
if (dev->flags&(IFF_LOOPBACK|IFF_NOARP))
|
||||
return;
|
||||
|
||||
@@ -1705,12 +1703,11 @@ void addrconf_join_solict(struct net_device *dev, const struct in6_addr *addr)
|
||||
ipv6_dev_mc_inc(dev, &maddr);
|
||||
}
|
||||
|
||||
/* caller must hold RTNL */
|
||||
void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr)
|
||||
{
|
||||
struct in6_addr maddr;
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
if (idev->dev->flags&(IFF_LOOPBACK|IFF_NOARP))
|
||||
return;
|
||||
|
||||
@@ -1718,12 +1715,11 @@ void addrconf_leave_solict(struct inet6_dev *idev, const struct in6_addr *addr)
|
||||
__ipv6_dev_mc_dec(idev, &maddr);
|
||||
}
|
||||
|
||||
/* caller must hold RTNL */
|
||||
static void addrconf_join_anycast(struct inet6_ifaddr *ifp)
|
||||
{
|
||||
struct in6_addr addr;
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
if (ifp->prefix_len >= 127) /* RFC 6164 */
|
||||
return;
|
||||
ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len);
|
||||
@@ -1732,12 +1728,11 @@ static void addrconf_join_anycast(struct inet6_ifaddr *ifp)
|
||||
ipv6_dev_ac_inc(ifp->idev->dev, &addr);
|
||||
}
|
||||
|
||||
/* caller must hold RTNL */
|
||||
static void addrconf_leave_anycast(struct inet6_ifaddr *ifp)
|
||||
{
|
||||
struct in6_addr addr;
|
||||
|
||||
ASSERT_RTNL();
|
||||
|
||||
if (ifp->prefix_len >= 127) /* RFC 6164 */
|
||||
return;
|
||||
ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len);
|
||||
|
Reference in New Issue
Block a user