netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] mptcp: sendmsg: reset iter on error redux
@ 2020-08-16 21:14 Florian Westphal
  2020-08-17  4:12 ` David Miller
  2020-08-17 15:28 ` Jakub Kicinski
  0 siblings, 2 replies; 3+ messages in thread
From: Florian Westphal @ 2020-08-16 21:14 UTC (permalink / raw)
  To: netdev; +Cc: mathew.j.martineau, matthieu.baerts, pabeni, Florian Westphal

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: 35759383133f64d "(mptcp: sendmsg: reset iter on error)"
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 Brown paper bag patch.  I will see if having distinct functions
 for the mtcp_sendmsg and retransmit wq case is feasible/more
 appropriate.

 net/mptcp/protocol.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 2499757bf899..f6561d126110 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -740,7 +740,8 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
 	ret = do_tcp_sendpages(ssk, page, offset, psize,
 			       msg->msg_flags | MSG_SENDPAGE_NOTLAST | MSG_DONTWAIT);
 	if (ret <= 0) {
-		iov_iter_revert(&msg->msg_iter, psize);
+		if (!retransmission)
+			iov_iter_revert(&msg->msg_iter, psize);
 		return ret;
 	}
 
@@ -1391,7 +1392,9 @@ static void mptcp_worker(struct work_struct *work)
 	struct mptcp_data_frag *dfrag;
 	u64 orig_write_seq;
 	size_t copied = 0;
-	struct msghdr msg;
+	struct msghdr msg = {
+		.msg_flags = MSG_DONTWAIT,
+	};
 	long timeo = 0;
 
 	lock_sock(sk);
@@ -1424,7 +1427,6 @@ static void mptcp_worker(struct work_struct *work)
 
 	lock_sock(ssk);
 
-	msg.msg_flags = MSG_DONTWAIT;
 	orig_len = dfrag->data_len;
 	orig_offset = dfrag->offset;
 	orig_write_seq = dfrag->data_seq;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] mptcp: sendmsg: reset iter on error redux
  2020-08-16 21:14 [PATCH net] mptcp: sendmsg: reset iter on error redux Florian Westphal
@ 2020-08-17  4:12 ` David Miller
  2020-08-17 15:28 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2020-08-17  4:12 UTC (permalink / raw)
  To: fw; +Cc: netdev, mathew.j.martineau, matthieu.baerts, pabeni

From: Florian Westphal <fw@strlen.de>
Date: Sun, 16 Aug 2020 23:14:20 +0200

> 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: 35759383133f64d "(mptcp: sendmsg: reset iter on error)"
> Signed-off-by: Florian Westphal <fw@strlen.de>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] mptcp: sendmsg: reset iter on error redux
  2020-08-16 21:14 [PATCH net] mptcp: sendmsg: reset iter on error redux Florian Westphal
  2020-08-17  4:12 ` David Miller
@ 2020-08-17 15:28 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2020-08-17 15:28 UTC (permalink / raw)
  To: Florian Westphal; +Cc: netdev, mathew.j.martineau, matthieu.baerts, pabeni

On Sun, 16 Aug 2020 23:14:20 +0200 Florian Westphal wrote:
> 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: 35759383133f64d "(mptcp: sendmsg: reset iter on error)"
> Signed-off-by: Florian Westphal <fw@strlen.de>

Fixes tag: Fixes: 35759383133f64d "(mptcp: sendmsg: reset iter on error)"
Has these problem(s):
	- Subject does not match target commit subject
	  Just use
		git log -1 --format='Fixes: %h ("%s")'

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-17 19:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-16 21:14 [PATCH net] mptcp: sendmsg: reset iter on error redux Florian Westphal
2020-08-17  4:12 ` David Miller
2020-08-17 15:28 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).