Skip to content

Commit 1992696

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: x_tables: cap allocations at 512 mbyte
Arbitrary limit, however, this still allows huge rulesets (> 1 million rules). This helps with automated fuzzer as it prevents oom-killer invocation. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent e816a2c commit 1992696

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/netfilter/x_tables.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
4040
MODULE_DESCRIPTION("{ip,ip6,arp,eb}_tables backend module");
4141

4242
#define XT_PCPU_BLOCK_SIZE 4096
43+
#define XT_MAX_TABLE_SIZE (512 * 1024 * 1024)
4344

4445
struct compat_delta {
4546
unsigned int offset; /* offset in kernel */
@@ -1117,7 +1118,7 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size)
11171118
struct xt_table_info *info = NULL;
11181119
size_t sz = sizeof(*info) + size;
11191120

1120-
if (sz < sizeof(*info))
1121+
if (sz < sizeof(*info) || sz >= XT_MAX_TABLE_SIZE)
11211122
return NULL;
11221123

11231124
/* __GFP_NORETRY is not fully supported by kvmalloc but it should

0 commit comments

Comments
 (0)