Message ID | 20210405070652.2447152-1-zenczykowski@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 630e4576f83accf90366686f39808d665d8dbecc |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net-ipv6: bugfix - raw & sctp - switch to ipv6_can_nonlocal_bind() | expand |
On Mon, Apr 5, 2021 at 4:07 PM Maciej Żenczykowski <zenczykowski@gmail.com> wrote: > The helper is defined as: > static inline bool ipv6_can_nonlocal_bind(struct net *net, struct inet_sock *inet) { > return net->ipv6.sysctl.ip_nonlocal_bind || inet->freebind || inet->transparent; > } > so this change only widens the accepted opt-outs and is thus a clean bugfix. Reviewed-By: Lorenzo Colitti <lorenzo@google.com>
Hello: This patch was applied to netdev/net.git (refs/heads/master): On Mon, 5 Apr 2021 00:06:52 -0700 you wrote: > From: Maciej Żenczykowski <maze@google.com> > > Found by virtue of ipv6 raw sockets not honouring the per-socket > IP{,V6}_FREEBIND setting. > > Based on hits found via: > git grep '[.]ip_nonlocal_bind' > We fix both raw ipv6 sockets to honour IP{,V6}_FREEBIND and IP{,V6}_TRANSPARENT, > and we fix sctp sockets to honour IP{,V6}_TRANSPARENT (they already honoured > FREEBIND), and not just the ipv6 'ip_nonlocal_bind' sysctl. > > [...] Here is the summary with links: - net-ipv6: bugfix - raw & sctp - switch to ipv6_can_nonlocal_bind() https://git.kernel.org/netdev/net/c/630e4576f83a You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 1f56d9aae589..bf3646b57c68 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -298,7 +298,7 @@ static int rawv6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) */ v4addr = LOOPBACK4_IPV6; if (!(addr_type & IPV6_ADDR_MULTICAST) && - !sock_net(sk)->ipv6.sysctl.ip_nonlocal_bind) { + !ipv6_can_nonlocal_bind(sock_net(sk), inet)) { err = -EADDRNOTAVAIL; if (!ipv6_chk_addr(sock_net(sk), &addr->sin6_addr, dev, 0)) { diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index c3e89c776e66..bd08807c9e44 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -664,8 +664,8 @@ static int sctp_v6_available(union sctp_addr *addr, struct sctp_sock *sp) if (!(type & IPV6_ADDR_UNICAST)) return 0; - return sp->inet.freebind || net->ipv6.sysctl.ip_nonlocal_bind || - ipv6_chk_addr(net, in6, NULL, 0); + return ipv6_can_nonlocal_bind(net, &sp->inet) || + ipv6_chk_addr(net, in6, NULL, 0); } /* This function checks if the address is a valid address to be used for @@ -954,8 +954,7 @@ 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 || !(opt->inet.freebind || - net->ipv6.sysctl.ip_nonlocal_bind || + if (!dev || !(ipv6_can_nonlocal_bind(net, &opt->inet) || ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0))) { rcu_read_unlock();