From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58D89C3524D for ; Mon, 3 Feb 2020 20:18:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2ED0C20720 for ; Mon, 3 Feb 2020 20:18:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727151AbgBCUSg (ORCPT ); Mon, 3 Feb 2020 15:18:36 -0500 Received: from Chamillionaire.breakpoint.cc ([193.142.43.52]:60622 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbgBCUSg (ORCPT ); Mon, 3 Feb 2020 15:18:36 -0500 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1iyiAz-00078R-RN; Mon, 03 Feb 2020 21:18:33 +0100 Date: Mon, 3 Feb 2020 21:18:33 +0100 From: Florian Westphal To: Cong Wang Cc: Florian Westphal , Linux Kernel Network Developers , NetFilter , syzbot , Pablo Neira Ayuso , Jozsef Kadlecsik Subject: Re: [Patch nf v2 1/3] xt_hashlimit: avoid OOM for user-controlled vmalloc Message-ID: <20200203201833.GA15904@breakpoint.cc> References: <20200203043053.19192-1-xiyou.wangcong@gmail.com> <20200203043053.19192-2-xiyou.wangcong@gmail.com> <20200203121612.GR795@breakpoint.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Cong Wang wrote: > On Mon, Feb 3, 2020 at 4:16 AM Florian Westphal wrote: > > > > Cong Wang wrote: > > > 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@syzkaller.appspotmail.com > > > Cc: Pablo Neira Ayuso > > > Cc: Jozsef Kadlecsik > > > Cc: Florian Westphal > > > Signed-off-by: Cong Wang > > > --- > > > net/netfilter/xt_hashlimit.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c > > > index bccd47cd7190..5d9943b37c42 100644 > > > --- a/net/netfilter/xt_hashlimit.c > > > +++ b/net/netfilter/xt_hashlimit.c > > > @@ -293,8 +293,8 @@ 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)); > > > + hinfo = __vmalloc(struct_size(hinfo, hash, size), > > > + GFP_USER | __GFP_NOWARN | __GFP_NORETRY, PAGE_KERNEL); > > > > Sorry for not noticing this earlier: should that be GFP_KERNEL_ACCOUNT > > instead of GFP_USER? > > Why do you think it should be accounted in kmemcg? We do that for xtables blob allocation, see xt_alloc_table_info(). > I think this one is controlled by user, so I pick GFP_USER, > like many other cases, for example, > proc_allowed_congestion_control(). Ok, I see, fair enough -- no objections from me.