aboutsummaryrefslogtreecommitdiff
path: root/drivers/crypto/amlogic/amlogic-gxl-cipher.c
AgeCommit message (Collapse)AuthorFilesLines
2020-09-04crypto: amlogic - Fix endianness markerHerbert Xu1-1/+1
The endianness marking on the variable v in meson_cipher is wrong. It is actually in CPU-order, not little-endian. This patch fixes it. Fixes: 3d04158814e7 ("crypto: amlogic - enable working on big...") Signed-off-by: Herbert Xu <[email protected]> Acked-by: Corentin Labbe <[email protected]> Tested-by: Corentin Labbe <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-09-04crypto: amlogic - use kfree_sensitive()Denis Efremov1-8/+2
Use kfree_sensitive() instead of open-coding it. Signed-off-by: Denis Efremov <[email protected]> Tested-by: Corentin Labbe <[email protected]> Acked-by: Corentin Labbe <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-08-07mm, treewide: rename kzfree() to kfree_sensitive()Waiman Long1-2/+2
As said by Linus: A symmetric naming is only helpful if it implies symmetries in use. Otherwise it's actively misleading. In "kzalloc()", the z is meaningful and an important part of what the caller wants. In "kzfree()", the z is actively detrimental, because maybe in the future we really _might_ want to use that "memfill(0xdeadbeef)" or something. The "zero" part of the interface isn't even _relevant_. The main reason that kzfree() exists is to clear sensitive information that should not be leaked to other future users of the same memory objects. Rename kzfree() to kfree_sensitive() to follow the example of the recently added kvfree_sensitive() and make the intention of the API more explicit. In addition, memzero_explicit() is used to clear the memory to make sure that it won't get optimized away by the compiler. The renaming is done by using the command sequence: git grep -w --name-only kzfree |\ xargs sed -i 's/kzfree/kfree_sensitive/' followed by some editing of the kfree_sensitive() kerneldoc and adding a kzfree backward compatibility macro in slab.h. [[email protected]: fs/crypto/inline_crypt.c needs linux/slab.h] [[email protected]: fix fs/crypto/inline_crypt.c some more] Suggested-by: Joe Perches <[email protected]> Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: David Howells <[email protected]> Acked-by: Michal Hocko <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: Jarkko Sakkinen <[email protected]> Cc: James Morris <[email protected]> Cc: "Serge E. Hallyn" <[email protected]> Cc: Joe Perches <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: David Rientjes <[email protected]> Cc: Dan Carpenter <[email protected]> Cc: "Jason A . Donenfeld" <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
2020-07-16crypto: amlogic-gxl - permit async skcipher as fallbackArd Biesheuvel1-14/+13
Even though the amlogic-gxl driver implements asynchronous versions of ecb(aes) and cbc(aes), the fallbacks it allocates are required to be synchronous. Given that SIMD based software implementations are usually asynchronous as well, even though they rarely complete asynchronously (this typically only happens in cases where the request was made from softirq context, while SIMD was already in use in the task context that it interrupted), these implementations are disregarded, and either the generic C version or another table based version implemented in assembler is selected instead. Since falling back to synchronous AES is not only a performance issue, but potentially a security issue as well (due to the fact that table based AES is not time invariant), let's fix this, by allocating an ordinary skcipher as the fallback, and invoke it with the completion routine that was given to the outer request. Signed-off-by: Ard Biesheuvel <[email protected]> Tested-by: Corentin Labbe <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2020-01-09crypto: remove CRYPTO_TFM_RES_BAD_KEY_LENEric Biggers1-1/+0
The CRYPTO_TFM_RES_BAD_KEY_LEN flag was apparently meant as a way to make the ->setkey() functions provide more information about errors. However, no one actually checks for this flag, which makes it pointless. Also, many algorithms fail to set this flag when given a bad length key. Reviewing just the generic implementations, this is the case for aes-fixed-time, cbcmac, echainiv, nhpoly1305, pcrypt, rfc3686, rfc4309, rfc7539, rfc7539esp, salsa20, seqiv, and xcbc. But there are probably many more in arch/*/crypto/ and drivers/crypto/. Some algorithms can even set this flag when the key is the correct length. For example, authenc and authencesn set it when the key payload is malformed in any way (not just a bad length), the atmel-sha and ccree drivers can set it if a memory allocation fails, and the chelsio driver sets it for bad auth tag lengths, not just bad key lengths. So even if someone actually wanted to start checking this flag (which seems unlikely, since it's been unused for a long time), there would be a lot of work needed to get it working correctly. But it would probably be much better to go back to the drawing board and just define different return values, like -EINVAL if the key is invalid for the algorithm vs. -EKEYREJECTED if the key was rejected by a policy like "no weak keys". That would be much simpler, less error-prone, and easier to test. So just remove this flag. Signed-off-by: Eric Biggers <[email protected]> Reviewed-by: Horia Geantă <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-11-22crypto: amlogic - enable working on big endian kernelCorentin Labbe1-13/+13
On big endian kernel, the GXL crypto driver does not works. This patch do the necessary modification to permit it to work on BE kernel (removing bitfield and adds some cpu_to_le32). Fixes: 48fe583fe541 ("crypto: amlogic - Add crypto accelerator for amlogic GXL") Signed-off-by: Corentin Labbe <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-11-17crypto: amlogic - fix two resources leakCorentin Labbe1-4/+6
This patch fixes two resources leak that occur on error path. Reported-by: coverity-bot <[email protected]> Addresses-Coverity-ID: 1487403 ("RESOURCE_LEAK") Addresses-Coverity-ID: 1487401 ("Resource leaks") Fixes: 48fe583fe541 ("crypto: amlogic - Add crypto accelerator for amlogic GXL") Signed-off-by: Corentin Labbe <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-11-08crypto: amlogic - Use kmemdup in meson_aes_setkey()YueHaibing1-2/+1
Use kmemdup rather than duplicating its implementation Signed-off-by: YueHaibing <[email protected]> Acked-by: Corentin Labbe <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
2019-10-26crypto: amlogic - Add crypto accelerator for amlogic GXLCorentin Labbe1-0/+381
This patch adds support for the amlogic GXL cryptographic offloader present on GXL SoCs. This driver supports AES cipher in CBC/ECB mode. Signed-off-by: Corentin Labbe <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Herbert Xu <[email protected]>