netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 11/47] netfilter: x_tables: cap allocations at 512 mbyte
Date: Fri, 30 Mar 2018 13:38:38 +0200	[thread overview]
Message-ID: <20180330113914.18431-2-pablo@netfilter.org> (raw)
In-Reply-To: <20180330113914.18431-1-pablo@netfilter.org>

From: Florian Westphal <fw@strlen.de>

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>
---
 net/netfilter/x_tables.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 4e6cbb38e616..dc68ac49614a 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -40,6 +40,7 @@ MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
 MODULE_DESCRIPTION("{ip,ip6,arp,eb}_tables backend module");
 
 #define XT_PCPU_BLOCK_SIZE 4096
+#define XT_MAX_TABLE_SIZE	(512 * 1024 * 1024)
 
 struct compat_delta {
 	unsigned int offset; /* offset in kernel */
@@ -1117,7 +1118,7 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size)
 	struct xt_table_info *info = NULL;
 	size_t sz = sizeof(*info) + size;
 
-	if (sz < sizeof(*info))
+	if (sz < sizeof(*info) || sz >= XT_MAX_TABLE_SIZE)
 		return NULL;
 
 	/* __GFP_NORETRY is not fully supported by kvmalloc but it should
-- 
2.11.0

  reply	other threads:[~2018-03-30 11:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-30 11:38 [PATCH 10/47] netfilter: x_tables: enforce unique and ascending entry points Pablo Neira Ayuso
2018-03-30 11:38 ` Pablo Neira Ayuso [this message]
2018-03-30 11:38 ` [PATCH 12/47] netfilter: x_tables: limit allocation requests for blob rule heads Pablo Neira Ayuso
2018-03-30 11:38 ` [PATCH 13/47] netfilter: x_tables: add counters allocation wrapper Pablo Neira Ayuso
2018-03-30 11:38 ` [PATCH 14/47] netfilter: compat: prepare xt_compat_init_offsets to return errors Pablo Neira Ayuso
2018-03-30 11:38 ` [PATCH 15/47] netfilter: compat: reject huge allocation requests Pablo Neira Ayuso
2018-03-30 11:38 ` [PATCH 16/47] netfilter: x_tables: make sure compat af mutex is held Pablo Neira Ayuso
2018-03-30 11:38 ` [PATCH 17/47] netfilter: x_tables: ensure last rule in base chain matches underflow/policy Pablo Neira Ayuso
2018-03-30 11:38 ` [PATCH 18/47] netfilter: make xt_rateest hash table per net Pablo Neira Ayuso
2018-03-30 11:38 ` [PATCH 19/47] netfilter: xt_limit: Spelling s/maxmum/maximum/ Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180330113914.18431-2-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).