Skip to contentSkip to conversation

Patch "tcp: fix return value for partial writes" has been added to the 4.8-stable tree

PATCH [email protected] 1 participant 1 message Nov 18, 2016

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 return value for partial writes

to the 4.8-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-return-value-for-partial-writes.patch
and it can be found in the queue-4.8 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 Fri Nov 18 11:35:46 CET 2016

From: Eric Dumazet <[email protected]>
Date: Wed, 2 Nov 2016 14:41:50 -0700
Subject: tcp: fix return value for partial writes

From: Eric Dumazet <[email protected]>

[ Upstream commit 79d8665b9545e128637c51cf7febde9c493b6481 ]

After my commit, tcp_sendmsg() might restart its loop after processing socket backlog.

If sk_err is set, we blindly return an error, even though we copied data to user space before.

We should instead return number of bytes that could be copied, otherwise user space might resend data and corrupt the stream.

This might happen if another thread is using recvmsg(MSG_ERRQUEUE) to process timestamps.

Issue was diagnosed by Soheil and Willem, big kudos to them !

Fixes d41a69f1d390f ("tcp: make tcp_sendmsg() aware of socket backlog")
Cc Willem de Bruijn <[email protected]>
Cc Soheil Hassas Yeganeh <[email protected]>
Cc Yuchung Cheng <[email protected]>
Cc Neal Cardwell <[email protected]>
---
 net/ipv4/tcp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp.c +1 -1
@@ -1145,7 +1145,7 @@ restart:
 
 	err = -EPIPE;
 	if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
-		goto out_err;
+		goto do_error;
 
 	sg = !!(sk->sk_route_caps & NETIF_F_SG);
 

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

queue-4.8/net-__skb_flow_dissect-must-cap-its-return-value.patch queue-4.8/tcp-take-care-of-truncations-done-by-sk_filter.patch queue-4.8/net-clear-sk_err_soft-in-sk_clone_lock.patch queue-4.8/dccp-do-not-release-listeners-too-soon.patch queue-4.8/net-mangle-zero-checksum-in-skb_checksum_help.patch queue-4.8/tcp-fix-return-value-for-partial-writes.patch queue-4.8/ipv6-dccp-fix-out-of-bound-access-in-dccp_v6_err.patch queue-4.8/ipv6-dccp-add-missing-bind_conflict-to-dccp_ipv6_mapped.patch queue-4.8/tcp-fix-potential-memory-corruption.patch queue-4.8/dccp-do-not-send-reset-to-already-closed-sockets.patch queue-4.8/dccp-fix-out-of-bound-access-in-dccp_v4_err.patch queue-4.8/sock-fix-sendmmsg-for-partial-sendmsg.patch