]> git.baikalelectronics.ru Git - kernel.git/commit
tcp: fix return value for partial writes
authorEric Dumazet <edumazet@google.com>
Wed, 2 Nov 2016 21:41:50 +0000 (14:41 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Nov 2016 20:12:06 +0000 (16:12 -0400)
commit7897aea509d541a9fcd3b36564747b1125b6a2ff
tree5a25d00198c300afd94f10b59ee5e8c87ee9d0d0
parent24d05de5f993eb16486c6073ce4c7e3dc6b2c239
tcp: fix return value for partial writes

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: 0cfb5406b3cdd ("tcp: make tcp_sendmsg() aware of socket backlog")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Cc: Soheil Hassas Yeganeh <soheil@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Tested-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp.c