Commit 0e2d3a12 authored by Herbert Xu's avatar Herbert Xu

crypto: shash - Fix alignment in unaligned operations

When we encounter an unaligned pointer we are supposed to copy
it to a temporary aligned location.  However the temporary buffer
isn't aligned properly.  This patch fixes that.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 8c32c516
...@@ -76,8 +76,9 @@ static int shash_update_unaligned(struct shash_desc *desc, const u8 *data, ...@@ -76,8 +76,9 @@ static int shash_update_unaligned(struct shash_desc *desc, const u8 *data,
unsigned long alignmask = crypto_shash_alignmask(tfm); unsigned long alignmask = crypto_shash_alignmask(tfm);
unsigned int unaligned_len = alignmask + 1 - unsigned int unaligned_len = alignmask + 1 -
((unsigned long)data & alignmask); ((unsigned long)data & alignmask);
u8 buf[shash_align_buffer_size(unaligned_len, alignmask)] u8 ubuf[shash_align_buffer_size(unaligned_len, alignmask)]
__attribute__ ((aligned)); __attribute__ ((aligned));
u8 *buf = PTR_ALIGN(&ubuf[0], alignmask + 1);
int err; int err;
if (unaligned_len > len) if (unaligned_len > len)
...@@ -111,8 +112,9 @@ static int shash_final_unaligned(struct shash_desc *desc, u8 *out) ...@@ -111,8 +112,9 @@ static int shash_final_unaligned(struct shash_desc *desc, u8 *out)
unsigned long alignmask = crypto_shash_alignmask(tfm); unsigned long alignmask = crypto_shash_alignmask(tfm);
struct shash_alg *shash = crypto_shash_alg(tfm); struct shash_alg *shash = crypto_shash_alg(tfm);
unsigned int ds = crypto_shash_digestsize(tfm); unsigned int ds = crypto_shash_digestsize(tfm);
u8 buf[shash_align_buffer_size(ds, alignmask)] u8 ubuf[shash_align_buffer_size(ds, alignmask)]
__attribute__ ((aligned)); __attribute__ ((aligned));
u8 *buf = PTR_ALIGN(&ubuf[0], alignmask + 1);
int err; int err;
err = shash->final(desc, buf); err = shash->final(desc, buf);
......
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