Received: by 10.213.65.16 with SMTP id m16csp61167imf; Sun, 11 Mar 2018 15:22:28 -0700 (PDT) X-Google-Smtp-Source: AG47ELsh+KSnvwZJW7mF4tRzAqcuiy/gN0Fxq+OD2YEpjTqGKWCVKRJFL/UWmB1wRsz5dhWzbqUg X-Received: by 10.101.93.71 with SMTP id e7mr4954481pgt.248.1520806948644; Sun, 11 Mar 2018 15:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520806948; cv=none; d=google.com; s=arc-20160816; b=ttam/kDwtwyET5UD7sPJGp1AOQMuezzYTsiWuC9hPsISMdI4YoE3v6xB0O2M+5zTeD RsRjOUHCv1XUs7v6Wfm7PR4bk5U5u0phoX5UYtZmXDCr873wLjpnlAskB481VZRBXjl7 Mp1QNmmot4ST+05Eacl1kDilJ7hqXyvgMH+FBwaE5yFphV/ucA1KhGYLcgcro2siyI5g RubZBFzDFHFGE7I++ngOWQ6Yf9UF5ITMdd+H5/eB/kzDReL1/zEzu2I0HkTeAaAhtY7R uJkyvFtiie7/X8+aw5TSTKFUQ+Lyuw1VkyS3P92qi9+G0upqGmwPVLKholZWAlwrNn5o qoyA== 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=0ipdUqnvTwtdggvuwk4+KsP3lDpajCK3xY26+Bs2+T8=; b=yC4I1MTrnnYZrw7M9GcHyM5CYxvilH7uVGDV5e4VGQV8MIRbn+eRDJp4urZXTN75KD G5QaKWorzt7pCNaI3eqMVsPJ7JFG0vLJKqUNjff1fRncMT0tpxk2GsCfSxM8jEM0mqRZ sx9fkzIwrAzDB6+ayTonFMKLD8QAI0SknBwchVpDJhCPkxTO+ttxVss7qWj3E4Q5phth QI+LsfGUSpV3uhPfA86KsVk5K2tlxpUXyfYpfGvSZ8kEXqntiFwvrynJGvMF4otd/Wql shR7ITyhAzApcwpui/L0p5bfDuf2CTbHLpqh51G2XAo2Rtw103jeAnSwWE2QO6Kh8YX4 NikA== 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 m37-v6si4831642plg.372.2018.03.11.15.22.12; Sun, 11 Mar 2018 15:22:28 -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 S932418AbeCKWVR (ORCPT + 99 others); Sun, 11 Mar 2018 18:21:17 -0400 Received: from mail.us.es ([193.147.175.20]:46684 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932166AbeCKWVP (ORCPT ); Sun, 11 Mar 2018 18:21:15 -0400 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 73A541176B7 for ; Sun, 11 Mar 2018 23:21:11 +0100 (CET) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 63A98DA3AE for ; Sun, 11 Mar 2018 23:21:11 +0100 (CET) Received: by antivirus1-rhel7.int (Postfix, from userid 99) id 51B23DA552; Sun, 11 Mar 2018 23:21:11 +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 634DCDA786; Sun, 11 Mar 2018 23:21:09 +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:21:09 +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 14AC941E4805; Sun, 11 Mar 2018 23:21:08 +0100 (CET) Date: Sun, 11 Mar 2018 23:21:10 +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: <20180311222110.yk34o63ha5y34ssx@salvia> References: <20180306184755.GA7628@embeddedgus> <20180311220414.feda33aw72zw2rko@salvia> <20df6b07-b3e7-7733-ee05-b12589bd287f@embeddedor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20df6b07-b3e7-7733-ee05-b12589bd287f@embeddedor.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 Sun, Mar 11, 2018 at 05:12:09PM -0500, Gustavo A. R. Silva wrote: > Hi Pablo, > > On 03/11/2018 05:04 PM, Pablo Neira Ayuso wrote: > > 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? > > > > We actually do have to initialized it because in the unlikely case that the > code block inside the 'if' below is not executed, then we will end up > freeing an uninitialized pointer. I see, you're right indeed. We can probably simplify this code, but just doing: if (!l4proto->ctnl_timeout.nlattr_to_obj)) return 0; netlink attribute parsing here. You could even remove the likely() thing, which doesn't make much sense for control plane code. I understand this is a larger change, but I think this function will look better while we're removing VLA. Would you mind having a look? I'd appreciate if so. Thanks.