diff options
author | Florian Westphal <fw@strlen.de> | 2018-02-27 19:42:33 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-04-26 11:02:21 +0200 |
commit | 82b68ecde5d056588799f0d38e675bbb81fe3b46 (patch) | |
tree | 9710a99b66102fce8910703cc452ae8915e47387 /net/netfilter/x_tables.c | |
parent | fab0b3ce67a54f45848ee5d6023ef9a42153a2c9 (diff) | |
download | linux-stable-82b68ecde5d056588799f0d38e675bbb81fe3b46.tar.gz linux-stable-82b68ecde5d056588799f0d38e675bbb81fe3b46.tar.bz2 linux-stable-82b68ecde5d056588799f0d38e675bbb81fe3b46.zip |
netfilter: x_tables: add counters allocation wrapper
commit c84ca954ac9fa67a6ce27f91f01e4451c74fd8f6 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/netfilter/x_tables.c')
-rw-r--r-- | net/netfilter/x_tables.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index d1d29015d91f..9c38627e09ea 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -1187,6 +1187,21 @@ static int xt_jumpstack_alloc(struct xt_table_info *i) return 0; } +struct xt_counters *xt_counters_alloc(unsigned int counters) +{ + struct xt_counters *mem; + + if (counters == 0 || counters > INT_MAX / sizeof(*mem)) + return NULL; + + counters *= sizeof(*mem); + if (counters > XT_MAX_TABLE_SIZE) + return NULL; + + return vzalloc(counters); +} +EXPORT_SYMBOL(xt_counters_alloc); + struct xt_table_info * xt_replace_table(struct xt_table *table, unsigned int num_counters, |