netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: ilpo.jarvinen@helsinki.fi
Cc: elendil@planet.nl, matthias.andree@gmx.de, netdev@vger.kernel.org
Subject: Re: [PATCH v2] tcp: fix MSG_PEEK race check
Date: Mon, 18 May 2009 15:04:33 -0700 (PDT)	[thread overview]
Message-ID: <20090518.150433.92463181.davem@davemloft.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0905180958150.3381@wrl-59.cs.helsinki.fi>

From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
Date: Mon, 18 May 2009 10:24:23 +0300 (EEST)

> Sorry, I'm not sure you thought this fully through here. What my patch 
> with urg_hole does is that it keeps peek_seq non-advancing using the 
> offsets. Now without the urg offsetting, the peek_seq side of the race 
> check advances, which means that we didn't catch the race when it happened 
> for real as copied_seq advanced too?!?

I see now what the situation is, thanks for explaining.

You're account for the "*seq" advance for URG that happens in
tcp_recvmsg() rather than the one that happens in tcp_check_urg().

> From another perspective when the race didn't happen but potential for it 
> existed, the current check should catch that since peek_seq advanced and 
> copied_seq stayed where it was. But that certainly doesn't match to your 
> description above.

Right.

> I wonder why all this fuzz about this particular race as we will do our 
> best anyway to skip the hole on MSG_PEEK side (if I read the code right)? 
> Either we never see the hole in MSG_PEEK side, or we're happily past it 
> already, does it make any difference anymore in the latter case? <insert 
> some "not that I fully understand all of that multipage function" 
> disclaimer here though, I may think too simple scenarios here>. Not that 
> I'm too interested in "improving" urg or so anywa, I'm just curious... :-)

A long long time ago we had an assertion here checking whether
->copied_seq moved without our knowledge.  Alexey and I found this
could trigger and investigation of that is what helped us
find the tcp_check_urg()+MSG_PEEK case.  That's when we added this
test and log message.

When the MSG_PEEK test existing in the !copied if() branch of
tcp_recvmsg(), so many of these code paths we are dealing with in this
fix could simply not be reached when MSG_PEEK.  That ++*seq could
never happen, because if "copied" was non-zero and MSG_PEEK was true
we would leave the loop and return from tcp_recvmsg() immediately.

Now, we have to accomodate those adjustments.

Since I now understand your urg_hole code I'm going to apply your v2
patch which takes care of the URG stuff.  I also buy the argument that
perhaps we should get rid of the log message, but look at how it
helped us find this kernel regression :-)

  parent reply	other threads:[~2009-05-18 22:04 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200902262310.12791.elendil@planet.nl>
     [not found] ` <200903091749.50818.elendil@planet.nl>
     [not found]   ` <op.uqjiqsol1e62zd@merlin.emma.line.org>
     [not found]     ` <200903141900.14498.elendil@planet.nl>
2009-05-06 16:15       ` Strange Application bug, race in MSG_PEEK complaints (was: Bug#513695: fetchmail: race in MSG_PEEK) Matthias Andree
2009-05-06 23:02       ` Matthias Andree
2009-05-07  6:48         ` Ilpo Järvinen
2009-05-07 17:16           ` Frans Pop
2009-05-07 18:48             ` Ilpo Järvinen
2009-05-07 20:43               ` Frans Pop
2009-05-09 18:14           ` Frans Pop
2009-05-11  6:32             ` [PATCH v2] tcp: fix MSG_PEEK race check Ilpo Järvinen
2009-05-11 12:50               ` Frans Pop
2009-05-11 13:32                 ` Ilpo Järvinen
2009-05-11 13:54                   ` Frans Pop
2009-05-11 14:57                     ` Ilpo Järvinen
2009-05-17 22:31                       ` David Miller
2009-05-18  8:02                         ` Matthias Andree
2009-05-17 22:41               ` David Miller
2009-05-18  7:24                 ` Ilpo Järvinen
2009-05-18 15:34                   ` Matthias Andree
2009-05-18 22:04                   ` David Miller [this message]
2009-05-19  4:33                     ` Ilpo Järvinen
2009-05-19  4:40                       ` David Miller
2009-05-19  9:05                     ` Matthias Andree

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=20090518.150433.92463181.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=elendil@planet.nl \
    --cc=ilpo.jarvinen@helsinki.fi \
    --cc=matthias.andree@gmx.de \
    --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 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).