Skip to content

Commit

Permalink
netfilter: xt_hashlimit: fix race between htable_destroy and htable_gc
Browse files Browse the repository at this point in the history
Deleting a timer with del_timer doesn't guarantee, that the
timer function is not running at the moment of deletion. Thus
in the xt_hashlimit case we can get into a ticklish situation
when the htable_gc rearms the timer back and we'll actually
delete an entry with a pending timer.

Fix it with using del_timer_sync().

AFAIK del_timer_sync checks for the timer to be pending by
itself, so I remove the check.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Jul 31, 2008
1 parent a8ddc91 commit 967ab99
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions net/netfilter/xt_hashlimit.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,7 @@ static void htable_gc(unsigned long htlong)

static void htable_destroy(struct xt_hashlimit_htable *hinfo)
{
/* remove timer, if it is pending */
if (timer_pending(&hinfo->timer))
del_timer(&hinfo->timer);
del_timer_sync(&hinfo->timer);

/* remove proc entry */
remove_proc_entry(hinfo->pde->name,
Expand Down

0 comments on commit 967ab99

Please sign in to comment.