android_kernel_motorola_sm6375/net/ipv6
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Kuniyuki Iwashima 9d1264c914 dccp/tcp: Reset saddr on failure after inet6?_hash_connect().
[ Upstream commit 77934dc6db0d2b111a8f2759e9ad2fb67f5cffa5 ]

When connect() is called on a socket bound to the wildcard address,
we change the socket's saddr to a local address.  If the socket
fails to connect() to the destination, we have to reset the saddr.

However, when an error occurs after inet_hash6?_connect() in
(dccp|tcp)_v[46]_conect(), we forget to reset saddr and leave
the socket bound to the address.

From the user's point of view, whether saddr is reset or not varies
with errno.  Let's fix this inconsistent behaviour.

Note that after this patch, the repro [0] will trigger the WARN_ON()
in inet_csk_get_port() again, but this patch is not buggy and rather
fixes a bug papering over the bhash2's bug for which we need another
fix.

For the record, the repro causes -EADDRNOTAVAIL in inet_hash6_connect()
by this sequence:

  s1 = socket()
  s1.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
  s1.bind(('127.0.0.1', 10000))
  s1.sendto(b'hello', MSG_FASTOPEN, (('127.0.0.1', 10000)))
  # or s1.connect(('127.0.0.1', 10000))

  s2 = socket()
  s2.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
  s2.bind(('0.0.0.0', 10000))
  s2.connect(('127.0.0.1', 10000))  # -EADDRNOTAVAIL

  s2.listen(32)  # WARN_ON(inet_csk(sk)->icsk_bind2_hash != tb2);

[0]: https://syzkaller.appspot.com/bug?extid=015d756bbd1f8b5c8f09

Fixes: 3df80d9320 ("[DCCP]: Introduce DCCPv6")
Fixes: 7c657876b6 ("[DCCP]: Initial implementation")
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Acked-by: Joanne Koong <joannelkoong@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-12-08 11:22:59 +01:00
..
ila
netfilter netfilter: nft_fib: Fix for rpath check with VRF devices 2022-10-26 13:22:25 +02:00
addrconf.c ipv6: take care of disable_policy when restoring routes 2022-07-07 17:36:47 +02:00
addrconf_core.c
addrlabel.c ipv6: addrlabel: fix infoleak when sending struct ifaddrlblmsg to network 2022-11-25 17:42:05 +01:00
af_inet6.c ip: Fix data-races around sysctl_ip_no_pmtu_disc. 2022-07-29 17:14:10 +02:00
ah6.c
anycast.c
calipso.c
datagram.c
esp6.c esp: limit skb_page_frag_refill use to a single page 2022-07-12 16:30:45 +02:00
esp6_offload.c
exthdrs.c
exthdrs_core.c
exthdrs_offload.c
fib6_notifier.c
fib6_rules.c ipv6: fix memory leak in fib6_rule_suppress 2021-12-08 09:01:13 +01:00
fou6.c
icmp.c
inet6_connection_sock.c
inet6_hashtables.c secure_seq: use the 64 bits of the siphash for port offset calculation 2022-06-06 08:33:49 +02:00
ip6_checksum.c
ip6_fib.c ipv6: annotate accesses to fn->fn_sernum 2022-02-01 17:24:38 +01:00
ip6_flowlabel.c
ip6_gre.c erspan: do not assume transport header is always set 2022-06-29 08:58:46 +02:00
ip6_icmp.c
ip6_input.c tcp/udp: Make early_demux back namespacified. 2022-11-10 17:57:55 +01:00
ip6_offload.c gso: do not skip outer ip header in case of ipip and net_failover 2022-03-02 11:41:06 +01:00
ip6_offload.h
ip6_output.c ipv6: fix panic when forwarding a pkt with no in6 dev 2022-04-20 09:19:38 +02:00
ip6_tunnel.c ipv6_tunnel: Rate limit warning messages 2022-02-01 17:24:36 +01:00
ip6_udp_tunnel.c
ip6_vti.c ip6_vti: initialize __ip6_tnl_parm struct in vti6_siocdevprivate 2022-01-11 15:23:33 +01:00
ip6mr.c ipv6: make mc_forwarding atomic 2022-04-15 14:18:32 +02:00
ipcomp6.c
ipv6_sockglue.c tcp/udp: Fix memory leak in ipv6_renew_options(). 2022-11-10 17:57:54 +01:00
Kconfig
Makefile
mcast.c
mcast_snoop.c
mip6.c
ndisc.c
netfilter.c
output_core.c
ping.c net: ping6: Fix memleak in ipv6_renew_options(). 2022-08-03 11:59:39 +02:00
proc.c
protocol.c
raw.c
reassembly.c
route.c ipv6: fix WARNING in ip6_route_net_exit_late() 2022-11-10 17:57:52 +01:00
seg6.c ipv6: sr: fix out-of-bounds read when setting HMAC data. 2022-09-15 12:04:55 +02:00
seg6_hmac.c net: ipv6: unexport __init-annotated seg6_hmac_net_init() 2022-07-07 17:36:49 +02:00
seg6_iptunnel.c seg6: fix skb checksum evaluation in SRH encapsulation/insertion 2022-07-21 20:59:23 +02:00
seg6_local.c seg6: fix skb checksum in SRv6 End.B6 and End.B6.Encaps behaviors 2022-07-21 20:59:23 +02:00
sit.c ipv6/sit: fix ipip6_tunnel_get_prl return value 2022-07-07 17:36:51 +02:00
syncookies.c tcp: Fix data-races around sysctl_tcp_syncookies. 2022-07-29 17:14:13 +02:00
sysctl_net_ipv6.c
tcp_ipv6.c dccp/tcp: Reset saddr on failure after inet6?_hash_connect(). 2022-12-08 11:22:59 +01:00
tcpv6_offload.c
tunnel6.c
udp.c tcp/udp: Make early_demux back namespacified. 2022-11-10 17:57:55 +01:00
udp_impl.h
udp_offload.c
udplite.c
xfrm6_input.c
xfrm6_output.c xfrm: fix tunnel model fragmentation behavior 2022-04-15 14:17:56 +02:00
xfrm6_policy.c xfrm: Fix ignored return value in xfrm6_init() 2022-12-08 11:22:58 +01:00
xfrm6_protocol.c
xfrm6_state.c
xfrm6_tunnel.c