]> Pileus Git - ~andy/linux/commitdiff
netfilter: xt_limit: have r->cost != 0 case work
authorJan Engelhardt <jengelh@inai.de>
Fri, 21 Sep 2012 22:26:52 +0000 (22:26 +0000)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 25 Sep 2012 23:33:16 +0000 (01:33 +0200)
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>
net/netfilter/xt_limit.c

index 5c22ce8ab3090b103ac75c7ae54d0489c1bc84e2..a4c1e4528cac7e3e820f1cecfb8ec22e8dcf5966 100644 (file)
@@ -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);
        }