All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet at gmail.com>
To: mptcp at lists.01.org
Subject: [MPTCP] Re: [PATCH net-next v2] mptcp: be careful on MPTCP-level ack.
Date: Wed, 02 Dec 2020 17:10:05 +0100	[thread overview]
Message-ID: <2ac90c38-c82a-8aeb-2c01-b44a6de1bf57@gmail.com> (raw)
In-Reply-To: 665bb3a603afebdcc85878f6b45bcf0313607994.camel@redhat.com

[-- Attachment #1: Type: text/plain, Size: 2669 bytes --]



On 12/2/20 4:37 PM, Paolo Abeni wrote:
> On Wed, 2020-12-02 at 14:18 +0100, Eric Dumazet wrote:
>>
>> 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.dumazet(a)gmail.com>
>>> Fixes: ea4ca586b16f ("mptcp: refine MPTCP-level ack scheduling")
>>> Signed-off-by: Paolo Abeni <pabeni(a)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 ?
> 
> Thank you for looking into this!
> 
> I can't reproduce the issue with the following packetdrill ?!?
> 
> +0.0  connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress)
> +0.1   > S 0:0(0) <mss 1460,sackOK,TS val 100 ecr 0,nop,wscale 8,mpcapable v1 fflags[flag_h] nokey>
> +0.1   < S. 0:0(0) ack 1 win 65535 <mss 1460,sackOK,TS val 700 ecr 100,nop,wscaale 8,mpcapable v1 flags[flag_h] key[skey=2] >
> +0.1  > . 1:1(0) ack 1 <nop, nop, TS val 100 ecr 700,mpcapable v1 flags[flag_h]] key[ckey,skey]>
> +0.1 fcntl(3, F_SETFL, O_RDWR) = 0
> +0.1   < .  1:201(200) ack 1 win 225 <dss dack8=1 dsn8=1 ssn=1 dll=200 nocs,  nop, nop>
> +0.1   > .  1:1(0) ack 201 <nop, nop, TS val 100 ecr 700, dss dack8=201 dll=00 nocs>
> +0.1 read(3, ..., 0) = 0
> 
> The main recvmsg() loop is interrupted by the following check:
> 
>                 if (copied >= target)
>                         break;

@copied should be 0, and @target should be 1

Are you sure the above condition is triggering ?

Maybe read(fd, ..., 0) does not reach recvmsg() at all.

You could try recvmsg() or recvmmsg(), 

> 
> I guess we could loop while the msk has available rcv space and some
> subflow is feeding new data. If so, I think moving:
> 
> 	if (skb_queue_empty(&msk->receive_queue) &&
>                     __mptcp_move_skbs(msk, len - copied))
>                         continue;
> 
> after the above check should address the issue, and will make the
> common case faster. Let me test the above - unless I underlooked
> something relevant!
> 
> Thanks,
> 
> Paolo
> 

WARNING: multiple messages have this Message-ID (diff)
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	netdev@vger.kernel.org
Cc: Jakub Kicinski <kuba@kernel.org>, mptcp@lists.01.org
Subject: Re: [PATCH net-next v2] mptcp: be careful on MPTCP-level ack.
Date: Wed, 2 Dec 2020 17:10:05 +0100	[thread overview]
Message-ID: <2ac90c38-c82a-8aeb-2c01-b44a6de1bf57@gmail.com> (raw)
In-Reply-To: <665bb3a603afebdcc85878f6b45bcf0313607994.camel@redhat.com>



On 12/2/20 4:37 PM, Paolo Abeni wrote:
> On Wed, 2020-12-02 at 14:18 +0100, Eric Dumazet wrote:
>>
>> 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.dumazet@gmail.com>
>>> Fixes: ea4ca586b16f ("mptcp: refine MPTCP-level ack scheduling")
>>> Signed-off-by: Paolo Abeni <pabeni@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 ?
> 
> Thank you for looking into this!
> 
> I can't reproduce the issue with the following packetdrill ?!?
> 
> +0.0  connect(3, ..., ...) = -1 EINPROGRESS (Operation now in progress)
> +0.1   > S 0:0(0) <mss 1460,sackOK,TS val 100 ecr 0,nop,wscale 8,mpcapable v1 fflags[flag_h] nokey>
> +0.1   < S. 0:0(0) ack 1 win 65535 <mss 1460,sackOK,TS val 700 ecr 100,nop,wscaale 8,mpcapable v1 flags[flag_h] key[skey=2] >
> +0.1  > . 1:1(0) ack 1 <nop, nop, TS val 100 ecr 700,mpcapable v1 flags[flag_h]] key[ckey,skey]>
> +0.1 fcntl(3, F_SETFL, O_RDWR) = 0
> +0.1   < .  1:201(200) ack 1 win 225 <dss dack8=1 dsn8=1 ssn=1 dll=200 nocs,  nop, nop>
> +0.1   > .  1:1(0) ack 201 <nop, nop, TS val 100 ecr 700, dss dack8=201 dll=00 nocs>
> +0.1 read(3, ..., 0) = 0
> 
> The main recvmsg() loop is interrupted by the following check:
> 
>                 if (copied >= target)
>                         break;

@copied should be 0, and @target should be 1

Are you sure the above condition is triggering ?

Maybe read(fd, ..., 0) does not reach recvmsg() at all.

You could try recvmsg() or recvmmsg(), 

> 
> I guess we could loop while the msk has available rcv space and some
> subflow is feeding new data. If so, I think moving:
> 
> 	if (skb_queue_empty(&msk->receive_queue) &&
>                     __mptcp_move_skbs(msk, len - copied))
>                         continue;
> 
> after the above check should address the issue, and will make the
> common case faster. Let me test the above - unless I underlooked
> something relevant!
> 
> Thanks,
> 
> Paolo
> 

             reply	other threads:[~2020-12-02 16:10 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02 16:10 Eric Dumazet [this message]
2020-12-02 16:10 ` [PATCH net-next v2] mptcp: be careful on MPTCP-level ack Eric Dumazet
  -- strict thread matches above, loose matches on Subject: below --
2020-12-02 17:08 [MPTCP] " Paolo Abeni
2020-12-02 17:08 ` Paolo Abeni
2020-12-02 16:51 Paolo Abeni
2020-12-02 16:51 ` Paolo Abeni
2020-12-02 16:45 [MPTCP] " Eric Dumazet
2020-12-02 16:45 ` Eric Dumazet
2020-12-02 16:32 [MPTCP] " Eric Dumazet
2020-12-02 16:32 ` Eric Dumazet
2020-12-02 16:30 [MPTCP] " Eric Dumazet
2020-12-02 16:30 ` Eric Dumazet
2020-12-02 15:37 [MPTCP] " Paolo Abeni
2020-12-02 15:37 ` Paolo Abeni
2020-12-02 13:18 [MPTCP] " Eric Dumazet
2020-12-02 13:18 ` Eric Dumazet
2020-11-25 21:37 [MPTCP] " Jakub Kicinski
2020-11-25 21:37 ` Jakub Kicinski
2020-11-24 21:51 [MPTCP] " Paolo Abeni
2020-11-24 21:51 ` Paolo Abeni
2020-11-24 15:03 [MPTCP] " Paolo Abeni
2020-11-24 14:25 Matthieu Baerts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ac90c38-c82a-8aeb-2c01-b44a6de1bf57@gmail.com \
    --to=unknown@example.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.