From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Kees Cook <keescook@chromium.org>,
Arend van Spriel <arend.vanspriel@broadcom.com>
Cc: Andreas Christoforou <andreaschristofo@gmail.com>,
Kernel Hardening <kernel-hardening@lists.openwall.com>,
QCA ath9k Development <ath9k-devel@qca.qualcomm.com>,
Kalle Valo <kvalo@codeaurora.org>,
linux-wireless <linux-wireless@vger.kernel.org>,
Network Development <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drivers: net: wireless: ath: ath9: dfs: remove VLA usage
Date: Sat, 10 Mar 2018 17:26:46 -0600 [thread overview]
Message-ID: <0475443a-5026-e897-bd52-9198f854919f@embeddedor.com> (raw)
In-Reply-To: <CAGXu5jKDA=L5E6Cu_oRe-M=ouuhrccCZHyM+z6_UMAUqe9xnRQ@mail.gmail.com>
On 03/10/2018 05:12 PM, Kees Cook wrote:
> On Sat, Mar 10, 2018 at 3:06 PM, Arend van Spriel
> <arend.vanspriel@broadcom.com> 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 <andreaschristofo@gmail.com>
>>> ---
>>> 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
next prev parent reply other threads:[~2018-03-10 23:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-09 12:30 [PATCH] drivers: net: wireless: ath: ath9: dfs: remove VLA usage Andreas Christoforou
2018-03-09 12:51 ` Himanshu Jha
2018-03-09 14:48 ` Kalle Valo
2018-03-10 23:06 ` Arend van Spriel
2018-03-10 23:12 ` Kees Cook
2018-03-10 23:26 ` Gustavo A. R. Silva [this message]
[not found] ` <CAGXu5jKDA=L5E6Cu_oRe-M=ouuhrccCZHyM+z6_UMAUqe9xnRQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-03-14 1:38 ` Miguel Ojeda
2018-03-10 23:44 ` Daniel Micay
2018-03-13 12:32 ` David Laight
2018-03-14 1:18 ` Daniel Micay
2018-03-14 1:22 ` Daniel Micay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0475443a-5026-e897-bd52-9198f854919f@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=andreaschristofo@gmail.com \
--cc=arend.vanspriel@broadcom.com \
--cc=ath9k-devel@qca.qualcomm.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox