Re: [PATCH v3 3/5] kasan: support alloca() poisoning

From: Andrey Ryabinin
Date: Mon Dec 04 2017 - 12:06:39 EST




On 12/04/2017 07:55 PM, Andrey Ryabinin wrote:
>
>
> On 12/04/2017 07:42 PM, Christoph Hellwig wrote:
>> I don't think we are using alloca in kernel mode code, and we shouldn't.
>> What do I miss? Is this hidden support for on-stack VLAs? I thought
>> we'd get rid of them as well.
>>
>
> Yes, this is for on-stack VLA. Last time I checked, we still had a few.
>

E.g. building with -Wvla:


/home/andrew/linux/sound/core/pcm_native.c: In function âconstrain_params_by_rulesâ:
/home/andrew/linux/sound/core/pcm_native.c:326:2: warning: ISO C90 forbids variable length array ârstampsâ [-Wvla]
unsigned int rstamps[constrs->rules_num];
^~~~~~~~
In file included from /home/andrew/linux/crypto/cbc.c:14:0:
/home/andrew/linux/include/crypto/cbc.h: In function âcrypto_cbc_decrypt_inplaceâ:
/home/andrew/linux/include/crypto/cbc.h:116:2: warning: ISO C90 forbids variable length array âlast_ivâ [-Wvla]
u8 last_iv[bsize];
^~
/home/andrew/linux/crypto/pcbc.c: In function âcrypto_pcbc_encrypt_inplaceâ:
/home/andrew/linux/crypto/pcbc.c:75:2: warning: ISO C90 forbids variable length array âtmpbufâ [-Wvla]
u8 tmpbuf[bsize];
^~
/home/andrew/linux/crypto/pcbc.c: In function âcrypto_pcbc_decrypt_inplaceâ:
/home/andrew/linux/crypto/pcbc.c:147:2: warning: ISO C90 forbids variable length array âtmpbufâ [-Wvla]
u8 tmpbuf[bsize] __aligned(__alignof__(u32));
^~
/home/andrew/linux/crypto/cts.c: In function âcts_cbc_encryptâ:
/home/andrew/linux/crypto/cts.c:107:2: warning: ISO C90 forbids variable length array âdâ [-Wvla]
u8 d[bsize * 2] __aligned(__alignof__(u32));
^~
/home/andrew/linux/crypto/cts.c: In function âcts_cbc_decryptâ:
/home/andrew/linux/crypto/cts.c:186:2: warning: ISO C90 forbids variable length array âdâ [-Wvla]
u8 d[bsize * 2] __aligned(__alignof__(u32));
^~
/home/andrew/linux/crypto/ctr.c: In function âcrypto_ctr_crypt_finalâ:
/home/andrew/linux/crypto/ctr.c:61:2: warning: ISO C90 forbids variable length array âtmpâ [-Wvla]
u8 tmp[bsize + alignmask];
^~
/home/andrew/linux/crypto/ctr.c: In function âcrypto_ctr_crypt_inplaceâ:
/home/andrew/linux/crypto/ctr.c:109:2: warning: ISO C90 forbids variable length array âtmpâ [-Wvla]
u8 tmp[bsize + alignmask];