Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: x86/ghash - fix unaligned access in ghash_setkey()

The key can be unaligned, so use the unaligned memory access helpers.

Fixes: 8ceee72808d1 ("crypto: ghash-clmulni-intel - use C implementation for setkey()")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Eric Biggers and committed by
Herbert Xu
116db270 736f8868

+3 -3
+3 -3
arch/x86/crypto/ghash-clmulni-intel_glue.c
··· 19 19 #include <crypto/internal/simd.h> 20 20 #include <asm/cpu_device_id.h> 21 21 #include <asm/simd.h> 22 + #include <asm/unaligned.h> 22 23 23 24 #define GHASH_BLOCK_SIZE 16 24 25 #define GHASH_DIGEST_SIZE 16 ··· 55 54 const u8 *key, unsigned int keylen) 56 55 { 57 56 struct ghash_ctx *ctx = crypto_shash_ctx(tfm); 58 - be128 *x = (be128 *)key; 59 57 u64 a, b; 60 58 61 59 if (keylen != GHASH_BLOCK_SIZE) 62 60 return -EINVAL; 63 61 64 62 /* perform multiplication by 'x' in GF(2^128) */ 65 - a = be64_to_cpu(x->a); 66 - b = be64_to_cpu(x->b); 63 + a = get_unaligned_be64(key); 64 + b = get_unaligned_be64(key + 8); 67 65 68 66 ctx->shash.a = (b << 1) | (a >> 63); 69 67 ctx->shash.b = (a << 1) | (b >> 63);