* [RFC] SHASH_DESC_ON_STACK macro
@ 2018-03-21 15:07 Gustavo A. R. Silva
2018-03-23 19:09 ` [RESEND] " Gustavo A. R. Silva
0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-03-21 15:07 UTC (permalink / raw)
To: Herbert Xu; +Cc: David S. Miller, linux-crypto, linux-kernel
Hi Herbert,
There is an ongoing effort to remove all VLAs from the code base [1] and
while working on that I came across the following macro at
include/crypto/hash.h:154:
#define SHASH_DESC_ON_STACK(shash, ctx) \
char __##shash##_desc[sizeof(struct shash_desc) + \
crypto_shash_descsize(ctx)] CRYPTO_MINALIGN_ATTR; \
struct shash_desc *shash = (struct shash_desc *)__##shash##_desc
Currently, this macro is being used in 46 different places.
I wonder how big can tfm->descsize can get?
Do you think it is feasible to replace the call to crypto_shash_descsize
with a constant value and get rid of 46 VLA warnings?
I have sent some patches to replace the use of this macro with dynamic
memory allocation instead, but it seems that this is not a suitable
solution for all cases due to performance issues.
[1] https://lkml.org/lkml/2018/3/7/621
I'd really appreciate any feedback.
Thanks
--
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RESEND] SHASH_DESC_ON_STACK macro
2018-03-21 15:07 [RFC] SHASH_DESC_ON_STACK macro Gustavo A. R. Silva
@ 2018-03-23 19:09 ` Gustavo A. R. Silva
2018-03-27 10:07 ` Herbert Xu
0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-03-23 19:09 UTC (permalink / raw)
To: Herbert Xu
Cc: David S. Miller, linux-crypto, linux-kernel, Gustavo A. R. Silva
Hi Herbert,
There is an ongoing effort to remove all VLAs from the code base [1] and
while working on that I came across the following macro at
include/crypto/hash.h:154:
#define SHASH_DESC_ON_STACK(shash, ctx) \
char __##shash##_desc[sizeof(struct shash_desc) + \
crypto_shash_descsize(ctx)] CRYPTO_MINALIGN_ATTR; \
struct shash_desc *shash = (struct shash_desc *)__##shash##_desc
Currently, this macro is being used in 46 different places.
I wonder how big can tfm->descsize can get?
Do you think it is feasible to replace the call to crypto_shash_descsize
with a constant value and get rid of 46 VLA warnings?
I have sent some patches to replace the use of this macro with dynamic
memory allocation instead, but it seems that this is not a suitable
solution for all cases due to performance issues.
[1] https://lkml.org/lkml/2018/3/7/621
I'd really appreciate any feedback.
Thanks
--
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RESEND] SHASH_DESC_ON_STACK macro
2018-03-23 19:09 ` [RESEND] " Gustavo A. R. Silva
@ 2018-03-27 10:07 ` Herbert Xu
2018-04-05 8:26 ` Gustavo A. R. Silva
0 siblings, 1 reply; 4+ messages in thread
From: Herbert Xu @ 2018-03-27 10:07 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: David S. Miller, linux-crypto, linux-kernel
On Fri, Mar 23, 2018 at 02:09:46PM -0500, Gustavo A. R. Silva wrote:
>
> Hi Herbert,
>
> There is an ongoing effort to remove all VLAs from the code base [1] and
> while working on that I came across the following macro at
> include/crypto/hash.h:154:
>
> #define SHASH_DESC_ON_STACK(shash, ctx) \
> char __##shash##_desc[sizeof(struct shash_desc) + \
> crypto_shash_descsize(ctx)] CRYPTO_MINALIGN_ATTR; \
> struct shash_desc *shash = (struct shash_desc *)__##shash##_desc
>
>
> Currently, this macro is being used in 46 different places.
>
> I wonder how big can tfm->descsize can get?
descsize is capped at PAGE_SIZE / 8.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RESEND] SHASH_DESC_ON_STACK macro
2018-03-27 10:07 ` Herbert Xu
@ 2018-04-05 8:26 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-04-05 8:26 UTC (permalink / raw)
To: Herbert Xu; +Cc: David S. Miller, linux-crypto, linux-kernel
Hi Herbert,
On 03/27/2018 05:07 AM, Herbert Xu wrote:
> On Fri, Mar 23, 2018 at 02:09:46PM -0500, Gustavo A. R. Silva wrote:
>>
>> Hi Herbert,
>>
>> There is an ongoing effort to remove all VLAs from the code base [1] and
>> while working on that I came across the following macro at
>> include/crypto/hash.h:154:
>>
>> #define SHASH_DESC_ON_STACK(shash, ctx) \
>> char __##shash##_desc[sizeof(struct shash_desc) + \
>> crypto_shash_descsize(ctx)] CRYPTO_MINALIGN_ATTR; \
>> struct shash_desc *shash = (struct shash_desc *)__##shash##_desc
>>
>>
>> Currently, this macro is being used in 46 different places.
>>
>> I wonder how big can tfm->descsize can get?
>
> descsize is capped at PAGE_SIZE / 8.
>
Sorry for the late response. It seems I lost track of this email somehow.
OK. So based on your response I will propose a patch for this.
Thanks!
--
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-04-05 8:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-21 15:07 [RFC] SHASH_DESC_ON_STACK macro Gustavo A. R. Silva
2018-03-23 19:09 ` [RESEND] " Gustavo A. R. Silva
2018-03-27 10:07 ` Herbert Xu
2018-04-05 8:26 ` Gustavo A. R. Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).