Skip to content

Commit b3b2854

Browse files
Florian Westphaldavem330
authored andcommitted
mptcp: sendmsg: reset iter on error redux
This fix wasn't correct: When this function is invoked from the retransmission worker, the iterator contains garbage and resetting it causes a crash. As the work queue should not be performance critical also zero the msghdr struct. Fixes: 3575938 "(mptcp: sendmsg: reset iter on error)" Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bd71ea6 commit b3b2854

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

net/mptcp/protocol.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,8 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
740740
ret = do_tcp_sendpages(ssk, page, offset, psize,
741741
msg->msg_flags | MSG_SENDPAGE_NOTLAST | MSG_DONTWAIT);
742742
if (ret <= 0) {
743-
iov_iter_revert(&msg->msg_iter, psize);
743+
if (!retransmission)
744+
iov_iter_revert(&msg->msg_iter, psize);
744745
return ret;
745746
}
746747

@@ -1392,7 +1393,9 @@ static void mptcp_worker(struct work_struct *work)
13921393
struct mptcp_data_frag *dfrag;
13931394
u64 orig_write_seq;
13941395
size_t copied = 0;
1395-
struct msghdr msg;
1396+
struct msghdr msg = {
1397+
.msg_flags = MSG_DONTWAIT,
1398+
};
13961399
long timeo = 0;
13971400

13981401
lock_sock(sk);
@@ -1425,7 +1428,6 @@ static void mptcp_worker(struct work_struct *work)
14251428

14261429
lock_sock(ssk);
14271430

1428-
msg.msg_flags = MSG_DONTWAIT;
14291431
orig_len = dfrag->data_len;
14301432
orig_offset = dfrag->offset;
14311433
orig_write_seq = dfrag->data_seq;

0 commit comments

Comments
 (0)