[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200131205216.22213-2-xiyou.wangcong@gmail.com>
Date: Fri, 31 Jan 2020 12:52:14 -0800
From: Cong Wang <xiyou.wangcong@...il.com>
To: netdev@...r.kernel.org
Cc: netfilter-devel@...r.kernel.org,
Cong Wang <xiyou.wangcong@...il.com>,
syzbot+adf6c6c2be1c3a718121@...kaller.appspotmail.com,
Pablo Neira Ayuso <pablo@...filter.org>,
Jozsef Kadlecsik <kadlec@...filter.org>,
Florian Westphal <fw@...len.de>
Subject: [Patch nf 1/3] xt_hashlimit: avoid OOM for user-controlled vmalloc
The hashtable size could be controlled by user, so use flags
GFP_USER | __GFP_NOWARN to avoid OOM warning triggered by user-space.
Also add __GFP_NORETRY to avoid retrying, as this is just a
best effort and the failure is already handled gracefully.
Reported-and-tested-by: syzbot+adf6c6c2be1c3a718121@...kaller.appspotmail.com
Cc: Pablo Neira Ayuso <pablo@...filter.org>
Cc: Jozsef Kadlecsik <kadlec@...filter.org>
Cc: Florian Westphal <fw@...len.de>
Signed-off-by: Cong Wang <xiyou.wangcong@...il.com>
---
net/netfilter/xt_hashlimit.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index bccd47cd7190..885a266d8e57 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -293,8 +293,9 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
if (size < 16)
size = 16;
}
- /* FIXME: don't use vmalloc() here or anywhere else -HW */
- hinfo = vmalloc(struct_size(hinfo, hash, size));
+ /* FIXME: don't use __vmalloc() here or anywhere else -HW */
+ hinfo = __vmalloc(struct_size(hinfo, hash, size),
+ GFP_USER | __GFP_NOWARN | __GFP_NORETRY, PAGE_KERNEL);
if (hinfo == NULL)
return -ENOMEM;
*out_hinfo = hinfo;
--
2.21.1
Powered by blists - more mailing lists