diff options
author | Vasily Averin <vvs@virtuozzo.com> | 2020-09-25 11:56:02 +0300 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2020-10-04 21:08:25 +0200 |
commit | 9446ab34ace256e5e470c5aa221d46e544ad895e (patch) | |
tree | d713cfca44e780cd30cc0929ae16acc67acf572d /net/netfilter/ipset | |
parent | 82ec6630f9fcd129ebd839a6c862d0dbffe9eafc (diff) | |
download | linux-9446ab34ace256e5e470c5aa221d46e544ad895e.tar.gz linux-9446ab34ace256e5e470c5aa221d46e544ad895e.tar.bz2 linux-9446ab34ace256e5e470c5aa221d46e544ad895e.zip |
netfilter: ipset: enable memory accounting for ipset allocations
Currently netadmin inside non-trusted container can quickly allocate
whole node's memory via request of huge ipset hashtable.
Other ipset-related memory allocations should be restricted too.
v2: fixed typo ALLOC -> ACCOUNT
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter/ipset')
-rw-r--r-- | net/netfilter/ipset/ip_set_core.c | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c index 920b7c4331f0..6f35832f0de3 100644 --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c @@ -250,22 +250,7 @@ EXPORT_SYMBOL_GPL(ip_set_type_unregister); void * ip_set_alloc(size_t size) { - void *members = NULL; - - if (size < KMALLOC_MAX_SIZE) - members = kzalloc(size, GFP_KERNEL | __GFP_NOWARN); - - if (members) { - pr_debug("%p: allocated with kmalloc\n", members); - return members; - } - - members = vzalloc(size); - if (!members) - return NULL; - pr_debug("%p: allocated with vmalloc\n", members); - - return members; + return kvzalloc(size, GFP_KERNEL_ACCOUNT); } EXPORT_SYMBOL_GPL(ip_set_alloc); |