tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kernel stack usage



On 04.07.2020 15:51, Jaromír Doleček wrote:
> Le sam. 4 juil. 2020 à 15:30, Kamil Rytarowski <kamil%netbsd.org@localhost> a écrit :
>>> Kamil - what's the difference in gcc between -Wframe-larger-than= and
>>> -Wstack-size= ?
>>>
>>
>> -Wstack-size doesn't exist?
> 
> Sorry, meant -Wstack-usage=
> 

It looks like WStack-usage is GCC specific (absent in Clang) and it
includes alloca + vla. Both are not welcome in the kernel anyway so both
should give in most cases the same result.

>>> I see according to gcc documentation -Wframe-larger-than doesn't count
>>> size for alloca() and variable-length arrays, which makes it much less
>>> useful than -Wstack-usage.
>>>
>>
>> It's not a problem.
>>
>> Whenever alloca or VLA is in use, it's already breaking the stack
>> protector. There are a few exceptions registered in sys/conf/ssp.mk.
>>
>> We could add -Walloca -Wvla for USE_SSP=yes builds to catch quickly
>> inappropriate usage (frequently violated by code optimizer).
> 
> It's already not used in our kernel code, I checked and I found it
> used only in some arch-specific stand/ code. So -Walloca should be
> safe to turn on unconditionally, regardless of SSP. Unless the
> compiler emits alloca() calls itself.
> 

Sounds good. I'm for adding -Walloca and ideally -Wvla wherever possible
in the kernel.

> Jaromir
> 


Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index