All of lore.kernel.org
 help / color / mirror / Atom feed
From: "van der Linden, Frank" <fllinden@amazon.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	"edumazet@google.com" <edumazet@google.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH v2] tcp: verify the checksum of the first data segment in a new connection
Date: Tue, 12 Jun 2018 21:53:17 +0000	[thread overview]
Message-ID: <EB56EB1B-8E64-4D2C-9604-5ACFD3857F0D@amazon.com> (raw)
In-Reply-To: <9541859a-1346-e13a-b97c-a2a63f3b19f4@gmail.com>

The convention seems to be to call tcp_checksum_complete after tcp_filter has a chance to deal with the packet. I wanted to preserve that.

If that is not a concern, then I agree that this is a far better way to go.

Frank

On 6/12/18, 2:50 PM, "Eric Dumazet" <eric.dumazet@gmail.com> wrote:

    
    
    On 06/12/2018 02:41 PM, Frank van der Linden wrote:
    > commit 079096f103fa ("tcp/dccp: install syn_recv requests into ehash
    > table") introduced an optimization for the handling of child sockets
    > created for a new TCP connection.
    > 
    > But this optimization passes any data associated with the last ACK of the
    > connection handshake up the stack without verifying its checksum, because it
    > calls tcp_child_process(), which in turn calls tcp_rcv_state_process()
    > directly.  These lower-level processing functions do not do any checksum
    > verification.
    > 
    > Insert a tcp_checksum_complete call in the TCP_NEW_SYN_RECEIVE path to
    > fix this.
    > 
    > Signed-off-by: Frank van der Linden <fllinden@amazon.com>
    
    
    This is way too complicated.
    
    You should call tcp_checksum_complete() earlier and avoid all this mess.
    
    
    IPV4 part shown here :
    
    diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
    index fed3f1c6616708997f621535efe9412e4afa0a50..7b5f32aa3835b0124b0a9bd342c371df7b46f471 100644
    --- a/net/ipv4/tcp_ipv4.c
    +++ b/net/ipv4/tcp_ipv4.c
    @@ -1730,6 +1730,10 @@ int tcp_v4_rcv(struct sk_buff *skb)
                            reqsk_put(req);
                            goto discard_it;
                    }
    +               if (unlikely(tcp_checksum_complete(skb))) {
    +                       reqsk_put(req);
    +                       goto csum_error;
    +               }
                    if (unlikely(sk->sk_state != TCP_LISTEN)) {
                            inet_csk_reqsk_queue_drop_and_put(sk, req);
                            goto lookup;
    
    
    
    


  reply	other threads:[~2018-06-12 21:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12 21:41 [PATCH v2] tcp: verify the checksum of the first data segment in a new connection Frank van der Linden
2018-06-12 21:50 ` Eric Dumazet
2018-06-12 21:53   ` van der Linden, Frank [this message]
2018-06-12 22:03     ` Eric Dumazet
2018-06-12 22:30       ` van der Linden, Frank
2018-06-12 23:12       ` van der Linden, Frank
2018-06-13  5:08   ` Balbir Singh

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=EB56EB1B-8E64-4D2C-9604-5ACFD3857F0D@amazon.com \
    --to=fllinden@amazon.com \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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.