android_kernel_samsung_msm8976/net/ipv4
Eric Dumazet 5cddf03d36 tcp: limit payload size of sacked skbs
commit 3b4929f65b0d8249f19a50245cd88ed1a2f78cff upstream.

Jonathan Looney reported that TCP can trigger the following crash
in tcp_shifted_skb() :

	BUG_ON(tcp_skb_pcount(skb) < pcount);

This can happen if the remote peer has advertized the smallest
MSS that linux TCP accepts : 48

An skb can hold 17 fragments, and each fragment can hold 32KB
on x86, or 64KB on PowerPC.

This means that the 16bit witdh of TCP_SKB_CB(skb)->tcp_gso_segs
can overflow.

Note that tcp_sendmsg() builds skbs with less than 64KB
of payload, so this problem needs SACK to be enabled.
SACK blocks allow TCP to coalesce multiple skbs in the retransmit
queue, thus filling the 17 fragments to maximal capacity.

CVE-2019-11477 -- u16 overflow of TCP_SKB_CB(skb)->tcp_gso_segs

Backport notes, provided by Joao Martins <joao.m.martins@oracle.com>

v4.15 or since commit 737ff314563 ("tcp: use sequence distance to
detect reordering") had switched from the packet-based FACK tracking and
switched to sequence-based.

v4.14 and older still have the old logic and hence on
tcp_skb_shift_data() needs to retain its original logic and have
@fack_count in sync. In other words, we keep the increment of pcount with
tcp_skb_pcount(skb) to later used that to update fack_count. To make it
more explicit we track the new skb that gets incremented to pcount in
@next_pcount, and we get to avoid the constant invocation of
tcp_skb_pcount(skb) all together.

Fixes: 832d11c5cd ("tcp: Try to restore large SKBs while SACK processing")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Jonathan Looney <jtl@netflix.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Reviewed-by: Tyler Hicks <tyhicks@canonical.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Bruce Curtis <brucec@netflix.com>
Cc: Jonathan Lemon <jonathan.lemon@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-07-27 22:11:09 +02:00
..
netfilter Revert "netfilter: have ip*t REJECT set the sock err when an icmp is to be sent" 2019-07-27 21:51:03 +02:00
Kconfig net: diag: Support destroying TCP sockets. 2016-05-18 14:36:07 +05:30
Makefile
af_inet.c udp: ipv4: Add udp early demux 2019-07-27 22:07:48 +02:00
ah4.c ipv4: properly refresh rtable entries on pmtu/redirect events 2019-07-27 21:45:24 +02:00
arp.c arp: make arp_invalidate static 2019-07-27 22:08:26 +02:00
cipso_ipv4.c netlabel: fix out-of-bounds memory accesses 2019-07-27 22:10:24 +02:00
datagram.c
devinet.c net/ipv4: queue work on power efficient wq 2019-07-27 22:11:05 +02:00
esp4.c xfrm: Return error on unknown encap_type in init_state 2019-07-27 21:46:27 +02:00
fib_frontend.c ipv4: remove BUG_ON() from fib_compute_spec_dst 2019-07-27 21:52:57 +02:00
fib_lookup.h
fib_rules.c
fib_semantics.c ipv4: fix a race in update_or_create_fnhe() 2019-07-27 22:10:30 +02:00
fib_trie.c
gre.c
icmp.c net: inet: Support UID-based routing in IP protocols. 2019-07-27 21:50:59 +02:00
igmp.c ipv4: igmp: guard against silly MTU values 2019-07-27 22:08:52 +02:00
inet_connection_sock.c net: inet: Support UID-based routing in IP protocols. 2019-07-27 21:50:59 +02:00
inet_diag.c net: inet: diag: expose the socket mark to privileged processes. 2019-07-27 21:50:56 +02:00
inet_fragment.c
inet_hashtables.c
inet_lro.c
inet_timewait_sock.c soreuseport: initialise timewait reuseport field 2019-07-27 21:52:18 +02:00
inetpeer.c net: ipv4: use a dedicated counter for icmp_v4 redirect packets 2019-07-27 22:07:53 +02:00
ip_forward.c
ip_fragment.c ANDROID: Revert "net: increase fragment memory usage limits" 2019-07-27 21:51:06 +02:00
ip_gre.c
ip_input.c IPv4: early demux can return an error code 2019-07-27 22:07:51 +02:00
ip_options.c
ip_output.c ipv4: ip_do_fragment: Preserve skb_iif during fragmentation 2019-07-27 22:10:35 +02:00
ip_sockglue.c netfilter: drop outermost socket lock in getsockopt() 2019-07-27 21:49:20 +02:00
ip_tunnel.c ipv4: igmp: guard against silly MTU values 2019-07-27 22:08:52 +02:00
ip_vti.c Make the VTI code compile. 2019-07-27 21:51:05 +02:00
ipcomp.c ipv4: properly refresh rtable entries on pmtu/redirect events 2019-07-27 21:45:24 +02:00
ipconfig.c
ipip.c
ipmr.c ipv4: Fix potential Spectre v1 vulnerability 2019-07-27 21:53:29 +02:00
netfilter.c
ping.c net: inet: Support UID-based routing in IP protocols. 2019-07-27 21:50:59 +02:00
proc.c
protocol.c
raw.c ipv4: Fix raw socket lookup for local traffic 2019-07-27 22:10:37 +02:00
route.c ipv4: fix a race in update_or_create_fnhe() 2019-07-27 22:10:30 +02:00
syncookies.c net: inet: Support UID-based routing in IP protocols. 2019-07-27 21:50:59 +02:00
sysctl_net_ipv4.c ipv4: Return EINVAL when ping_group_range sysctl doesn't map to user ns 2019-07-27 21:50:25 +02:00
sysfs_net_ipv4.c
tcp.c tcp: limit payload size of sacked skbs 2019-07-27 22:11:09 +02:00
tcp_bic.c
tcp_cong.c tcp: disallow cwnd undo when switching congestion control 2019-07-27 21:44:29 +02:00
tcp_cubic.c tcp_cubic: do not set epoch_start in the future 2017-04-18 12:17:39 +02:00
tcp_diag.c net: diag: Support destroying TCP sockets. 2016-05-18 14:36:07 +05:30
tcp_fastopen.c
tcp_highspeed.c
tcp_htcp.c
tcp_hybla.c
tcp_illinois.c
tcp_input.c tcp: limit payload size of sacked skbs 2019-07-27 22:11:09 +02:00
tcp_ipv4.c net: Replace more instances of ACCESS_ONCE w/ READ_ONCE 2019-07-27 22:08:51 +02:00
tcp_lp.c tcp: fix wraparound issue in tcp_lp 2019-07-27 21:44:45 +02:00
tcp_memcontrol.c
tcp_metrics.c
tcp_minisocks.c tcp: remove BUG_ON() in tcp_check_req() 2019-07-27 21:51:29 +02:00
tcp_output.c tcp: limit payload size of sacked skbs 2019-07-27 22:11:09 +02:00
tcp_probe.c
tcp_scalable.c
tcp_timer.c tcp: fix various issues for sockets morphing to listen state 2019-07-27 21:44:00 +02:00
tcp_vegas.c
tcp_vegas.h
tcp_veno.c
tcp_westwood.c
tcp_yeah.c
tunnel4.c
udp.c net: Replace more instances of ACCESS_ONCE w/ READ_ONCE 2019-07-27 22:08:51 +02:00
udp_diag.c net: inet: diag: expose the socket mark to privileged processes. 2019-07-27 21:50:56 +02:00
udp_impl.h
udplite.c
xfrm4_input.c xfrm: Reinject transport-mode packets through tasklet 2019-07-27 21:46:20 +02:00
xfrm4_mode_beet.c
xfrm4_mode_transport.c
xfrm4_mode_tunnel.c
xfrm4_output.c
xfrm4_policy.c BACKPORT: net: xfrm: support setting an output mark. 2019-07-27 21:51:33 +02:00
xfrm4_state.c
xfrm4_tunnel.c