netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* BUG? a possible race between htable_find_get() and htable_put()
@ 2010-01-13  2:51 홍신 shin hong
  2010-01-13  6:39 ` Patrick McHardy
  0 siblings, 1 reply; 3+ messages in thread
From: 홍신 shin hong @ 2010-01-13  2:51 UTC (permalink / raw)
  To: netfilter-devel

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) ;                  |

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-01-13  6:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-13  2:51 BUG? a possible race between htable_find_get() and htable_put() 홍신 shin hong
2010-01-13  6:39 ` Patrick McHardy
2010-01-13  6:41   ` Patrick McHardy

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).