Re: [netfilter-core] kernel panic: Out of memory and no killable processes... (2)
From: Michal Hocko <mhocko@kernel.org>
Date: 2018-01-31 08:19:21
Also in:
linux-mm, lkml, netfilter-devel
Subsystem:
netfilter, networking [general], the rest · Maintainers:
Pablo Neira Ayuso, Florian Westphal, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
On Tue 30-01-18 11:27:45, Andrew Morton wrote:
On Tue, 30 Jan 2018 15:01:04 +0100 Michal Hocko [off-list ref] wrote:quoted
quoted
Well, this is not about syzkaller, it merely pointed out a potential DoS... And that has to be addressed somehow.So how about this? ---argh ;)
doh, those hardwired moves...
quoted
quoted
From d48e950f1b04f234b57b9e34c363bdcfec10aeee Mon Sep 17 00:00:00 2001From: Michal Hocko <mhocko@suse.com> Date: Tue, 30 Jan 2018 14:51:07 +0100 Subject: [PATCH] net/netfilter/x_tables.c: make allocation less aggressive syzbot has noticed that xt_alloc_table_info can allocate a lot of memory. This is an admin only interface but an admin in a namespace is sufficient as well. eacd86ca3b03 ("net/netfilter/x_tables.c: use kvmalloc() in xt_alloc_table_info()") has changed the opencoded kmalloc->vmalloc fallback into kvmalloc. It has dropped __GFP_NORETRY on the way because vmalloc has simply never fully supported __GFP_NORETRY semantic. This is still the case because e.g. page tables backing the vmalloc area are hardcoded GFP_KERNEL. Revert back to __GFP_NORETRY as a poors man defence against excessively large allocation request here. We will not rule out the OOM killer completely but __GFP_NORETRY should at least stop the large request in most cases. Fixes: eacd86ca3b03 ("net/netfilter/x_tables.c: use kvmalloc() in xt_alloc_table_info()") Signed-off-by: Michal Hocko <mhocko@suse.com> --- net/netfilter/x_tables.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index d8571f414208..a5f5c29bcbdc 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c@@ -1003,7 +1003,13 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size) if ((SMP_ALIGN(size) >> PAGE_SHIFT) + 2 > totalram_pages) return NULL;offtopic: preceding comment here is "prevent them from hitting BUG() in vmalloc.c". I suspect this is ancient code and vmalloc sure as heck shouldn't go BUG with this input. And it should be using `sz' ;)
Yeah, we do not BUG but rather fail instead. See __vmalloc_node_range. My excavation tools pointed me to "VM: Rework vmalloc code to support mapping of arbitray pages" by Christoph back in 2002. So yes, we can safely remove it finally. Se below.
From 8d52e1d939d101b0dafed6ae5c3c1376183e65bb Mon Sep 17 00:00:00 2001
From: Michal Hocko <mhocko@suse.com> Date: Wed, 31 Jan 2018 09:16:56 +0100 Subject: [PATCH] net/netfilter/x_tables.c: remove size check Back in 2002 vmalloc used to BUG on too large sizes. We are much better behaved these days and vmalloc simply returns NULL for those. Remove the check as it simply not needed and the comment even misleading. Suggested-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Michal Hocko <mhocko@suse.com> --- net/netfilter/x_tables.c | 4 ---- 1 file changed, 4 deletions(-)
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index b55ec5aa51a6..48a6ff620493 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c@@ -999,10 +999,6 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size) if (sz < sizeof(*info)) return NULL; - /* Pedantry: prevent them from hitting BUG() in vmalloc.c --RR */ - if ((SMP_ALIGN(size) >> PAGE_SHIFT) + 2 > totalram_pages) - return NULL; - /* __GFP_NORETRY is not fully supported by kvmalloc but it should * work reasonably well if sz is too large and bail out rather * than shoot all processes down before realizing there is nothing
--
2.15.1
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>