netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: eric.dumazet@gmail.com
Cc: soheil.kdev@gmail.com, netdev@vger.kernel.org, ycheng@google.com,
	ncardwell@google.com, edumazet@google.com, willemb@google.com,
	soheil@google.com
Subject: Re: [PATCH V2 net-next 1/2] tcp: send in-queue bytes in cmsg upon read
Date: Mon, 30 Apr 2018 12:10:24 -0400 (EDT)	[thread overview]
Message-ID: <20180430.121024.1354407786745903932.davem@davemloft.net> (raw)
In-Reply-To: <c95883da-51ab-47aa-7ad1-a5bb85935e6b@gmail.com>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 30 Apr 2018 09:01:47 -0700

> TCP sockets are read by a single thread really (or synchronized
> threads), or garbage is ensured, regardless of how the kernel
> ensures locking while reporting "queue length"

Whatever applications "typically do", we should never return
garbage, and that is what this code allowing to happen.

Everything else in recvmsg() operates on state under the proper socket
lock, to ensure consistency.

The only reason we are releasing the socket lock first it to make sure
the backlog is processed and we have the most update information
available.

It seems like one is striving for correctness and better accuracy, no?
:-)

Look, this can be fixed really simply.  And if you are worried about
unbounded loops if two apps maliciously do recvmsg() in parallel,
then don't even loop, just fallback to full socket locking and make
the "non-typical" application pay the price:

	tmp1 = A;
	tmp2 = B;
	barrier();
	tmp3 = A;
	if (unlikely(tmp1 != tmp3)) {
		lock_sock(sk);
		tmp1 = A;
		tmp2 = B;
		release_sock(sk);
	}

I'm seriously not applying the patch as-is, sorry.  This issue
must be addressed somehow.

Thank you.

  reply	other threads:[~2018-04-30 16:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-27 18:57 [PATCH V2 net-next 1/2] tcp: send in-queue bytes in cmsg upon read Soheil Hassas Yeganeh
2018-04-27 18:57 ` [PATCH V2 net-next 2/2] selftest: add test for TCP_INQ Soheil Hassas Yeganeh
2018-04-30 15:38 ` [PATCH V2 net-next 1/2] tcp: send in-queue bytes in cmsg upon read David Miller
2018-04-30 15:43   ` Eric Dumazet
2018-04-30 15:56     ` David Miller
2018-04-30 16:01       ` Eric Dumazet
2018-04-30 16:10         ` David Miller [this message]
2018-04-30 16:59           ` Soheil Hassas Yeganeh
2018-04-30 15:59     ` Soheil Hassas Yeganeh

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=20180430.121024.1354407786745903932.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=soheil.kdev@gmail.com \
    --cc=soheil@google.com \
    --cc=willemb@google.com \
    --cc=ycheng@google.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 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).