Received: by 10.213.65.16 with SMTP id m16csp56584imf; Sun, 11 Mar 2018 15:05:40 -0700 (PDT) X-Google-Smtp-Source: AG47ELvIERnJWPB9Y5kyBk//29HfooAs2u3eh1NGQAsoiajlvHZipY09vinWP6dyKfZThgMUiK5+ X-Received: by 2002:a17:902:167:: with SMTP id 94-v6mr6025629plb.294.1520805939977; Sun, 11 Mar 2018 15:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520805939; cv=none; d=google.com; s=arc-20160816; b=oLaruBZEpfQUqfB4VkfCeghIfsm53zQaemCZf9oIP19ufky2mx4x/IL+jBnCTPrUwh V0IXiy8n9F9h5OC52ODctIValxi+ty3N3CbnVPwv2P3/uDu5Ve8j77x7w78jt6q16WWD 6jl+DckOL/2vSUR/7eFzKf99W45T2Y2KVrlXDjW2TOfW+Jf2Xd7j09ANdHxL2srjfIzY /u5OFst+ak2qMfGeupdhBwR6g3M3PxCXO919O0mi+D1FlbYuxvqJzDPNMeibzT90cKk7 YS0Ma19bWdOOEEXrOPR2gMzSJftzlEPnGh7VCJDsV0EGW8JLBi/+pZ3/U1aexSjQd4vS S3yA== 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:arc-authentication-results; bh=1lmpdZdQHBrB1TJ5JCXKTaVc2FPdT2z6NuT5YTMa9ds=; b=d854wXOCqc7cz+1MtXiX0eiZJ6/rj01oWQrEk1AQdVFbR5c32k4TiFGWFZdMkiU4/o SRLKxze+Ig2waCgdlgVrOfU3iQj28OAKnHGOAOVEA3KlQjbliMNd4pH0XST5VXdZX5K0 IQjpvTyZvnpceI94B1MZMqk8Tes+d0pG9LDT8/iL3YwpoaDxBbXSIfX7S3ee1I6IvzbK Gx4aUPXF+4sLDD4Ut/sqrdDiltelf6hOBGvLvRPVYj1/9O5CqgKjGrW+A//22QY1iVs5 0KPK+/V6YR3WSKyM5wfsZFR0ZbhU43nkMUYnmkxbh0I83qwTNVOCGiRo5EKR4FsMBdro SnmA== 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 y6si4117642pgo.735.2018.03.11.15.05.25; Sun, 11 Mar 2018 15:05:39 -0700 (PDT) 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 S932469AbeCKWEU (ORCPT + 99 others); Sun, 11 Mar 2018 18:04:20 -0400 Received: from mail.us.es ([193.147.175.20]:44386 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932344AbeCKWES (ORCPT ); Sun, 11 Mar 2018 18:04:18 -0400 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 06E011176B4 for ; Sun, 11 Mar 2018 23:04:15 +0100 (CET) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id EADDDDA727 for ; Sun, 11 Mar 2018 23:04:14 +0100 (CET) Received: by antivirus1-rhel7.int (Postfix, from userid 99) id CD597DA78B; Sun, 11 Mar 2018 23:04:14 +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.0 required=7.5 tests=ALL_TRUSTED,BAYES_50, HEADER_FROM_DIFFERENT_DOMAINS,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 E2C2DDA727; Sun, 11 Mar 2018 23:04:12 +0100 (CET) Received: from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int (F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); Sun, 11 Mar 2018 23:04:12 +0100 (CET) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int) Received: from us.es (129.166.216.87.static.jazztel.es [87.216.166.129]) (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 931F441E4818; Sun, 11 Mar 2018 23:04:12 +0100 (CET) Date: Sun, 11 Mar 2018 23:04:14 +0100 X-SMTPAUTHUS: auth mail.us.es From: Pablo Neira Ayuso To: "Gustavo A. R. Silva" Cc: Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: Re: [RFC] netfilter: cttimeout: remove VLA in ctnl_timeout_parse_policy Message-ID: <20180311220414.feda33aw72zw2rko@salvia> References: <20180306184755.GA7628@embeddedgus> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180306184755.GA7628@embeddedgus> 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 Tue, Mar 06, 2018 at 12:47:55PM -0600, Gustavo A. R. Silva wrote: > In preparation to enabling -Wvla, remove VLA and replace it > with dynamic memory allocation. Looks good but... > Signed-off-by: Gustavo A. R. Silva > --- > net/netfilter/nfnetlink_cttimeout.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c > index 95b0470..a2f7d92 100644 > --- a/net/netfilter/nfnetlink_cttimeout.c > +++ b/net/netfilter/nfnetlink_cttimeout.c > @@ -52,18 +52,26 @@ ctnl_timeout_parse_policy(void *timeouts, > struct net *net, const struct nlattr *attr) > { > int ret = 0; > + struct nlattr **tb = NULL; I think we don't need to initialize this, right? > > if (likely(l4proto->ctnl_timeout.nlattr_to_obj)) { > - struct nlattr *tb[l4proto->ctnl_timeout.nlattr_max+1]; > + tb = kcalloc(l4proto->ctnl_timeout.nlattr_max + 1, sizeof(*tb), > + GFP_KERNEL); > + > + if (!tb) > + return -ENOMEM; > > ret = nla_parse_nested(tb, l4proto->ctnl_timeout.nlattr_max, > attr, l4proto->ctnl_timeout.nla_policy, > NULL); > if (ret < 0) > - return ret; > + goto err; > > ret = l4proto->ctnl_timeout.nlattr_to_obj(tb, net, timeouts); > } > + > +err: > + kfree(tb); > return ret; > } > > -- > 2.7.4 >