Received: by 10.213.65.68 with SMTP id h4csp19381imn; Mon, 12 Mar 2018 05:25:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELtQZ88Y0PzASoIymhdbmi8w8lD973PmmCmo3bqJrX7tntVIJ5wqsm/ggG/c9aJOIh4E4DX0 X-Received: by 10.99.116.30 with SMTP id p30mr1064177pgc.60.1520857557251; Mon, 12 Mar 2018 05:25:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520857557; cv=none; d=google.com; s=arc-20160816; b=SUeiGSNlNaCEOjkhejmEZheqY9+dnP/DGZPeIpwZjHXKdOgHi2uxpW53Eo10SJ62bb Z0Y7TBsrJyn+Wl1SQ++PjAb/t39VqhAXR9G8TcducaliLBln4Rp9/jxQxivmYfOS3Kj5 +D5TCYRN5oVHsKfe6hAfP5MXC9r685wQURkm8mpm1tE8vgDjf/QQdDZZNiQpsgVXbRb7 d8XgRisJkKkuI/dTImyJa8k5XoNhdQ2FfDrhg//S4GAqHLEqYVb8ynmhTDrgJ6mq6Rvp uk8Zd03h9TfrxJp37deErtWnUl+WtLd7eyhvu1NIw/oiLJPem85RLOAlmWgLgCHesVBu SqYA== 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=H2+SvRy6b44MNjtpS+5tree87cm1YEgb7KhvSWbDWsE=; b=OkRRdAR1qM1Dkv4b9QdYit5pzCpo9b/WMKogtZ7kIYYruovY9DMCIXQZSPgUSZoRJ1 5T8ZGd+UbkCOtqkevb/v1o3yJu+XqSYuIku0/QtLzpFQXP9oStX8TzNPWufd0/O+DjW0 cRG9PRjcfYa7mLyxpm89rezYMCWyBoZuY0GVa2gvyrRWXI30BKofpkxMmHUblna0Vt/g H4g7DGc+lsaZctLD4WuW+VC3hISI3tgs5S8AfcsMcA/LfxDvXNAq+0NBRpPa9EbdOqJN bQkMYY22vzwhAFd9DVpPW4z1cG2FvbIhcfHic8sloCK2z6vykIWF7j9qRRtrWleCpoCf 7nhg== 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 f9-v6si5823746pln.542.2018.03.12.05.25.42; Mon, 12 Mar 2018 05:25:57 -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 S1751616AbeCLMYI (ORCPT + 99 others); Mon, 12 Mar 2018 08:24:08 -0400 Received: from a.mx.secunet.com ([62.96.220.36]:60734 "EHLO a.mx.secunet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751394AbeCLMYG (ORCPT ); Mon, 12 Mar 2018 08:24:06 -0400 Received: from localhost (localhost [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id BBF53201B4; Mon, 12 Mar 2018 13:24:05 +0100 (CET) X-Virus-Scanned: by secunet Received: from a.mx.secunet.com ([127.0.0.1]) by localhost (a.mx.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mU0bikIgaCo5; Mon, 12 Mar 2018 13:24:04 +0100 (CET) Received: from mail-essen-01.secunet.de (mail-essen-01.secunet.de [10.53.40.204]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a.mx.secunet.com (Postfix) with ESMTPS id 5850A20189; Mon, 12 Mar 2018 13:24:04 +0100 (CET) Received: from gauss2.secunet.de (10.182.7.193) by mail-essen-01.secunet.de (10.53.40.204) with Microsoft SMTP Server id 14.3.382.0; Mon, 12 Mar 2018 13:24:04 +0100 Received: by gauss2.secunet.de (Postfix, from userid 1000) id E7E0431824AF; Mon, 12 Mar 2018 13:24:03 +0100 (CET) Date: Mon, 12 Mar 2018 13:24:03 +0100 From: Steffen Klassert To: Stefano Brivio CC: Kees Cook , Andreas Christoforou , Kernel Hardening , 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: <20180312122403.tkav5d3plfll63vp@gauss3.secunet.de> References: <1520667645-21975-1-git-send-email-andreaschristofo@gmail.com> <20180310094327.685d181d@epycfail> <20180310192644.3fcbb69d@epycfail> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20180310192644.3fcbb69d@epycfail> User-Agent: NeoMutt/20170609 (1.8.3) X-G-Data-MailSecurity-for-Exchange-State: 0 X-G-Data-MailSecurity-for-Exchange-Error: 0 X-G-Data-MailSecurity-for-Exchange-Sender: 23 X-G-Data-MailSecurity-for-Exchange-Server: d65e63f7-5c15-413f-8f63-c0d707471c93 X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 X-G-Data-MailSecurity-for-Exchange-Guid: 912AC1C5-CE00-4ECA-B7BE-D7957649ABCA Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 10, 2018 at 07:26:44PM +0100, Stefano Brivio wrote: > 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! :) If Andreas does a v3 anyway, please also consider to trim the subject line to something like: xfrm: remove VLA usage in __xfrm6_sort()