summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Toth <laszlth@gmail.com>2017-10-23 19:19:33 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-11-18 11:30:37 +0100
commit574475f09d984238580b85c070e6052f164c778e (patch)
tree268094de1f9bca907770b9945c4698dfd18f030b
parentf9b6f439d879da4b7db31fa30b68ea954f328329 (diff)
downloadlinux-stable-574475f09d984238580b85c070e6052f164c778e.tar.gz
linux-stable-574475f09d984238580b85c070e6052f164c778e.tar.bz2
linux-stable-574475f09d984238580b85c070e6052f164c778e.zip
sctp: full support for ipv6 ip_nonlocal_bind & IP_FREEBIND
[ Upstream commit b71d21c274eff20a9db8158882b545b141b73ab8 ] Commit 9b9742022888 ("sctp: support ipv6 nonlocal bind") introduced support for the above options as v4 sctp did, so patched sctp_v6_available(). In the v4 implementation it's enough, because sctp_inet_bind_verify() just returns with sctp_v4_available(). However sctp_inet6_bind_verify() has an extra check before that for link-local scope_id, which won't respect the above options. Added the checks before calling ipv6_chk_addr(), but not before the validation of scope_id. before (w/ both options): ./v6test fe80::10 sctp bind failed, errno: 99 (Cannot assign requested address) ./v6test fe80::10 tcp bind success, errno: 0 (Success) after (w/ both options): ./v6test fe80::10 sctp bind success, errno: 0 (Success) Signed-off-by: Laszlo Toth <laszlth@gmail.com> Reviewed-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/sctp/ipv6.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index a4b6ffb61495..1344e3a411ae 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -882,8 +882,10 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr)
net = sock_net(&opt->inet.sk);
rcu_read_lock();
dev = dev_get_by_index_rcu(net, addr->v6.sin6_scope_id);
- if (!dev ||
- !ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0)) {
+ if (!dev || !(opt->inet.freebind ||
+ net->ipv6.sysctl.ip_nonlocal_bind ||
+ ipv6_chk_addr(net, &addr->v6.sin6_addr,
+ dev, 0))) {
rcu_read_unlock();
return 0;
}