crypto: crypto_xor - use helpers for unaligned accesses
authorArd Biesheuvel <ardb@kernel.org>
Wed, 23 Feb 2022 07:07:01 +0000 (08:07 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 2 Mar 2022 22:49:20 +0000 (10:49 +1200)
commit7976c1492571a5fb234c416559a0d9790855c635
tree34d455af015e3256902f25da54e17bb52c5aeed5
parent4920a4a7262dd1c647b515c05358ccbee0ab828c
crypto: crypto_xor - use helpers for unaligned accesses

Dereferencing a misaligned pointer is undefined behavior in C, and may
result in codegen on architectures such as ARM that trigger alignments
traps and expensive fixups in software.

Instead, use the get_aligned()/put_aligned() accessors, which are cheap
or even completely free when CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y.

In the converse case, the prior alignment checks ensure that the casts
are safe, and so no unaligned accessors are necessary.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/algapi.c
include/crypto/algapi.h