Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1350116imu; Wed, 9 Jan 2019 16:50:00 -0800 (PST) X-Google-Smtp-Source: ALg8bN5tseyNNS9cgV9noNpdTG72M5gUbpXJamHsbZaI88iXlCrhwJIoTm2fIzbMLyib6UDbPBAM X-Received: by 2002:a63:451a:: with SMTP id s26mr7531844pga.150.1547081400601; Wed, 09 Jan 2019 16:50:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547081400; cv=none; d=google.com; s=arc-20160816; b=y89q84sFWXRPBLRHdpQtpDEA7TNSrNO1vkV2VpZoczCgYoMbXWP69j3/lGJ4dmIBFy c6NXJEgGAvYZNnd1Ci1g0MlhUlUddxWNvUjkg5InljTL/GcvswSnk/FkG2+VbZ0eHUfy kc36JOGHezxgUXIPR8c7yq8gUa5fFV7Ohy2CQJyuTAhmLxRNk5FZD0fexK0BSv1UjFoM eqCv4hOtGhu0MmRyyZVTnXaG+tCbPtQIF+RuM07am21WAfxHUHInS13A4Q7CizYqE+Oh nfwxUQG70PwpoVYcxmMpVbKzY0M5v7eX1D4YPYvEWoJbYEfwbBQbyWJKpOByFKlgRx/W Zl3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=IATlR++OR3CRUDi26RqBOBFscFc7UBU/oIfe2+CTgPQ=; b=w2JZe934T4kX54Y//uPl70bXwHmplTUdSQJiXSm49bZGIKb4KdqOamx/hzO1wczeNx C6nUgTnUWRuL9incEPuL2cwVcEUe3wCLUdMeyJYk7Dj2H+1O+mlA32BwRhULghZtjKTb TAGj4i8aTWwD0VUhspp4AdFu1FxCpxbcSDOCeolDDg59vHt0ir42vlE1ut/KjLRthBVo lwNu9E/q8i1S9fMk/bWl6K/MA4sBWosp6eV6n2NRlRRz6Du8Y6GlzBQrAL/oto36BRTA eZewA83/56hE5M45TQzL5rG3wNmSFm2SwDj1ffhASg9CUl1Xy1TFtxmdqauIP6NEV/4e Alhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5si22354800pgk.49.2019.01.09.16.49.44; Wed, 09 Jan 2019 16:50:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726818AbfAJAof (ORCPT + 99 others); Wed, 9 Jan 2019 19:44:35 -0500 Received: from mail.us.es ([193.147.175.20]:49274 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726730AbfAJAoe (ORCPT ); Wed, 9 Jan 2019 19:44:34 -0500 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 3C3E01E8FA4 for ; Thu, 10 Jan 2019 01:44:31 +0100 (CET) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 1FF65DA84E for ; Thu, 10 Jan 2019 01:44:31 +0100 (CET) Received: by antivirus1-rhel7.int (Postfix, from userid 99) id 00185DA86E; Thu, 10 Jan 2019 01:44:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on antivirus1-rhel7.int X-Spam-Level: X-Spam-Status: No, score=-108.2 required=7.5 tests=ALL_TRUSTED,BAYES_50, SMTPAUTH_US2,USER_IN_WHITELIST autolearn=disabled version=3.4.1 Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 366DADA7FC; Thu, 10 Jan 2019 01:44:27 +0100 (CET) Received: from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int (F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); Thu, 10 Jan 2019 01:44:27 +0100 (CET) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int) Received: from us.es (sys.soleta.eu [212.170.55.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 1984lsi) by entrada.int (Postfix) with ESMTPSA id F3D6A4265A5C; Thu, 10 Jan 2019 01:44:26 +0100 (CET) Date: Thu, 10 Jan 2019 01:44:26 +0100 X-SMTPAUTHUS: auth mail.us.es From: Pablo Neira Ayuso To: Shakeel Butt Cc: Michal Hocko , Andrew Morton , Florian Westphal , Kirill Tkhai , linux-mm@kvack.org, linux-kernel@vger.kernel.org, syzbot+7713f3aa67be76b1552c@syzkaller.appspotmail.com, Jozsef Kadlecsik , Roopa Prabhu , Nikolay Aleksandrov , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, bridge@lists.linux-foundation.org Subject: Re: [PATCH v2] netfilter: account ebt_table_info to kmemcg Message-ID: <20190110004426.p4n4lrpnnvv4czir@salvia> References: <20190103031431.247970-1-shakeelb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190103031431.247970-1-shakeelb@google.com> User-Agent: NeoMutt/20170113 (1.7.2) X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 02, 2019 at 07:14:31PM -0800, Shakeel Butt wrote: > The [ip,ip6,arp]_tables use x_tables_info internally and the underlying > memory is already accounted to kmemcg. Do the same for ebtables. The > syzbot, by using setsockopt(EBT_SO_SET_ENTRIES), was able to OOM the > whole system from a restricted memcg, a potential DoS. > > By accounting the ebt_table_info, the memory used for ebt_table_info can > be contained within the memcg of the allocating process. However the > lifetime of ebt_table_info is independent of the allocating process and > is tied to the network namespace. So, the oom-killer will not be able to > relieve the memory pressure due to ebt_table_info memory. The memory for > ebt_table_info is allocated through vmalloc. Currently vmalloc does not > handle the oom-killed allocating process correctly and one large > allocation can bypass memcg limit enforcement. So, with this patch, > at least the small allocations will be contained. For large allocations, > we need to fix vmalloc. Fine with this -mm? If no objections, I'll apply this to the netfilter tree. Thanks. > Reported-by: syzbot+7713f3aa67be76b1552c@syzkaller.appspotmail.com > Signed-off-by: Shakeel Butt > Cc: Florian Westphal > Cc: Michal Hocko > Cc: Kirill Tkhai > Cc: Pablo Neira Ayuso > Cc: Jozsef Kadlecsik > Cc: Roopa Prabhu > Cc: Nikolay Aleksandrov > Cc: Andrew Morton > Cc: Linux MM > Cc: netfilter-devel@vger.kernel.org > Cc: coreteam@netfilter.org > Cc: bridge@lists.linux-foundation.org > Cc: LKML > --- > Changelog since v1: > - More descriptive commit message. > > net/bridge/netfilter/ebtables.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c > index 491828713e0b..5e55cef0cec3 100644 > --- a/net/bridge/netfilter/ebtables.c > +++ b/net/bridge/netfilter/ebtables.c > @@ -1137,14 +1137,16 @@ static int do_replace(struct net *net, const void __user *user, > tmp.name[sizeof(tmp.name) - 1] = 0; > > countersize = COUNTER_OFFSET(tmp.nentries) * nr_cpu_ids; > - newinfo = vmalloc(sizeof(*newinfo) + countersize); > + newinfo = __vmalloc(sizeof(*newinfo) + countersize, GFP_KERNEL_ACCOUNT, > + PAGE_KERNEL); > if (!newinfo) > return -ENOMEM; > > if (countersize) > memset(newinfo->counters, 0, countersize); > > - newinfo->entries = vmalloc(tmp.entries_size); > + newinfo->entries = __vmalloc(tmp.entries_size, GFP_KERNEL_ACCOUNT, > + PAGE_KERNEL); > if (!newinfo->entries) { > ret = -ENOMEM; > goto free_newinfo; > -- > 2.20.1.415.g653613c723-goog >