diff options
author | Patrick McHardy <kaber@trash.net> | 2010-02-03 13:24:54 +0100 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2010-02-03 13:24:54 +0100 |
commit | 2eff25c18c3d332d3c4dd98f2ac9b7114e9771b0 (patch) | |
tree | c5b42ff3fb067e6f632edd716b9a4b70c4378ee8 /include/net | |
parent | 10a199394b8f9b4c4e0be6e14a61109a7d891b1b (diff) | |
download | op-kernel-dev-2eff25c18c3d332d3c4dd98f2ac9b7114e9771b0.zip op-kernel-dev-2eff25c18c3d332d3c4dd98f2ac9b7114e9771b0.tar.gz |
netfilter: xt_hashlimit: fix race condition and simplify locking
As noticed by Shin Hong <hongshin@gmail.com>, there is a race between
htable_find_get() and htable_put():
htable_put(): htable_find_get():
spin_lock_bh(&hashlimit_lock);
<search entry>
atomic_dec_and_test(&hinfo->use)
atomic_inc(&hinfo->use)
spin_unlock_bh(&hashlimit_lock)
return hinfo;
spin_lock_bh(&hashlimit_lock);
hlist_del(&hinfo->node);
spin_unlock_bh(&hashlimit_lock);
htable_destroy(hinfo);
The entire locking concept is overly complicated, tables are only
created/referenced and released in process context, so a single
mutex works just fine. Remove the hashinfo_spinlock and atomic
reference count and use the mutex to protect table lookups/creation
and reference count changes.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include/net')
0 files changed, 0 insertions, 0 deletions