Skip to contentSkip to conversation

Patch "sock: fix sendmmsg for partial sendmsg" 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

sock: fix sendmmsg for partial sendmsg

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:
sock-fix-sendmmsg-for-partial-sendmsg.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: Soheil Hassas Yeganeh <[email protected]>
Date: Fri, 4 Nov 2016 15:36:49 -0400
Subject: sock: fix sendmmsg for partial sendmsg

From: Soheil Hassas Yeganeh <[email protected]>

[ Upstream commit 3023898b7d4aac65987bd2f485cc22390aae6f78 ]

Do not send the next message in sendmmsg for partial sendmsg invocations.

sendmmsg assumes that it can continue sending the next message when the return value of the individual sendmsg invocations is positive. It results in corrupting the data for TCP, SCTP, and UNIX streams.

For example, sendmmsg([["abcd"], ["efgh"]]) can result in a stream of "aefgh" if the first sendmsg invocation sends only the first byte while the second sendmsg goes through.

Datagram sockets either send the entire datagram or fail, so this patch affects only sockets of type SOCK_STREAM and SOCK_SEQPACKET.

---
 net/socket.c |    2 ++
 1 file changed, 2 insertions(+)
net/socket.c +2 -0
@@ -2041,6 +2041,8 @@ int __sys_sendmmsg(int fd, struct mmsghd
 		if (err)
 			break;
 		++datagrams;
+		if (msg_data_left(&msg_sys))
+			break;
 		cond_resched();
 	}
 

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

queue-4.8/net-clear-sk_err_soft-in-sk_clone_lock.patch queue-4.8/tcp-fix-return-value-for-partial-writes.patch queue-4.8/sock-fix-sendmmsg-for-partial-sendmsg.patch