aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinícius Tinti <viniciustinti@gmail.com>2014-04-04 18:18:00 -0300
committerSumit Semwal <sumit.semwal@linaro.org>2016-12-20 22:17:06 +0530
commitf73496e5494fc5aa55fc4a403c23b1e7b3370e49 (patch)
treed5cf72078d0f70ecd873c047cc9677a7e699e0e5
parent9dc14e61b27ad2c1e3fd2db2b75b24df44a9ade2 (diff)
apparmor: LLVMLinux: Remove VLAIS
Replaced the use of a Variable Length Array In Struct (VLAIS) with a C99 compliant equivalent. This patch instead allocates the appropriate amount of memory using a char array using the SHASH_DESC_ON_STACK macro. The new code can be compiled with both gcc and clang. Signed-off-by: Vinícius Tinti <viniciustinti@gmail.com> Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de> Reviewed-by: Mark Charlebois <charlebm@gmail.com> Signed-off-by: Behan Webster <behanw@converseincode.com> Acked-by: John Johansen <john.johansen@canonical.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--security/apparmor/crypto.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/security/apparmor/crypto.c b/security/apparmor/crypto.c
index 532471d0b3a0..c948247e90c2 100644
--- a/security/apparmor/crypto.c
+++ b/security/apparmor/crypto.c
@@ -32,10 +32,7 @@ unsigned int aa_hash_size(void)
int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start,
size_t len)
{
- struct {
- struct shash_desc shash;
- char ctx[crypto_shash_descsize(apparmor_tfm)];
- } desc;
+ SHASH_DESC_ON_STACK(shash, apparmor_tfm);
int error = -ENOMEM;
u32 le32_version = cpu_to_le32(version);
@@ -46,19 +43,19 @@ int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start,
if (!profile->hash)
goto fail;
- desc.shash.tfm = apparmor_tfm;
- desc.shash.flags = 0;
+ shash->tfm = apparmor_tfm;
+ shash->flags = 0;
- error = crypto_shash_init(&desc.shash);
+ error = crypto_shash_init(shash);
if (error)
goto fail;
- error = crypto_shash_update(&desc.shash, (u8 *) &le32_version, 4);
+ error = crypto_shash_update(shash, (u8 *) &le32_version, 4);
if (error)
goto fail;
- error = crypto_shash_update(&desc.shash, (u8 *) start, len);
+ error = crypto_shash_update(shash, (u8 *) start, len);
if (error)
goto fail;
- error = crypto_shash_final(&desc.shash, profile->hash);
+ error = crypto_shash_final(shash, profile->hash);
if (error)
goto fail;