All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch net] ipv6: explicitly initialize udp6_addr in udp_sock_create6()
@ 2018-12-19  5:17 Cong Wang
  2018-12-19 20:10 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Wang @ 2018-12-19  5:17 UTC (permalink / raw)
  To: netdev; +Cc: Cong Wang, Jon Maloy

syzbot reported the use of uninitialized udp6_addr::sin6_scope_id.
We can just set ::sin6_scope_id to zero, as tunnels are unlikely
to use an IPv6 address that needs a scope id and there is no
interface to bind in this context.

For net-next, it looks different as we have cfg->bind_ifindex there
so we can probably call ipv6_iface_scope_id().

Same for ::sin6_flowinfo, tunnels don't use it.

Fixes: 8024e02879dd ("udp: Add udp_sock_create for UDP tunnels to open listener socket")
Reported-by: syzbot+c56449ed3652e6720f30@syzkaller.appspotmail.com
Cc: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 net/ipv6/ip6_udp_tunnel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_udp_tunnel.c b/net/ipv6/ip6_udp_tunnel.c
index b283f293ee4a..caad40d6e74d 100644
--- a/net/ipv6/ip6_udp_tunnel.c
+++ b/net/ipv6/ip6_udp_tunnel.c
@@ -15,7 +15,7 @@
 int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
 		     struct socket **sockp)
 {
-	struct sockaddr_in6 udp6_addr;
+	struct sockaddr_in6 udp6_addr = {};
 	int err;
 	struct socket *sock = NULL;
 
@@ -42,6 +42,7 @@ int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
 		goto error;
 
 	if (cfg->peer_udp_port) {
+		memset(&udp6_addr, 0, sizeof(udp6_addr));
 		udp6_addr.sin6_family = AF_INET6;
 		memcpy(&udp6_addr.sin6_addr, &cfg->peer_ip6,
 		       sizeof(udp6_addr.sin6_addr));
-- 
2.19.2

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

* Re: [Patch net] ipv6: explicitly initialize udp6_addr in udp_sock_create6()
  2018-12-19  5:17 [Patch net] ipv6: explicitly initialize udp6_addr in udp_sock_create6() Cong Wang
@ 2018-12-19 20:10 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-12-19 20:10 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, jon.maloy

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Tue, 18 Dec 2018 21:17:44 -0800

> syzbot reported the use of uninitialized udp6_addr::sin6_scope_id.
> We can just set ::sin6_scope_id to zero, as tunnels are unlikely
> to use an IPv6 address that needs a scope id and there is no
> interface to bind in this context.
> 
> For net-next, it looks different as we have cfg->bind_ifindex there
> so we can probably call ipv6_iface_scope_id().
> 
> Same for ::sin6_flowinfo, tunnels don't use it.
> 
> Fixes: 8024e02879dd ("udp: Add udp_sock_create for UDP tunnels to open listener socket")
> Reported-by: syzbot+c56449ed3652e6720f30@syzkaller.appspotmail.com
> Cc: Jon Maloy <jon.maloy@ericsson.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

Applied, thanks Cong.

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

end of thread, other threads:[~2018-12-19 20:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-19  5:17 [Patch net] ipv6: explicitly initialize udp6_addr in udp_sock_create6() Cong Wang
2018-12-19 20:10 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.