Received: by 10.192.245.15 with SMTP id i15csp962423imn; Sat, 10 Mar 2018 15:28:47 -0800 (PST) X-Google-Smtp-Source: AG47ELuu8hnWJOwvoF6TeqmEqUfnAKS+WuJc5rdkerPGGYtvABXwb50rjG2lSLvgYKkBksja9I1l X-Received: by 10.101.86.198 with SMTP id w6mr2670875pgs.434.1520724527220; Sat, 10 Mar 2018 15:28:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520724527; cv=none; d=google.com; s=arc-20160816; b=tH3m6nsPSiaNv0eMUE+xuBZoJJt76gSJk1a3+YEK5mJCnRYlVLXSqELpDzVxORjAeb FX+NBrSyKdBzsYZjce2nBBM8EDE05KVV88ExZ7sxo3GGY0+vBsVQLfgmKwaT7j7R1wqL DorxtXfFnXlIYylO4sPxbHkJcBbNkXE71Vwckx4B6LEx0xK2XjV1taqkDUdsnMkhKiVQ k8Pq3Cq4rbNfypGd8vtzhXFIk6olikb/kSoyksgkwiorfoKfFGL6vUWuPGCmVCU/QsPe sAFH3l9xr8AzQ5mM0LbT8+KKSmIvZRYHlGk0yDDzZ2DJn/cZCiwPw/2ZKJ1s/7CZIejs 7Hmw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=e48vBYAmygDVZLqlBKKezhwM/q9i0W3KI0sQr7IL9B0=; b=MSlWNNcZby38EX4fbu9IuvRbHpJeUrXp8A4IA9jlAv/5wyEcRp+TCPZOqyEkfORYrA 8Llr9hkHgjzSZ3bj/zjI+8ZODJlN57cQ52oNUIHQ18Nv4zmjt8/KtWVucP2SnB5VHtyB yrQubJiOphDQOdq0lBuGf043Tiy50AbWhP/Uy/23JyoyTAUTB83ZI6DkMLOFt0zD7KHV eexI2Nq3R26T44TL9Insj2Jt7xNopwEl3YT0SwxXrG/aKbDUpHzBBlbgDYzTXET6wH4s HsTF5vqW2zOSgtdFL25jVrWjfhHblyNYm2g/diuhEurVvJIXKdmpgKNhf8dGnBew9C8y hsLw== 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 q3si2879341pgp.632.2018.03.10.15.28.12; Sat, 10 Mar 2018 15:28:47 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751225AbeCJX0w (ORCPT + 99 others); Sat, 10 Mar 2018 18:26:52 -0500 Received: from gateway31.websitewelcome.com ([192.185.143.47]:18108 "EHLO gateway31.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751172AbeCJX0u (ORCPT ); Sat, 10 Mar 2018 18:26:50 -0500 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 4253230B27 for ; Sat, 10 Mar 2018 17:26:48 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id unt2e1WIYE0sxunt2e1Jlv; Sat, 10 Mar 2018 17:26:48 -0600 Received: from [189.175.117.58] (port=44090 helo=[192.168.1.66]) by gator4166.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1eunt1-002iV5-MV; Sat, 10 Mar 2018 17:26:47 -0600 Subject: Re: [PATCH] drivers: net: wireless: ath: ath9: dfs: remove VLA usage To: Kees Cook , Arend van Spriel Cc: Andreas Christoforou , Kernel Hardening , QCA ath9k Development , Kalle Valo , linux-wireless , Network Development , LKML References: <1520598613-3641-1-git-send-email-andreaschristofo@gmail.com> <5AA464DE.90100@broadcom.com> From: "Gustavo A. R. Silva" Message-ID: <0475443a-5026-e897-bd52-9198f854919f@embeddedor.com> Date: Sat, 10 Mar 2018 17:26:46 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.175.117.58 X-Source-L: No X-Exim-ID: 1eunt1-002iV5-MV X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.1.66]) [189.175.117.58]:44090 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 9 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/10/2018 05:12 PM, Kees Cook wrote: > On Sat, Mar 10, 2018 at 3:06 PM, Arend van Spriel > wrote: >> On 3/9/2018 1:30 PM, Andreas Christoforou wrote: >>> >>> The kernel would like to have all stack VLA usage removed. >> >> >> I think there was a remark made earlier to give more explanation here. It >> should explain why we want "VLA on stack" removed. >> >>> Signed-off-by: Andreas Christoforou >>> --- >>> drivers/net/wireless/ath/ath9k/dfs.c | 3 +-- >>> 1 file changed, 1 insertion(+), 2 deletions(-) >>> >>> diff --git a/drivers/net/wireless/ath/ath9k/dfs.c >>> b/drivers/net/wireless/ath/ath9k/dfs.c >>> index 6fee9a4..cfb0f84 100644 >>> --- a/drivers/net/wireless/ath/ath9k/dfs.c >>> +++ b/drivers/net/wireless/ath/ath9k/dfs.c >>> @@ -41,7 +41,6 @@ static const int BIN_DELTA_MAX = 10; >>> >>> /* we need at least 3 deltas / 4 samples for a reliable chirp detection >>> */ >>> #define NUM_DIFFS 3 >>> -static const int FFT_NUM_SAMPLES = (NUM_DIFFS + 1); >>> What about this instead? #define FFT_NUM_SAMPLES (NUM_DIFFS + 1) >>> /* Threshold for difference of delta peaks */ >>> static const int MAX_DIFF = 2; >>> @@ -101,7 +100,7 @@ static bool ath9k_check_chirping(struct ath_softc *sc, >>> u8 *data, >>> int datalen, bool is_ctl, bool is_ext) >>> { >>> int i; >>> - int max_bin[FFT_NUM_SAMPLES]; >>> + int max_bin[NUM_DIFFS + 1]; >> >> >> Just wondering. Is this actually a VLA. FFT_NUM_SAMPLES was static const so >> not really going to show a lot of variation. This array will always have the >> same size on the stack. > > The problem is that it's not a "constant expression", so the compiler > frontend still yells about it under -Wvla. I would characterize this > mainly as a fix for "accidental VLA" or "misdetected VLA" or something > like that. AIUI, there really isn't a functional change here. > > -Kees > -- Gustavo