Commit 9814448d authored by Nicolas Iooss's avatar Nicolas Iooss Committed by James Morris

apparmor: use SHASH_DESC_ON_STACK

When building the kernel with clang, the compiler fails to build
security/apparmor/crypto.c with the following error:

    security/apparmor/crypto.c:36:8: error: fields must have a constant
    size: 'variable length array in structure' extension will never be
    supported
                    char ctx[crypto_shash_descsize(apparmor_tfm)];
                         ^

Since commit a0a77af1 ("crypto: LLVMLinux: Add macro to remove use
of VLAIS in crypto code"), include/crypto/hash.h defines
SHASH_DESC_ON_STACK to work around this issue. Use it in aa_calc_hash()
and aa_calc_profile_hash().
Signed-off-by: default avatarNicolas Iooss <nicolas.iooss_linux@m4x.org>
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
Signed-off-by: default avatarJames Morris <james.l.morris@oracle.com>
parent eea7a05f
...@@ -31,10 +31,7 @@ unsigned int aa_hash_size(void) ...@@ -31,10 +31,7 @@ unsigned int aa_hash_size(void)
char *aa_calc_hash(void *data, size_t len) char *aa_calc_hash(void *data, size_t len)
{ {
struct { SHASH_DESC_ON_STACK(desc, apparmor_tfm);
struct shash_desc shash;
char ctx[crypto_shash_descsize(apparmor_tfm)];
} desc;
char *hash = NULL; char *hash = NULL;
int error = -ENOMEM; int error = -ENOMEM;
...@@ -45,16 +42,16 @@ char *aa_calc_hash(void *data, size_t len) ...@@ -45,16 +42,16 @@ char *aa_calc_hash(void *data, size_t len)
if (!hash) if (!hash)
goto fail; goto fail;
desc.shash.tfm = apparmor_tfm; desc->tfm = apparmor_tfm;
desc.shash.flags = 0; desc->flags = 0;
error = crypto_shash_init(&desc.shash); error = crypto_shash_init(desc);
if (error) if (error)
goto fail; goto fail;
error = crypto_shash_update(&desc.shash, (u8 *) data, len); error = crypto_shash_update(desc, (u8 *) data, len);
if (error) if (error)
goto fail; goto fail;
error = crypto_shash_final(&desc.shash, hash); error = crypto_shash_final(desc, hash);
if (error) if (error)
goto fail; goto fail;
...@@ -69,10 +66,7 @@ char *aa_calc_hash(void *data, size_t len) ...@@ -69,10 +66,7 @@ char *aa_calc_hash(void *data, size_t len)
int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start, int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start,
size_t len) size_t len)
{ {
struct { SHASH_DESC_ON_STACK(desc, apparmor_tfm);
struct shash_desc shash;
char ctx[crypto_shash_descsize(apparmor_tfm)];
} desc;
int error = -ENOMEM; int error = -ENOMEM;
__le32 le32_version = cpu_to_le32(version); __le32 le32_version = cpu_to_le32(version);
...@@ -86,19 +80,19 @@ int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start, ...@@ -86,19 +80,19 @@ int aa_calc_profile_hash(struct aa_profile *profile, u32 version, void *start,
if (!profile->hash) if (!profile->hash)
goto fail; goto fail;
desc.shash.tfm = apparmor_tfm; desc->tfm = apparmor_tfm;
desc.shash.flags = 0; desc->flags = 0;
error = crypto_shash_init(&desc.shash); error = crypto_shash_init(desc);
if (error) if (error)
goto fail; goto fail;
error = crypto_shash_update(&desc.shash, (u8 *) &le32_version, 4); error = crypto_shash_update(desc, (u8 *) &le32_version, 4);
if (error) if (error)
goto fail; goto fail;
error = crypto_shash_update(&desc.shash, (u8 *) start, len); error = crypto_shash_update(desc, (u8 *) start, len);
if (error) if (error)
goto fail; goto fail;
error = crypto_shash_final(&desc.shash, profile->hash); error = crypto_shash_final(desc, profile->hash);
if (error) if (error)
goto fail; goto fail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment