Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: MuraliRaja Muniraju <muralira@google.com>
Cc: netdev@vger.kernel.org
Subject: Re: Query regarding a code snippet in __inet_lookup_established.
Date: Sat, 21 Jan 2012 08:30:25 +0100	[thread overview]
Message-ID: <1327131025.6338.1.camel@edumazet-laptop> (raw)
In-Reply-To: <CAP3iWTRS5d5dHLFpkOmiTuh46pPnFLLiJ1FG=WTumt-1B8DgZQ@mail.gmail.com>

Le vendredi 20 janvier 2012 à 17:02 -0800, MuraliRaja Muniraju a écrit :
> Hi All,
>     In function __inet_lookup_established, I do see a potential issue
> in a corner case while reading through the code where socket can be
> freed while being in the list and also while in rcu_read critical
> section.
>         rcu_read_lock();
> begin:
>         sk_nulls_for_each_rcu(sk, node, &head->chain) {
>                 if (INET_MATCH(sk, net, hash, acookie,
>                                         saddr, daddr, ports, dif)) {
>                         if (unlikely(!atomic_inc_not_zero(&sk->sk_refcnt)))
>                                 goto begintw;
>                         if (unlikely(!INET_MATCH(sk, net, hash, acookie,
>                                 saddr, daddr, ports, dif))) {
> Murali>                                sock_put(sk);
> Murali>                                goto begin;
>                         }
>                         goto out;
>                 }
>         }
> 
> I am not certain under what scenario this might occur. Can someone let
> me know if this is a possibility.

Since we succeeded in atomic_inc_not_zero(&sk->sk_refcnt), socket cannot
be freed until our sock_put()

      reply	other threads:[~2012-01-21  7:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-21  1:02 Query regarding a code snippet in __inet_lookup_established MuraliRaja Muniraju
2012-01-21  7:30 ` Eric Dumazet [this message]

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=1327131025.6338.1.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=muralira@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox