From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from gateway20.websitewelcome.com ([192.185.60.19]:26026 "EHLO gateway20.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751189AbeCJXvL (ORCPT ); Sat, 10 Mar 2018 18:51:11 -0500 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway20.websitewelcome.com (Postfix) with ESMTP id 4209E400D0F70 for ; Sat, 10 Mar 2018 17:26:48 -0600 (CST) 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> (sfid-20180311_005115_359401_ED2AC95E) Date: Sat, 10 Mar 2018 17:26:46 -0600 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Sender: linux-wireless-owner@vger.kernel.org List-ID: 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