netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next v1] net/ipv6: allow any source address for sendmsg pktinfo with ip_nonlocal_bind
@ 2018-07-25 11:19 Vincent Bernat
  2018-07-29 19:28 ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Vincent Bernat @ 2018-07-25 11:19 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI, netdev,
	Tom Herbert
  Cc: Vincent Bernat

When freebind feature is set of an IPv6 socket, any source address can
be used when sending UDP datagrams using IPv6 PKTINFO ancillary
message. Global non-local bind feature was added in commit
35a256fee52c ("ipv6: Nonlocal bind") for IPv6. This commit also allows
IPv6 source address spoofing when non-local bind feature is enabled.

Signed-off-by: Vincent Bernat <vincent@bernat.im>
---
 net/ipv6/datagram.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 201306b9b5ea..c46936563b15 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -800,7 +800,8 @@ int ip6_datagram_send_ctl(struct net *net, struct sock *sk,
 
 			if (addr_type != IPV6_ADDR_ANY) {
 				int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL;
-				if (!(inet_sk(sk)->freebind || inet_sk(sk)->transparent) &&
+				if (!(net->ipv6.sysctl.ip_nonlocal_bind ||
+				      inet_sk(sk)->freebind || inet_sk(sk)->transparent) &&
 				    !ipv6_chk_addr_and_flags(net, &src_info->ipi6_addr,
 							     dev, !strict, 0,
 							     IFA_F_TENTATIVE) &&
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-08-01 19:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-25 11:19 [net-next v1] net/ipv6: allow any source address for sendmsg pktinfo with ip_nonlocal_bind Vincent Bernat
2018-07-29 19:28 ` David Miller
2018-07-30  6:08   ` Vincent Bernat
2018-07-30 16:08     ` David Miller
2018-07-31 19:18       ` [PATCH net-next v1] net: add helpers checking if socket can be bound to nonlocal address Vincent Bernat
2018-08-01 16:50         ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).