]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit4c5823f587e167f6a42225750b1d0294e751cf49
tree34d455af015e3256902f25da54e17bb52c5aeed5
parente82ee36ebc8c0ed112ebd156c4a124ec91d7819a
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