Skip to contentSkip to conversation

Patch "tcp: fix various issues for sockets morphing to listen state" has been added to the 4.9-stable tree

PATCH [email protected] 1 participant 1 message Mar 18, 2017

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

tcp: fix various issues for sockets morphing to listen state

to the 4.9-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
tcp-fix-various-issues-for-sockets-morphing-to-listen-state.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Sat Mar 18 22:03:25 CST 2017

From: Eric Dumazet <[email protected]>
Date: Fri, 3 Mar 2017 14:08:21 -0800
Subject: tcp: fix various issues for sockets morphing to listen state

From: Eric Dumazet <[email protected]>

[ Upstream commit 02b2faaf0af1d85585f6d6980e286d53612acfc2 ]

Dmitry Vyukov reported a divide by 0 triggered by syzkaller, exploiting tcp_disconnect() path that was never really considered and/or used before syzkaller ;)

I was not able to reproduce the bug, but it seems issues here are the three possible actions that assumed they would never trigger on a listener.

1) tcp_write_timer_handler
2) tcp_delack_timer_handler
3) MTU reduction

Only IPv6 MTU reduction was properly testing TCP_CLOSE and TCP_LISTEN
states from tcp_v6_mtu_reduced()

---
 net/ipv4/tcp_ipv4.c  |    7 +++++--
 net/ipv4/tcp_timer.c |    6 ++++--
 2 files changed, 9 insertions(+), 4 deletions(-)
net/ipv4/tcp_ipv4.c +5 -2
@@ -269,10 +269,13 @@ EXPORT_SYMBOL(tcp_v4_connect);
  */
 void tcp_v4_mtu_reduced(struct sock *sk)
 {
-	struct dst_entry *dst;
 	struct inet_sock *inet = inet_sk(sk);
-	u32 mtu = tcp_sk(sk)->mtu_info;
+	struct dst_entry *dst;
+	u32 mtu;
 
+	if ((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE))
+		return;
+	mtu = tcp_sk(sk)->mtu_info;
 	dst = inet_csk_update_pmtu(sk, mtu);
 	if (!dst)
 		return;
net/ipv4/tcp_timer.c +4 -2
@@ -249,7 +249,8 @@ void tcp_delack_timer_handler(struct soc
 
 	sk_mem_reclaim_partial(sk);
 
-	if (sk->sk_state == TCP_CLOSE || !(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
+	if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) ||
+	    !(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
 		goto out;
 
 	if (time_after(icsk->icsk_ack.timeout, jiffies)) {
@@ -552,7 +553,8 @@ void tcp_write_timer_handler(struct sock
 	struct inet_connection_sock *icsk = inet_csk(sk);
 	int event;
 
-	if (sk->sk_state == TCP_CLOSE || !icsk->icsk_pending)
+	if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) ||
+	    !icsk->icsk_pending)
 		goto out;
 
 	if (time_after(icsk->icsk_timeout, jiffies)) {

Patches currently in stable-queue which might be from [email protected] are

queue-4.9/tcp-fix-various-issues-for-sockets-morphing-to-listen-state.patch queue-4.9/tcp-dccp-block-bh-for-syn-processing.patch queue-4.9/dccp-fix-use-after-free-in-dccp_feat_activate_values.patch queue-4.9/net-fix-socket-refcounting-in-skb_complete_tx_timestamp.patch queue-4.9/net-net_enable_timestamp-can-be-called-from-irq-contexts.patch queue-4.9/dccp-unlock-sock-before-calling-sk_free.patch queue-4.9/net-don-t-call-strlen-on-the-user-buffer-in-packet_bind_spkt.patch queue-4.9/net-fix-socket-refcounting-in-skb_complete_wifi_ack.patch queue-4.9/ipv6-orphan-skbs-in-reassembly-unit.patch