netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "홍신 shin hong" <hongshin@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: BUG? a possible race between htable_find_get() and htable_put()
Date: Wed, 13 Jan 2010 11:51:49 +0900	[thread overview]
Message-ID: <2014bcab1001121851g28e8e7d3x5ed3604b6854a0ed@mail.gmail.com> (raw)

Hi. I am reporting a suspected race between htable_find_get()
and htable_put() in net/netfilter/xt_hashlimit.c.

I found this issue while I read the code so that it might not realistic.
But, please examine the code to check possibility of race condition.

htable_put() first updates hinfo->use and then unlink the object from the list.
But, htable_find_get() first searches an object from the list,
and then updates hinfo->use.
Therefore, race would be possible for the following situation.

hinfo->use == 1.

htable_put()                                      |  htable_find_get()
--------------------------------------------------------------------------------------------------------------
  atomic_dec_and_test(&hinfo->use) ; |
                                                       |
spin_lock_bh(&hashlimit_lock) ;
                                                       |
hlist_for_each_entry(...) ;
                                                       | ...
                                                       |
atomic_inc(&hinfo->use) ;
                                                       |
spin_unlock_bh(&hashlimit_lock) ;
  spin_lock_bh(&hashlimit_lock) ;       |
  hlist_del(&hinfo->node) ;                  |

             reply	other threads:[~2010-01-13  2:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-13  2:51 홍신 shin hong [this message]
2010-01-13  6:39 ` BUG? a possible race between htable_find_get() and htable_put() Patrick McHardy
2010-01-13  6:41   ` Patrick McHardy

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=2014bcab1001121851g28e8e7d3x5ed3604b6854a0ed@mail.gmail.com \
    --to=hongshin@gmail.com \
    --cc=netfilter-devel@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).