net: ipv6: reset daddr and dport in sk if connect() fails
Subsystems (3)
PATCH v3 1/1 net: ipv6: reset daddr and dport in sk if connect() fails
From: Wei Wang <[email protected]>
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.
v3: add TCP_ESTABLISHED state check in udp_v6_early_demux()
v2: fix compilation error
--- net/ipv6/datagram.c | 8 +++++++- net/ipv6/udp.c | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-)
net/ipv6/datagram.c +7 -1
@@ -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);
net/ipv6/udp.c +2 -1
@@ -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 ;
Signature · 1 line
2.13.1.611.g7e3b11ae1-goog
David Miller
maintainerFrom: Wei Wang <[email protected]>
Date: Fri, 23 Jun 2017 15:25:37 -0700
Quoted 9 lines
From: Wei Wang <[email protected]>
In
__ip6_datagram_connect(), resetsk->sk_v6_daddrandinet->dportif error occurs.
Inudp_v6_early_demux(), check forsk_stateto make sure it is inTCP_ESTABLISHEDstate.
Together, it makes sure unconnected UDP socket won't be considered as a valid candidate for early demux.
Quoted 7 lines
Fixes 5425077d73e0 ("net: ipv6: Add early demux handler for UDP unicast")v3: add
TCP_ESTABLISHEDstate check inudp_v6_early_demux()
v2: fix compilation errorSigned-off-by Wei Wang <[email protected]>
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.
Quoted 23 lines · David Miller
From: Wei Wang <[email protected]>
Date: Fri, 23 Jun 2017 15:25:37 -0700Quoted 9 lines
From: Wei Wang <[email protected]>
In
__ip6_datagram_connect(), resetsk->sk_v6_daddrandinet->dportif error occurs.
Inudp_v6_early_demux(), check forsk_stateto make sure it is inTCP_ESTABLISHEDstate.
Together, it makes sure unconnected UDP socket won't be considered as a valid candidate for early demux.Quoted 7 lines
Fixes 5425077d73e0 ("net: ipv6: Add early demux handler for UDP unicast")v3: add
TCP_ESTABLISHEDstate check inudp_v6_early_demux()
v2: fix compilation errorSigned-off-by Wei Wang <[email protected]>Please don't format the tag area like this, if you want to put a change log put it first.
Quoted 6 lines
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