All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ipset: enable memory accounting for ipset allocations
@ 2020-09-25  5:55 Vasily Averin
  2020-09-25  7:53   ` kernel test robot
  2020-09-25  9:13   ` kernel test robot
  0 siblings, 2 replies; 7+ messages in thread
From: Vasily Averin @ 2020-09-25  5:55 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: netfilter-devel, Jozsef Kadlecsik, Florian Westphal, David S. Miller

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.

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 net/netfilter/ipset/ip_set_core.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 920b7c4..e9fe34a 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -250,22 +250,7 @@ static struct ip_set_net *ip_set_pernet(struct net *net)
 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_ALLOC);
 }
 EXPORT_SYMBOL_GPL(ip_set_alloc);
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-10-04 19:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-25  5:55 [PATCH] ipset: enable memory accounting for ipset allocations Vasily Averin
2020-09-25  7:53 ` kernel test robot
2020-09-25  7:53   ` kernel test robot
2020-09-25  8:56   ` [PATCH v2] " Vasily Averin
2020-10-04 19:09     ` Pablo Neira Ayuso
2020-09-25  9:13 ` [PATCH] " kernel test robot
2020-09-25  9:13   ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.