Message ID | 20170623222537.130493-1-tracywwnj@gmail.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
From: Wei Wang <tracywwnj@gmail.com> Date: Fri, 23 Jun 2017 15:25:37 -0700 > From: Wei Wang <weiwan@google.com> > > In __ip6_datagram_connect(), reset sk->sk_v6_daddr and inet->dport if > error occurs. > In udp_v6_early_demux(), check for sk_state to make sure it is in > TCP_ESTABLISHED state. > Together, it makes sure unconnected UDP socket won't be considered as a > valid candidate for early demux. > > Fixes: 5425077d73e0 ("net: ipv6: Add early demux handler for UDP unicast") > > v3: add TCP_ESTABLISHED state check in udp_v6_early_demux() > v2: fix compilation error > > Signed-off-by: Wei Wang <weiwan@google.com> > Acked-by: Maciej Żenczykowski <maze@google.com> Please don't format the tag area like this, if you want to put a change log put it first. Then put all of the tags (Fixes:, Signed-off-by:, Acked-by:, etc.) together with no empty line separators, at the end. I fixed it up this time. Applied and queued up for -stable, thanks.
On Sun, Jun 25, 2017 at 8:46 AM, David Miller <davem@davemloft.net> wrote: > From: Wei Wang <tracywwnj@gmail.com> > Date: Fri, 23 Jun 2017 15:25:37 -0700 > >> From: Wei Wang <weiwan@google.com> >> >> In __ip6_datagram_connect(), reset sk->sk_v6_daddr and inet->dport if >> error occurs. >> In udp_v6_early_demux(), check for sk_state to make sure it is in >> TCP_ESTABLISHED state. >> Together, it makes sure unconnected UDP socket won't be considered as a >> valid candidate for early demux. >> >> Fixes: 5425077d73e0 ("net: ipv6: Add early demux handler for UDP unicast") >> >> v3: add TCP_ESTABLISHED state check in udp_v6_early_demux() >> v2: fix compilation error >> >> Signed-off-by: Wei Wang <weiwan@google.com> >> Acked-by: Maciej Żenczykowski <maze@google.com> > > Please don't format the tag area like this, if you want to put a change > log put it first. > > Then put all of the tags (Fixes:, Signed-off-by:, Acked-by:, etc.) > together with no empty line separators, at the end. > > I fixed it up this time. > > Applied and queued up for -stable, thanks. Got it. Will note it down. Thanks for taking care of it. Wei
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index e011122ebd43..5c786f5ab961 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -250,8 +250,14 @@ int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, */ err = ip6_datagram_dst_update(sk, true); - if (err) + if (err) { + /* Reset daddr and dport so that udp_v6_early_demux() + * fails to find this socket + */ + memset(&sk->sk_v6_daddr, 0, sizeof(sk->sk_v6_daddr)); + inet->inet_dport = 0; goto out; + } sk->sk_state = TCP_ESTABLISHED; sk_set_txhash(sk); diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 2b33847bf931..d494b2621b11 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -880,7 +880,8 @@ static struct sock *__udp6_lib_demux_lookup(struct net *net, struct sock *sk; udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) { - if (INET6_MATCH(sk, net, rmt_addr, loc_addr, ports, dif)) + if (sk->sk_state == TCP_ESTABLISHED && + INET6_MATCH(sk, net, rmt_addr, loc_addr, ports, dif)) return sk; /* Only check first socket in chain */ break;