lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 11 Oct 2018 17:16:41 +0100
From:   John Garry <john.garry@...wei.com>
To:     Johannes Berg <johannes@...solutions.net>,
        Joe Perches <joe@...ches.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Andy Shevchenko <andy.shevchenko@...il.com>,
        Kalle Valo <kvalo@...eaurora.org>,
        <jakub.kicinski@...ronome.com>, <yamada.masahiro@...ionext.com>,
        "Arnd Bergmann" <arnd@...db.de>, <viro@...iv.linux.org.uk>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     <linux-wireless@...r.kernel.org>, <nbd@....name>
Subject: Re: Question on FIELD_PREP() for static array

On 11/10/2018 16:23, Johannes Berg wrote:

Hi

> On Thu, 2018-10-11 at 15:24 +0100, John Garry wrote:
>>
>>> +#define BUILD_BUG_ON_RET_ZERO(cond) (sizeof(char[1 - 2*!!(cond)]) - 1)
>>> +#define BUILD_BUG_ON_NOT_POW2_RET_ZERO(n)	BUILD_BUG_ON_RET_ZERO(((n) & ((n) - 1)) != 0)
>
>> Seems reasonable. However I did try this and was getting compiler
>> warnings about VLA, from a non-constant being fed into
>> BUILD_BUG_ON_RET_ZERO(), related to sizeof char[]:
>> drivers/iio/adc/meson_saradc.c:375:2: warning: ISO C90 forbids variable
>> length array [-Wvla]
>>    regval = FIELD_PREP(MESON_SAR_ADC_CHAN_LIST_ENTRY_MASK(0),
>
> Hmm, what's the code there?

Nothing special, it was just a sample. Here'e the code:
     regval = FIELD_PREP(MESON_SAR_ADC_CHAN_LIST_ENTRY_MASK(0),
                 chan->address);

So val is a variable, and I find if remove both of the 
BUILD_BUG_ON_RET_ZERO()' which use __bf_shf() then it goes away.

>
> I don't see why the compiler should think it's a variable length?
>
>> Surely __NLA_ENSURE is getting a similar issue as it uses a similar
>> principle, no? I see that this is in -next now, but could not this macro
>> or derivatives being referenced.
>
> Yeah, I have a patch now to reference it, but I don't see anything from
> -Wvla with gcc 8.1?

I'm using a 7.3.1-based toolchain

>
> See
> https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git/commit/?id=3d7af878357acd9e37fc156928106f1a969c8942
> and its parent.
>
> Do you see -Wvla warnings there? Any idea how I could reproduce them?

I'll try it, thanks

John

>
> johannes
>
> .
>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