Received: by 10.223.185.111 with SMTP id b44csp1644683wrg; Sat, 10 Mar 2018 10:28:14 -0800 (PST) X-Google-Smtp-Source: AG47ELt/pcy/cwahjKUMBGpB71zz+GBZUWYVbyzCuqombHkuVXeSVw1KDo2fX252+m+vzpKbuKoh X-Received: by 10.98.69.196 with SMTP id n65mr2691589pfi.29.1520706494611; Sat, 10 Mar 2018 10:28:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520706494; cv=none; d=google.com; s=arc-20160816; b=xYMC3yAOE8HTYHamblD9+QLws4f9jAqJgZrjG0WFgGSUC8PRqyACG0fHiZ9v5AF/7k QAOu+FjwDYqtoSyu8xoZACpNpIFlXUqNK4Ueiz+Ici8ZmXmsgRekk/jbZm5s1B7FnixF Wkdc/HvjdHlIsgsIoTWa8QwrEuugzq304W0yAVBqdqZiW4yh5bL0+aReLrkfnyIrw4sV qV4/hjrEdmqd04/MWgueUej6OKrCGRtBWNx2CV7hP3UPTaKxIG+y1957Pt0RtqPY+Xod LIPx2zyREpOCD/txCRVMlaDsmEuVMT9eygRrpvCYLDCcxfxweZPAy7rfnaJyxGg79Jxx r9ag== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=6iPCUHqZYN2TBkHNCfAvyC1mbf1NC4z9Z0LlXIQqcG0=; b=rikV1DqkexL7/N/V0VpJLGYscmLPOpCLC5pmVYcbRbE35L1kyQsf2qYYU5ZGygdH79 tL17T0L4KXlTzQfFrmOsmIWWNbkCuwiAxwm5Xw4Uwc8cxg2L6mBqYEeA89j0SSddqbyi vmUyYi86eLy1nBo4iIC01jjx40pY9jS+owtgDW32dgWr9WzePp9Z+F2GRRsKvib5+h36 ARDHaX8pMKPgvcnua3TADFAoZrtF3N9oESD+ACn7g9Xo/KMxDMwUlbnhMzdF0PvJ6G2O liC445qFwvNzjD7/OuQiH3rtlU446E9+6L3PP4oGlAUAQgk9IOUHGOzlJfGUICl9+R43 VZBA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61-v6si3152435plf.640.2018.03.10.10.28.00; Sat, 10 Mar 2018 10:28:14 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752020AbeCJS0y (ORCPT + 99 others); Sat, 10 Mar 2018 13:26:54 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:35428 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751113AbeCJS0v (ORCPT ); Sat, 10 Mar 2018 13:26:51 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E11178182D1D; Sat, 10 Mar 2018 18:26:50 +0000 (UTC) Received: from epycfail (ovpn-112-65.ams2.redhat.com [10.36.112.65]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0915B6F9E2; Sat, 10 Mar 2018 18:26:47 +0000 (UTC) Date: Sat, 10 Mar 2018 19:26:44 +0100 From: Stefano Brivio To: Kees Cook Cc: Andreas Christoforou , Kernel Hardening , Steffen Klassert , Herbert Xu , "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Network Development , LKML Subject: Re: [PATCH v2] net: ipv6: xfrm6_state: remove VLA usage Message-ID: <20180310192644.3fcbb69d@epycfail> In-Reply-To: References: <1520667645-21975-1-git-send-email-andreaschristofo@gmail.com> <20180310094327.685d181d@epycfail> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Sat, 10 Mar 2018 18:26:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Sat, 10 Mar 2018 18:26:51 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'sbrivio@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 10 Mar 2018 09:18:46 -0800 Kees Cook wrote: > On Sat, Mar 10, 2018 at 12:43 AM, Stefano Brivio wrote: > > On Sat, 10 Mar 2018 09:40:44 +0200 > > Andreas Christoforou wrote: > > > >> diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c > >> index b15075a..270a53a 100644 > >> --- a/net/ipv6/xfrm6_state.c > >> +++ b/net/ipv6/xfrm6_state.c > >> @@ -62,7 +62,7 @@ __xfrm6_sort(void **dst, void **src, int n, int (*cmp)(void *p), int maxclass) > >> { > >> int i; > >> int class[XFRM_MAX_DEPTH]; > >> - int count[maxclass]; > >> + int count[XFRM_MAX_DEPTH]; > >> > >> memset(count, 0, sizeof(count)); > > > > Can you perhaps initialize 'count' instead of calling memset(), now? > > Do you mean: > > int count[XFRM_MAX_DEPTH] = { }; > > instead of the memset()? Yep. > I thought the compiler would resolve these both to the same thing? Yes, for all practical purposes. With gcc 7.3.0 for x86_64, starting from -O1, it's exactly the same. With e.g. gcc 4.4.7, even with -O3, they can be a bit different depending on context. > The former looks better though! :) Yep! :) -- Stefano