netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefani Seibold <stefani@seibold.net>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH] UDPCP Communication Protocol
Date: Sat, 01 Jan 2011 22:28:45 +0100	[thread overview]
Message-ID: <1293917325.28510.1.camel@wall-e> (raw)
In-Reply-To: <1293796805.2973.62.camel@edumazet-laptop>

Am Freitag, den 31.12.2010, 13:00 +0100 schrieb Eric Dumazet:
> Le vendredi 31 décembre 2010 à 12:25 +0100, Eric Dumazet a écrit :
> > Le vendredi 31 décembre 2010 à 10:29 +0100, stefani@seibold.net a
> > écrit :
> > > +		if (!list_empty(&usk->destlist)) {
> > > +			state->sk = (struct sock *)usk;
> > > +			state->dest = list_first_entry(&usk->destlist,
> > > +					struct udpcp_dest, list);
> > > +			sock_hold(state->sk);
> > > +
> > > +			if (atomic_read(&state->sk->sk_refcnt) != 1) {
> > > +				spin_unlock_irqrestore(&spinlock, flags);
> > > +				return state;
> > > +			}
> > > +			atomic_dec(&state->sk->sk_refcnt);
> > > +		}
> > > +
> > 
> > I am trying to understand what you are doing here.
> > 
> > It seems racy to me.
> > 
> > Apparently, what you want is to take a reference only if actual
> > sk_refcnt is not zero.
> > 
> > I suggest using atomic_inc_notzero(&state->sk->sk_refcnt) to avoid the
> > race in atomic_dec().
> > 
> > 
> 
> Before you ask why its racy, this is because UDP sockets are RCU
> protected, and RCU lookups depend on sk_refcnt being zero or not.
> 
> Doing an sk_refcnt increment/decrement opens a race window for the
> concurrent lookups.
> 

I still revamped the whole /proc/net/udpcp thing and hope it is now race
free.

  reply	other threads:[~2011-01-01 21:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-31  9:29 [PATCH] UDPCP Communication Protocol stefani
2010-12-31 10:00 ` Eric Dumazet
2010-12-31 10:22   ` Stefani Seibold
2010-12-31 10:41     ` Eric Dumazet
2010-12-31 11:23       ` Stefani Seibold
2010-12-31 11:54         ` Eric Dumazet
2011-01-01 21:40           ` Stefani Seibold
2011-01-10 22:28             ` Hagen Paul Pfeifer
2010-12-31 10:15 ` Eric Dumazet
2010-12-31 10:29   ` Stefani Seibold
2010-12-31 10:35 ` Eric Dumazet
2010-12-31 11:25 ` Eric Dumazet
2010-12-31 12:00   ` Eric Dumazet
2011-01-01 21:28     ` Stefani Seibold [this message]
2010-12-31 17:46 ` Stephen Hemminger
2010-12-31 17:46 ` Stephen Hemminger
2011-01-06 20:11 ` Pavel Machek
2011-01-06 20:17   ` David Miller
2011-01-10 22:53 ` Jesper Juhl
2011-01-11  0:49 ` Hagen Paul Pfeifer

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=1293917325.28510.1.camel@wall-e \
    --to=stefani@seibold.net \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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).