netfilter: nf_tables: don't update chain with unset counters
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 5 Aug 2014 15:25:59 +0000 (17:25 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 8 Aug 2014 13:38:50 +0000 (15:38 +0200)
Fix possible replacement of the per-cpu chain counters by null
pointer when updating an existing chain in the commit path.

Reported-by: Matteo Croce <technoboy85@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index c6f9d3d18ed1f9263ab821c294fcf13d2e19eb2c..9aa31f11056dc42d75461755377f7fc5f69a06c5 100644 (file)
@@ -899,6 +899,9 @@ static struct nft_stats __percpu *nft_stats_alloc(const struct nlattr *attr)
 static void nft_chain_stats_replace(struct nft_base_chain *chain,
                                    struct nft_stats __percpu *newstats)
 {
+       if (newstats == NULL)
+               return;
+
        if (chain->stats) {
                struct nft_stats __percpu *oldstats =
                                nft_dereference(chain->stats);