2016-11-16 00:27:53

by Stephen Rothwell

[permalink] [raw]
Subject: linux-next: build warning after merge of the pstore tree

Hi Kees,

After merging the pstore tree, today's linux-next build (x86_64
allmodconfig) produced this warning:

In file included from include/linux/rcupdate.h:38:0,
from include/linux/idr.h:18,
from include/linux/kernfs.h:14,
from include/linux/sysfs.h:15,
from include/linux/kobject.h:21,
from include/linux/device.h:17,
from fs/pstore/ram_core.c:17:
fs/pstore/ram_core.c: In function 'buffer_size_add':
include/linux/spinlock.h:246:3: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
_raw_spin_unlock_irqrestore(lock, flags); \
^
fs/pstore/ram_core.c:78:16: note: 'flags' was declared here
unsigned long flags;
^
In file included from include/linux/rcupdate.h:38:0,
from include/linux/idr.h:18,
from include/linux/kernfs.h:14,
from include/linux/sysfs.h:15,
from include/linux/kobject.h:21,
from include/linux/device.h:17,
from fs/pstore/ram_core.c:17:
fs/pstore/ram_core.c: In function 'buffer_start_add':
include/linux/spinlock.h:246:3: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
_raw_spin_unlock_irqrestore(lock, flags); \
^
fs/pstore/ram_core.c:56:16: note: 'flags' was declared here
unsigned long flags;
^

Introduced by commit

95937ddce59a ("pstore: Allow prz to control need for locking")

They appear to be a very noisy false positives. :-(

--
Cheers,
Stephen Rothwell


2016-11-16 00:35:38

by Kees Cook

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the pstore tree

On Tue, Nov 15, 2016 at 4:27 PM, Stephen Rothwell <[email protected]> wrote:
> Hi Kees,
>
> After merging the pstore tree, today's linux-next build (x86_64
> allmodconfig) produced this warning:
>
> In file included from include/linux/rcupdate.h:38:0,
> from include/linux/idr.h:18,
> from include/linux/kernfs.h:14,
> from include/linux/sysfs.h:15,
> from include/linux/kobject.h:21,
> from include/linux/device.h:17,
> from fs/pstore/ram_core.c:17:
> fs/pstore/ram_core.c: In function 'buffer_size_add':
> include/linux/spinlock.h:246:3: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
> _raw_spin_unlock_irqrestore(lock, flags); \
> ^
> fs/pstore/ram_core.c:78:16: note: 'flags' was declared here
> unsigned long flags;
> ^
> In file included from include/linux/rcupdate.h:38:0,
> from include/linux/idr.h:18,
> from include/linux/kernfs.h:14,
> from include/linux/sysfs.h:15,
> from include/linux/kobject.h:21,
> from include/linux/device.h:17,
> from fs/pstore/ram_core.c:17:
> fs/pstore/ram_core.c: In function 'buffer_start_add':
> include/linux/spinlock.h:246:3: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
> _raw_spin_unlock_irqrestore(lock, flags); \
> ^
> fs/pstore/ram_core.c:56:16: note: 'flags' was declared here
> unsigned long flags;
> ^
>
> Introduced by commit
>
> 95937ddce59a ("pstore: Allow prz to control need for locking")
>
> They appear to be a very noisy false positives. :-(

Hah. Ironically, I ran sparse against this code to make sure it would
be happy with the conditional locking, and totally missed the flags
bit. I'll switch it to explicitly initialize flags to silence this.

Thanks!

-Kees

--
Kees Cook
Nexus Security

2016-11-16 05:19:45

by Joel Fernandes

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the pstore tree

On Tue, Nov 15, 2016 at 4:35 PM, Kees Cook <[email protected]> wrote:
> On Tue, Nov 15, 2016 at 4:27 PM, Stephen Rothwell <[email protected]> wrote:
>> Hi Kees,
>>
>> After merging the pstore tree, today's linux-next build (x86_64
>> allmodconfig) produced this warning:
>>
>> In file included from include/linux/rcupdate.h:38:0,
>> from include/linux/idr.h:18,
>> from include/linux/kernfs.h:14,
>> from include/linux/sysfs.h:15,
>> from include/linux/kobject.h:21,
>> from include/linux/device.h:17,
>> from fs/pstore/ram_core.c:17:
>> fs/pstore/ram_core.c: In function 'buffer_size_add':
>> include/linux/spinlock.h:246:3: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
>> _raw_spin_unlock_irqrestore(lock, flags); \
>> ^
>> fs/pstore/ram_core.c:78:16: note: 'flags' was declared here
>> unsigned long flags;
>> ^
>> In file included from include/linux/rcupdate.h:38:0,
>> from include/linux/idr.h:18,
>> from include/linux/kernfs.h:14,
>> from include/linux/sysfs.h:15,
>> from include/linux/kobject.h:21,
>> from include/linux/device.h:17,
>> from fs/pstore/ram_core.c:17:
>> fs/pstore/ram_core.c: In function 'buffer_start_add':
>> include/linux/spinlock.h:246:3: warning: 'flags' may be used uninitialized in this function [-Wmaybe-uninitialized]
>> _raw_spin_unlock_irqrestore(lock, flags); \
>> ^
>> fs/pstore/ram_core.c:56:16: note: 'flags' was declared here
>> unsigned long flags;
>> ^
>>
>> Introduced by commit
>>
>> 95937ddce59a ("pstore: Allow prz to control need for locking")
>>
>> They appear to be a very noisy false positives. :-(
>
> Hah. Ironically, I ran sparse against this code to make sure it would
> be happy with the conditional locking, and totally missed the flags
> bit. I'll switch it to explicitly initialize flags to silence this.
>

Ah! False positive.

Thanks a lot Kees for fixing it.

Regards,
Joel