Skip to content

Commit

Permalink
ipvs: Fix possible deadlock in estimator code
Browse files Browse the repository at this point in the history
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>
Cc: stable <stable@kernel.org>
Acked-by: Simon Horman <horms@verge.net.au>
  • Loading branch information
Sven Wegener committed Aug 11, 2008
1 parent bc0fde2 commit 8ab19ea
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions net/ipv4/ipvs/ip_vs_est.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,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);
}

Expand Down

0 comments on commit 8ab19ea

Please sign in to comment.