From: Florian Westphal Date: Tue, 27 Feb 2018 18:42:32 +0000 (+0100) Subject: netfilter: x_tables: limit allocation requests for blob rule heads X-Git-Tag: v4.16.5~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a394b1be5ac2225ad1836ea787719be90bb9198;p=thirdparty%2Fkernel%2Fstable.git netfilter: x_tables: limit allocation requests for blob rule heads commit 9d5c12a7c08f67999772065afd50fb222072114e upstream. This is a very conservative limit (134217728 rules), but good enough to not trigger frequent oom from syzkaller. Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index f75e4b6e2f9a9..a94c0e3cdcf0c 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -818,6 +818,9 @@ EXPORT_SYMBOL(xt_check_entry_offsets); */ unsigned int *xt_alloc_entry_offsets(unsigned int size) { + if (size > XT_MAX_TABLE_SIZE / sizeof(unsigned int)) + return NULL; + return kvmalloc_array(size, sizeof(unsigned int), GFP_KERNEL | __GFP_ZERO); }