netfilter: x_tables: add counters allocation wrapper

allows to have size checks in a single spot.
This is supposed to reduce oom situations when fuzz-testing xtables.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
Florian Westphal
2018-02-27 19:42:33 +01:00
committed by Pablo Neira Ayuso
parent 9d5c12a7c0
commit c84ca954ac
5 changed files with 19 additions and 3 deletions

View File

@@ -1063,7 +1063,7 @@ __do_replace(struct net *net, const char *name, unsigned int valid_hooks,
struct ip6t_entry *iter;
ret = 0;
counters = vzalloc(num_counters * sizeof(struct xt_counters));
counters = xt_counters_alloc(num_counters);
if (!counters) {
ret = -ENOMEM;
goto out;