Received: by 10.213.65.68 with SMTP id h4csp445674imn; Tue, 13 Mar 2018 09:16:48 -0700 (PDT) X-Google-Smtp-Source: AG47ELthfXZ36dEGvid8thqKDUhN9SBVhvkKRi+3xyLG5iLVBGa/l0df+qm8FIWLvzT8y/drV2xU X-Received: by 2002:a17:902:3383:: with SMTP id b3-v6mr1073016plc.224.1520957808428; Tue, 13 Mar 2018 09:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520957808; cv=none; d=google.com; s=arc-20160816; b=0kV84WKrpzl9Z1LSobXBxlIYfR9AdMEwB0rfAw8iCV+IoY6bGeAeduZxoNfO4hVPfJ +d/HXSZU2jXsk0gyTnZWwfMHghyw26VvMPqHkVWETyTBWfb6Jg49gpFvO4ilCcIiUPvl 6h0GLE0V/fmS4AcnIzqRxqNgS9JVlK4Cjsy2qPRnNdp9MIa528u0DVhdqhhqXMQUDQ91 o29EIMV38MRubzU+q0fIenGaaeFRcpzAXQUjNL0gIFebiXROUOGCLtFBpbP1cWqeoBsv B7J2HSJOsTr9z6Rg4HGWJ4u5HnNwIf5ktwKfKQAZpmrbYZ0UGsl/gmai5wsl6GXtp02F Gxvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=P5y63aY+vUejlY0Tc7Mvh6L8i9auGDx9h/jRNZGwRBs=; b=zlJSRacCNJRyi9qsMT+LpQ9CovmoIAqhXtOkImLac1wQ6arRWqdMICvNh0TJ6IBzX3 nXz93aROcly+axvVjiP9VDVeamLdorpt199MqIuvzCiEPutKQrGyJURsWMD68Z7Me8bL PWPinxR+4OwycYJZdNGYQwLyGGWhSKZRNFZfBvKDLT4Y7OXyN+9rYMQBthRGwlwHLNHH lLXLGh8pbCYyjs3+ieb9lMJWVNFAbg6xc32LIeh/hlJ+fm+Ins4kkLtIYFFNF/mQMqPQ WOmtFRnhyoN6/BzRSGmGSFzkQP7rh1BMwyR3QaICdTB4AwRYzjw49+aGyEb9nkV1Cr8i JKgw== 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 y6-v6si337271plr.174.2018.03.13.09.16.33; Tue, 13 Mar 2018 09:16:48 -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 S934125AbeCMQNz (ORCPT + 99 others); Tue, 13 Mar 2018 12:13:55 -0400 Received: from smtprelay0078.hostedemail.com ([216.40.44.78]:54942 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932638AbeCMQNw (ORCPT ); Tue, 13 Mar 2018 12:13:52 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 82420100E86CA; Tue, 13 Mar 2018 16:13:51 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:2894:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:4321:5007:6119:6742:9389:10004:10400:10848:11026:11232:11658:11914:12043:12438:12740:12760:12895:13069:13311:13357:13439:14659:14721:21080:21627:30012:30054:30070:30090:30091,0,RBL:47.151.150.235:@perches.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: skin35_5b889f845551f X-Filterd-Recvd-Size: 2751 Received: from XPS-9350 (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf10.hostedemail.com (Postfix) with ESMTPA; Tue, 13 Mar 2018 16:13:48 +0000 (UTC) Message-ID: <1520957627.2049.37.camel@perches.com> Subject: Re: [PATCH] netfilter: cttimeout: remove VLA usage From: Joe Perches To: Pablo Neira Ayuso Cc: "Gustavo A. R. Silva" , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kernel Hardening , Kees Cook , "Gustavo A. R. Silva" Date: Tue, 13 Mar 2018 09:13:47 -0700 In-Reply-To: <20180313145947.tpekwvyioaft5auc@salvia> References: <20180312231442.GA22071@embeddedgus> <1520899118.2049.24.camel@perches.com> <20180313145947.tpekwvyioaft5auc@salvia> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-03-13 at 15:59 +0100, Pablo Neira Ayuso wrote: > On Mon, Mar 12, 2018 at 04:58:38PM -0700, Joe Perches wrote: > > On Mon, 2018-03-12 at 18:14 -0500, Gustavo A. R. Silva wrote: > > > In preparation to enabling -Wvla, remove VLA and replace it > > > with dynamic memory allocation. > > > > > > From a security viewpoint, the use of Variable Length Arrays can be > > > a vector for stack overflow attacks. Also, in general, as the code > > > evolves it is easy to lose track of how big a VLA can get. Thus, we > > > can end up having segfaults that are hard to debug. > > > > > > Also, fixed as part of the directive to remove all VLAs from > > > > [] > > > diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c > > > > [] > > > @@ -51,19 +51,27 @@ ctnl_timeout_parse_policy(void *timeouts, > > > const struct nf_conntrack_l4proto *l4proto, > > > struct net *net, const struct nlattr *attr) > > > { > > > + struct nlattr **tb; > > > int ret = 0; > > > > > > - if (likely(l4proto->ctnl_timeout.nlattr_to_obj)) { > > > - struct nlattr *tb[l4proto->ctnl_timeout.nlattr_max+1]; > > > + if (!l4proto->ctnl_timeout.nlattr_to_obj) > > > + return 0; > > > > Why not > > if unlikely(!...) > > This is control plane code - not packet path - I think we should just > let the compiler decide on this one, not really need to provide an > explicit hint here. I don't have an issue with that, but it should probably be mentioned in the changelog as it's unrelated to VLA removal.