OrangePi_CM5/net/ipv4
Lu Wei 02f8dfee75 tcp: prohibit TCP_REPAIR_OPTIONS if data was already sent
[ Upstream commit 0c175da7b0378445f5ef53904247cfbfb87e0b78 ]

If setsockopt with option name of TCP_REPAIR_OPTIONS and opt_code
of TCPOPT_SACK_PERM is called to enable sack after data is sent
and dupacks are received , it will trigger a warning in function
tcp_verify_left_out() as follows:

============================================
WARNING: CPU: 8 PID: 0 at net/ipv4/tcp_input.c:2132
tcp_timeout_mark_lost+0x154/0x160
tcp_enter_loss+0x2b/0x290
tcp_retransmit_timer+0x50b/0x640
tcp_write_timer_handler+0x1c8/0x340
tcp_write_timer+0xe5/0x140
call_timer_fn+0x3a/0x1b0
__run_timers.part.0+0x1bf/0x2d0
run_timer_softirq+0x43/0xb0
__do_softirq+0xfd/0x373
__irq_exit_rcu+0xf6/0x140

The warning is caused in the following steps:
1. a socket named socketA is created
2. socketA enters repair mode without build a connection
3. socketA calls connect() and its state is changed to TCP_ESTABLISHED
   directly
4. socketA leaves repair mode
5. socketA calls sendmsg() to send data, packets_out and sack_outs(dup
   ack receives) increase
6. socketA enters repair mode again
7. socketA calls setsockopt with TCPOPT_SACK_PERM to enable sack
8. retransmit timer expires, it calls tcp_timeout_mark_lost(), lost_out
   increases
9. sack_outs + lost_out > packets_out triggers since lost_out and
   sack_outs increase repeatly

In function tcp_timeout_mark_lost(), tp->sacked_out will be cleared if
Step7 not happen and the warning will not be triggered. As suggested by
Denis and Eric, TCP_REPAIR_OPTIONS should be prohibited if data was
already sent.

socket-tcp tests in CRIU has been tested as follows:
$ sudo ./test/zdtm.py run -t zdtm/static/socket-tcp*  --keep-going \
       --ignore-taint

socket-tcp* represent all socket-tcp tests in test/zdtm/static/.

