]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: ipv6: keep sk status consistent after datagram connect failure
authorPaolo Abeni <pabeni@redhat.com>
Mon, 12 Mar 2018 13:54:23 +0000 (14:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 9 Jan 2021 12:35:49 +0000 (13:35 +0100)
commitc49f30b2979bfc8701620e598558f29a48e07234
tree159124419714470177d2aa360ad96095f56dd643
parent25d264a3cfa3484adb52f3fb22cbc56e0975e511
net: ipv6: keep sk status consistent after datagram connect failure

commit 2f987a76a97773beafbc615b9c4d8fe79129a7f4 upstream.

On unsuccesful ip6_datagram_connect(), if the failure is caused by
ip6_datagram_dst_update(), the sk peer information are cleared, but
the sk->sk_state is preserved.

If the socket was already in an established status, the overall sk
status is inconsistent and fouls later checks in datagram code.

Fix this saving the old peer information and restoring them in
case of failure. This also aligns ipv6 datagram connect() behavior
with ipv4.

v1 -> v2:
 - added missing Fixes tag

Fixes: 85cb73ff9b74 ("net: ipv6: reset daddr and dport in sk if connect() fails")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv6/datagram.c