Skip to content

Commit 3575938

Browse files
Florian Westphaldavem330
authored andcommitted
mptcp: sendmsg: reset iter on error
Once we've copied data from the iterator we need to revert in case we end up not sending any data. This bug doesn't trigger with normal 'poll' based tests, because we only feed a small chunk of data to kernel after poll indicated POLLOUT. With blocking IO and large writes this triggers. Receiver ends up with less data than it should get. Fixes: 72511aa ("mptcp: avoid blocking in tcp_sendpages") Signed-off-by: Florian Westphal <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0688854 commit 3575938

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/mptcp/protocol.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,10 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
725725
if (!psize)
726726
return -EINVAL;
727727

728-
if (!sk_wmem_schedule(sk, psize + dfrag->overhead))
728+
if (!sk_wmem_schedule(sk, psize + dfrag->overhead)) {
729+
iov_iter_revert(&msg->msg_iter, psize);
729730
return -ENOMEM;
731+
}
730732
} else {
731733
offset = dfrag->offset;
732734
psize = min_t(size_t, dfrag->data_len, avail_size);
@@ -737,8 +739,10 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
737739
*/
738740
ret = do_tcp_sendpages(ssk, page, offset, psize,
739741
msg->msg_flags | MSG_SENDPAGE_NOTLAST | MSG_DONTWAIT);
740-
if (ret <= 0)
742+
if (ret <= 0) {
743+
iov_iter_revert(&msg->msg_iter, psize);
741744
return ret;
745+
}
742746

743747
frag_truesize += ret;
744748
if (!retransmission) {

0 commit comments

Comments
 (0)