On 11/24/20 10:51 PM, Paolo Abeni wrote:
> We can enter the main mptcp_recvmsg() loop even when
> no subflows are connected. As note by Eric, that would
> result in a divide by zero oops on ack generation.
>
> Address the issue by checking the subflow status before
> sending the ack.
>
> Additionally protect mptcp_recvmsg() against invocation
> with weird socket states.
>
> v1 -> v2:
> - removed unneeded inline keyword - Jakub
>
> Reported-and-suggested-by: Eric Dumazet <eric.duma...@gmail.com>
> Fixes: ea4ca586b16f ("mptcp: refine MPTCP-level ack scheduling")
> Signed-off-by: Paolo Abeni <pab...@redhat.com>
> ---
> net/mptcp/protocol.c | 67 ++++++++++++++++++++++++++++++++------------
> 1 file changed, 49 insertions(+), 18 deletions(-)
>
Looking at mptcp recvmsg(), it seems that a read(fd, ..., 0) will
trigger an infinite loop if there is available data in receive queue ?
It seems the following is needed, commit ea4ca586b16f removed
a needed check to catch this condition.
Untested patch, I can submit it formally if you agree.
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index
221f7cdd416bdb681968bf1b3ff2ed1b03cea3ce..57213ff60f784fae14c2a96f391ccdec6249c168
100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1921,7 +1921,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr
*msg, size_t len,
len = min_t(size_t, len, INT_MAX);
target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
- for (;;) {
+ while (copied < len) {
int bytes_read, old_space;
bytes_read = __mptcp_recvmsg_mskq(msk, msg, len - copied);