sctp: ipv6: avoid touching device refcount
Avoid touching device refcount in sctp/ipv6, thanks to RCU Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
122ec6ffca
commit
40c9c31e38
@@ -837,15 +837,16 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr)
|
|||||||
if (type & IPV6_ADDR_LINKLOCAL) {
|
if (type & IPV6_ADDR_LINKLOCAL) {
|
||||||
if (!addr->v6.sin6_scope_id)
|
if (!addr->v6.sin6_scope_id)
|
||||||
return 0;
|
return 0;
|
||||||
dev = dev_get_by_index(&init_net, addr->v6.sin6_scope_id);
|
rcu_read_lock();
|
||||||
if (!dev)
|
dev = dev_get_by_index_rcu(&init_net,
|
||||||
return 0;
|
addr->v6.sin6_scope_id);
|
||||||
if (!ipv6_chk_addr(&init_net, &addr->v6.sin6_addr,
|
if (!dev ||
|
||||||
|
!ipv6_chk_addr(&init_net, &addr->v6.sin6_addr,
|
||||||
dev, 0)) {
|
dev, 0)) {
|
||||||
dev_put(dev);
|
rcu_read_unlock();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
dev_put(dev);
|
rcu_read_unlock();
|
||||||
} else if (type == IPV6_ADDR_MAPPED) {
|
} else if (type == IPV6_ADDR_MAPPED) {
|
||||||
if (!opt->v4mapped)
|
if (!opt->v4mapped)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -873,10 +874,12 @@ static int sctp_inet6_send_verify(struct sctp_sock *opt, union sctp_addr *addr)
|
|||||||
if (type & IPV6_ADDR_LINKLOCAL) {
|
if (type & IPV6_ADDR_LINKLOCAL) {
|
||||||
if (!addr->v6.sin6_scope_id)
|
if (!addr->v6.sin6_scope_id)
|
||||||
return 0;
|
return 0;
|
||||||
dev = dev_get_by_index(&init_net, addr->v6.sin6_scope_id);
|
rcu_read_lock();
|
||||||
|
dev = dev_get_by_index_rcu(&init_net,
|
||||||
|
addr->v6.sin6_scope_id);
|
||||||
|
rcu_read_unlock();
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return 0;
|
return 0;
|
||||||
dev_put(dev);
|
|
||||||
}
|
}
|
||||||
af = opt->pf->af;
|
af = opt->pf->af;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user