summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiping Zhang <liping.zhang@spreadtrum.com>2016-09-12 22:21:36 +0800
committerPablo Neira Ayuso <pablo@netfilter.org>2016-09-12 20:00:23 +0200
commit2e917d602acd9e3e8c6e4c43b213c8929d986503 (patch)
tree1d7ffcad09e03541892e6eb11fb150f30208a323
parent8e8118f893138d4cc3d4dbf4163d7497fca54a9d (diff)
downloadlinux-2e917d602acd9e3e8c6e4c43b213c8929d986503.tar.gz
linux-2e917d602acd9e3e8c6e4c43b213c8929d986503.tar.bz2
linux-2e917d602acd9e3e8c6e4c43b213c8929d986503.zip
netfilter: nft_numgen: fix race between num generate and store it
After we generate a new number, we still use the priv->counter and store it to the dreg. This is not correct, another cpu may already change it to a new number. So we must use the generated number, not the priv->counter itself. Fixes: 91dbc6be0a62 ("netfilter: nf_tables: add number generator expression") Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--net/netfilter/nft_numgen.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/netfilter/nft_numgen.c b/net/netfilter/nft_numgen.c
index f51a3ede3932..f173ebec30a7 100644
--- a/net/netfilter/nft_numgen.c
+++ b/net/netfilter/nft_numgen.c
@@ -37,7 +37,7 @@ static void nft_ng_inc_eval(const struct nft_expr *expr,
nval = (oval + 1 < priv->modulus) ? oval + 1 : 0;
} while (atomic_cmpxchg(&priv->counter, oval, nval) != oval);
- memcpy(&regs->data[priv->dreg], &priv->counter, sizeof(u32));
+ regs->data[priv->dreg] = nval;
}
static const struct nla_policy nft_ng_policy[NFTA_NG_MAX + 1] = {