diff options
author | Sven Wegener <sven.wegener@stealer.net> | 2008-08-14 07:55:22 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-08-20 22:05:03 +0400 |
commit | db6d9c1f9a1beb1b20b7b0bd5e12a16c68a6465b (patch) | |
tree | 862e8aa877b86d8457e653c07cc53fd5b49c4475 | |
parent | 6191b1862fd159d8bf6eeb5014d6415782e482ea (diff) | |
download | linux-db6d9c1f9a1beb1b20b7b0bd5e12a16c68a6465b.tar.xz |
ipvs: Fix possible deadlock in estimator code
commit 8ab19ea36c5c5340ff598e4d15fc084eb65671dc upstream
There is a slight chance for a deadlock in the estimator code. We can't call
del_timer_sync() while holding our lock, as the timer might be active and
spinning for the lock on another cpu. Work around this issue by using
try_to_del_timer_sync() and releasing the lock. We could actually delete the
timer outside of our lock, as the add and kill functions are only every called
from userspace via [gs]etsockopt() and are serialized by a mutex, but better
make this explicit.
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
Acked-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | net/ipv4/ipvs/ip_vs_est.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/net/ipv4/ipvs/ip_vs_est.c b/net/ipv4/ipvs/ip_vs_est.c index dfa0d713c801..f97ffc5a6b8a 100644 --- a/net/ipv4/ipvs/ip_vs_est.c +++ b/net/ipv4/ipvs/ip_vs_est.c @@ -172,8 +172,11 @@ void ip_vs_kill_estimator(struct ip_vs_stats *stats) kfree(est); killed++; } - if (killed && est_list == NULL) - del_timer_sync(&est_timer); + while (killed && !est_list && try_to_del_timer_sync(&est_timer) < 0) { + write_unlock_bh(&est_lock); + cpu_relax(); + write_lock_bh(&est_lock); + } write_unlock_bh(&est_lock); } |