Fixes: b139ba4e90 ("tcp: Repair connection-time negotiated parameters")
Signed-off-by: Lu Wei <luwei32@huawei.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-11-16 09:57:11 +01:00
..
bpfilter
…
netfilter netfilter: nft_fib: Fix for rpath check with VRF devices 2022-10-26 13:25:22 +02:00
Kconfig
…
Makefile
…
af_inet.c tcp/udp: Make early_demux back namespacified. 2022-11-10 18:14:26 +01:00
ah4.c
…
arp.c ipv4: Invalidate neighbour for broadcast address upon address addition 2022-04-13 21:00:57 +02:00
bpf_tcp_ca.c
…
cipso_ipv4.c cipso: Fix data-races around sysctl. 2022-07-21 21:20:08 +02:00
datagram.c udp: Update reuse->has_conns under reuseport_lock. 2022-10-30 09:41:19 +01:00
devinet.c net: socket: remove register_gifconf 2022-09-28 11:10:35 +02:00
esp4.c esp: limit skb_page_frag_refill use to a single page 2022-04-27 13:53:48 +02:00
esp4_offload.c esp: Fix BEET mode inter address family tunneling on GSO 2022-03-16 14:15:57 +01:00
fib_frontend.c ip: fix triggering of 'icmp redirect' 2022-09-08 11:11:40 +02:00
fib_lookup.h
…
fib_notifier.c
…
fib_rules.c ipv4: convert fib_num_tclassid_users to atomic_t 2021-12-08 09:03:26 +01:00
fib_semantics.c ipv4: Fix a data-race around sysctl_fib_multipath_use_neigh. 2022-07-29 17:19:20 +02:00
fib_trie.c ipv4: Fix a data-race around sysctl_fib_sync_mem. 2022-07-21 21:20:08 +02:00
fou.c
…
gre_demux.c
…
gre_offload.c
…
icmp.c ip: Fix data-races around sysctl_ip_no_pmtu_disc. 2022-07-29 17:19:12 +02:00
igmp.c igmp: Fix data-races around sysctl_igmp_qrv. 2022-08-03 12:00:46 +02:00
inet_connection_sock.c ip: Fix a data-race around sysctl_ip_autobind_reuse. 2022-07-29 17:19:13 +02:00
inet_diag.c inet_diag: fix kernel-infoleak for UDP sockets 2021-12-22 09:30:53 +01:00
inet_fragment.c inet: frags: annotate races around fqdir->dead and fqdir->high_thresh 2022-01-27 10:54:33 +01:00
inet_hashtables.c once: add DO_ONCE_SLOW() for sleepable contexts 2022-10-26 13:25:23 +02:00
inet_timewait_sock.c
…
inetpeer.c inetpeer: Fix data-races around sysctl. 2022-07-21 21:20:07 +02:00
ip_forward.c ip: Fix data-races around sysctl_ip_fwd_update_priority. 2022-07-29 17:19:12 +02:00
ip_fragment.c inet: frags: annotate races around fqdir->dead and fqdir->high_thresh 2022-01-27 10:54:33 +01:00
ip_gre.c erspan: do not assume transport header is always set 2022-06-29 08:59:48 +02:00
ip_input.c tcp/udp: Make early_demux back namespacified. 2022-11-10 18:14:26 +01:00
ip_options.c
…
ip_output.c net: Fix data-races around sysctl_[rw]mem_(max|default). 2022-08-31 17:15:19 +02:00
ip_sockglue.c net: Fix data-races around sysctl_optmem_max. 2022-08-31 17:15:20 +02:00
ip_tunnel.c net: Set true network header for ECN decapsulation 2021-08-04 12:46:42 +02:00
ip_tunnel_core.c tunnels: do not assume mac header is set in skb_tunnel_check_pmtu() 2022-07-07 17:52:19 +02:00
ip_vti.c
…
ipcomp.c
…
ipconfig.c net: ipconfig: Don't override command-line hostnames or domains 2021-06-18 10:00:05 +02:00
ipip.c
…
ipmr.c ipmr,ip6mr: acquire RTNL before calling ip[6]mr_free_table() on failure path 2022-02-16 12:54:25 +01:00
ipmr_base.c
…
metrics.c
…
netfilter.c
…
netlink.c
…
nexthop.c nh: fix scope used to find saddr when adding non gw nh 2022-11-03 23:57:54 +09:00
ping.c lsm,selinux: pass flowi_common instead of flowi to the LSM hooks 2022-06-09 10:21:09 +02:00
proc.c tcp: switch orphan_count to bare per-cpu counters 2021-11-18 14:04:08 +01:00
protocol.c
…
raw.c lsm,selinux: pass flowi_common instead of flowi to the LSM hooks 2022-06-09 10:21:09 +02:00
raw_diag.c
…
route.c ip: Fix data-races around sysctl_ip_fwd_use_pmtu. 2022-07-29 17:19:12 +02:00
syncookies.c tcp: Fix data-races around sysctl knobs related to SYN option. 2022-07-29 17:19:21 +02:00
sysctl_net_ipv4.c tcp/udp: Make early_demux back namespacified. 2022-11-10 18:14:26 +01:00
tcp.c tcp: prohibit TCP_REPAIR_OPTIONS if data was already sent 2022-11-16 09:57:11 +01:00
tcp_bbr.c tcp_bbr: fix u32 wrap bug in round logic if bbr_init() called after 2B packets 2021-08-18 08:59:13 +02:00
tcp_bic.c
…
tcp_bpf.c bpf, sockmap: Fix the sk->sk_forward_alloc warning of sk_stream_kill_queues 2022-11-16 09:57:08 +01:00
tcp_cdg.c
…
tcp_cong.c
…
tcp_cubic.c tcp_cubic: fix spurious Hystart ACK train detections for not-cwnd-limited flows 2021-12-01 09:19:06 +01:00
tcp_dctcp.c
…
tcp_dctcp.h
…
tcp_diag.c
…
tcp_fastopen.c tcp: Fix data-races around sysctl_tcp_fastopen_blackhole_timeout. 2022-07-29 17:19:18 +02:00
tcp_highspeed.c
…
tcp_htcp.c
…
tcp_hybla.c
…
tcp_illinois.c
…
tcp_input.c tcp: fix indefinite deferral of RTO with SACK reneging 2022-11-03 23:57:52 +09:00
tcp_ipv4.c tcp: fix a signed-integer-overflow bug in tcp_add_backlog() 2022-11-03 23:57:52 +09:00
tcp_lp.c
…
tcp_metrics.c tcp: Fix data-races around sysctl_tcp_no_ssthresh_metrics_save. 2022-08-03 12:00:45 +02:00
tcp_minisocks.c tcp: Fix a data-race around sysctl_tcp_rfc1337. 2022-07-29 17:19:22 +02:00
tcp_nv.c
…
tcp_offload.c net, gro: Set inner transport header offset in tcp/udp GRO hook 2021-08-12 13:22:05 +02:00
tcp_output.c tcp: fix tcp_cwnd_validate() to not forget is_cwnd_limited 2022-10-26 13:25:23 +02:00
tcp_rate.c tcp: ensure to use the most recently sent skb when filling the rate sample 2022-05-09 09:05:03 +02:00
tcp_recovery.c tcp: Fix data-races around sysctl_tcp_recovery. 2022-07-29 17:19:21 +02:00
tcp_scalable.c
…
tcp_timer.c tcp: Fix a data-race around sysctl_tcp_thin_linear_timeouts. 2022-07-29 17:19:21 +02:00
tcp_ulp.c
…
tcp_vegas.c
…
tcp_vegas.h
…
tcp_veno.c
…
tcp_westwood.c
…
tcp_yeah.c
…
tunnel4.c
…
udp.c udp: Update reuse->has_conns under reuseport_lock. 2022-10-30 09:41:19 +01:00
udp_bpf.c bpf, sockmap, udp: sk_prot needs inuse_idx set for proc stats 2021-07-28 14:35:37 +02:00
udp_diag.c
…
udp_impl.h
…
udp_offload.c net, gro: Set inner transport header offset in tcp/udp GRO hook 2021-08-12 13:22:05 +02:00
udp_tunnel_core.c
…
udp_tunnel_nic.c udp_tunnel: Fix end of loop test in udp_tunnel_nic_unregister() 2022-03-02 11:42:51 +01:00
udp_tunnel_stub.c
…
udplite.c
…
xfrm4_input.c
…
xfrm4_output.c
…
xfrm4_policy.c
…
xfrm4_protocol.c net: xfrm: unexport __init-annotated xfrm4_protocol_init() 2022-06-14 18:32:40 +02:00
xfrm4_state.c
…
xfrm4_tunnel.c
…