Skip to content

Commit

Permalink
netfilter: xt_limit: have r->cost != 0 case work
Browse files Browse the repository at this point in the history
Commit v2.6.19-rc1~1272^2~41 tells us that r->cost != 0 can happen when
a running state is saved to userspace and then reinstated from there.

Make sure that private xt_limit area is initialized with correct values.
Otherwise, random matchings due to use of uninitialized memory.

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
jengelh authored and ummakynes committed Sep 25, 2012
1 parent 3e10986 commit 82e6bfe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/netfilter/xt_limit.c
Expand Up @@ -117,11 +117,11 @@ static int limit_mt_check(const struct xt_mtchk_param *par)

/* For SMP, we only want to use one set of state. */
r->master = priv;
/* User avg in seconds * XT_LIMIT_SCALE: convert to jiffies *
128. */
priv->prev = jiffies;
priv->credit = user2credits(r->avg * r->burst); /* Credits full. */
if (r->cost == 0) {
/* User avg in seconds * XT_LIMIT_SCALE: convert to jiffies *
128. */
priv->prev = jiffies;
priv->credit = user2credits(r->avg * r->burst); /* Credits full. */
r->credit_cap = priv->credit; /* Credits full. */
r->cost = user2credits(r->avg);
}
Expand Down

0 comments on commit 82e6bfe

Please sign in to comment.