summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2025-04-16crypto: hash - Add HASH_REQUEST_ON_STACKHerbert Xu
Allow any ahash to be used with a stack request, with optional dynamic allocation when async is needed. The intended usage is: HASH_REQUEST_ON_STACK(req, tfm); ... err = crypto_ahash_digest(req); /* The request cannot complete synchronously. */ if (err == -EAGAIN) { /* This will not fail. */ req = HASH_REQUEST_CLONE(req, gfp); /* Redo operation. */ err = crypto_ahash_digest(req); } Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: shash - Remove dynamic descsizeHerbert Xu
As all users of the dynamic descsize have been converted to use a static one instead, remove support for dynamic descsize. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: hmac - Make descsize an algorithm attributeHerbert Xu
Rather than setting descsize in init_tfm, make it an algorithm attribute and set it during instance construction. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: zynqmp-sha - Make descsize an algorithm attributeHerbert Xu
Rather than setting descsize in init_tfm, set it statically and double-check it in init_tfm. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: padlock-sha - Make descsize an algorithm attributeHerbert Xu
Rather than setting descsize in init_tfm, set it statically and double-check it in init_tfm. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: api - Add support for duplicating algorithms before registrationHerbert Xu
If the bit CRYPTO_ALG_DUP_FIRST is set, an algorithm will be duplicated by kmemdup before registration. This is inteded for hardware-based algorithms that may be unplugged at will. Do not use this if the algorithm data structure is embedded in a bigger data structure. Perform the duplication in the driver instead. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: skcipher - Realign struct skcipher_walk to save 8 bytesThorsten Blum
Reduce skcipher_walk's struct size by 8 bytes by realigning its members. pahole output before: /* size: 120, cachelines: 2, members: 13 */ /* sum members: 108, holes: 2, sum holes: 8 */ /* padding: 4 */ /* last cacheline: 56 bytes */ and after: /* size: 112, cachelines: 2, members: 13 */ /* padding: 4 */ /* last cacheline: 48 bytes */ No functional changes intended. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: simd - Include asm/simd.h in internal/simd.hHerbert Xu
Now that the asm/simd.h files have been made safe against double inclusion, include it directly in internal/simd.h. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16x86: Make simd.h more resilientHerbert Xu
Add missing header inclusions and protect against double inclusion. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16arm: Make simd.h more resilientHerbert Xu
Add missing header inclusions and protect against double inclusion. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16asm-generic: Make simd.h more resilientHerbert Xu
Add missing header inclusions and protect against double inclusion. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: powerpc - Include uaccess.h and othersHerbert Xu
The powerpc aes/ghash code was relying on pagefault_disable from being pulled in by random header files. Fix this by explicitly including uaccess.h. Also add other missing header files to prevent similar problems in future. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16fs: ensure that *path_locked*() helpers leave passed path pristineChristian Brauner
The functions currently leaving dangling pointers in the passed-in path leading to hard to debug bugs in the long run. Ensure that the path is left in pristine state just like we do in e.g., path_parentat() and other helpers. Link: https://lore.kernel.org/20250414-rennt-wimmeln-f186c3a780f1@brauner Signed-off-by: Christian Brauner <brauner@kernel.org>
2025-04-16hwrng: npcm - Add struct device pointer to device context structSakari Ailus
Add a struct device pointer field to the device's context struct. This makes using the unsigned long priv pointer in struct hwrng unnecessary, so remove that one as well. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16hwrng: mtk - Add struct device pointer to device context structSakari Ailus
Add a struct device pointer field to the device's context struct. This makes using the unsigned long priv pointer in struct hwrng unnecessary, so remove that one as well. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16hwrng: atmel - Add struct device pointer to device context structSakari Ailus
Add a struct device pointer field to the device's context struct. This makes using the unsigned long priv pointer in struct hwrng unnecessary, so remove that one as well. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: ccp - Fix __sev_snp_shutdown_lockedAshish Kalra
Fix smatch warning: drivers/crypto/ccp/sev-dev.c:1755 __sev_snp_shutdown_locked() error: uninitialized symbol 'dfflush_error'. Fixes: 9770b428b1a2 ("crypto: ccp - Move dev_info/err messages for SEV/SNP init and shutdown") Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/linux-crypto/d9c2e79c-e26e-47b7-8243-ff6e7b101ec3@stanley.mountain/ Signed-off-by: Ashish Kalra <ashish.kalra@amd.com> Acked-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: api - Allow delayed algorithm destructionHerbert Xu
The current algorithm unregistration mechanism originated from software crypto. The code relies on module reference counts to stop in-use algorithms from being unregistered. Therefore if the unregistration function is reached, it is assumed that the module reference count has hit zero and thus the algorithm reference count should be exactly 1. This is completely broken for hardware devices, which can be unplugged at random. Fix this by allowing algorithms to be destroyed later if a destroy callback is provided. Reported-by: Sean Anderson <sean.anderson@linux.dev> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: essiv - Remove unnecessary strscpy() size argumentThorsten Blum
If the destination buffer has a fixed length, strscpy() automatically determines its size using sizeof() when the argument is omitted. This makes the explicit size argument unnecessary - remove it. No functional changes intended. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: ecdsa - Fix NIST P521 key size reported by KEYCTL_PKEY_QUERYLukas Wunner
When user space issues a KEYCTL_PKEY_QUERY system call for a NIST P521 key, the key_size is incorrectly reported as 528 bits instead of 521. That's because the key size obtained through crypto_sig_keysize() is in bytes and software_key_query() multiplies by 8 to yield the size in bits. The underlying assumption is that the key size is always a multiple of 8. With the recent addition of NIST P521, that's no longer the case. Fix by returning the key_size in bits from crypto_sig_keysize() and adjusting the calculations in software_key_query(). The ->key_size() callbacks of sig_alg algorithms now return the size in bits, whereas the ->digest_size() and ->max_size() callbacks return the size in bytes. This matches with the units in struct keyctl_pkey_query. Fixes: a7d45ba77d3d ("crypto: ecdsa - Register NIST P521 and extend test suite") Signed-off-by: Lukas Wunner <lukas@wunner.de> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Ignat Korchagin <ignat@cloudflare.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: ecdsa - Fix enc/dec size reported by KEYCTL_PKEY_QUERYLukas Wunner
KEYCTL_PKEY_QUERY system calls for ecdsa keys return the key size as max_enc_size and max_dec_size, even though such keys cannot be used for encryption/decryption. They're exclusively for signature generation or verification. Only rsa keys with pkcs1 encoding can also be used for encryption or decryption. Return 0 instead for ecdsa keys (as well as ecrdsa keys). Signed-off-by: Lukas Wunner <lukas@wunner.de> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Ignat Korchagin <ignat@cloudflare.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: caam - Add support for i.MX8QMThomas Richard
On i.MX8QM, caam clocks are turned on automatically and Linux does not have access to the caam controller's register page, so skip clocks initialization. Signed-off-by: Thomas Richard <thomas.richard@bootlin.com> Reviewed-by: Gaurav Jain <gaurav.jain@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: tegra - use API helpers to setup fallback requestOvidiu Panait
Rather than setting up the fallback request by hand, use ahash_request_set_callback() and ahash_request_set_crypt() API helpers to properly setup the new request. Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: rk3288 - use API helpers to setup fallback requestOvidiu Panait
Rather than setting up the fallback request by hand, use ahash_request_set_callback() and ahash_request_set_crypt() API helpers to properly setup the new request. This also ensures that the completion callback is properly passed down to the fallback algorithm, which avoids a crash with async fallbacks. Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: img-hash - use API helpers to setup fallback requestOvidiu Panait
Rather than setting up the fallback request by hand, use ahash_request_set_callback() and ahash_request_set_crypt() API helpers to properly setup the new request. This also ensures that the completion callback is properly passed down to the fallback algorithm, which avoids a crash with async fallbacks. Signed-off-by: Ovidiu Panait <ovidiu.panait.oss@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: ahash - Use cra_reqsizeHerbert Xu
Use the common reqsize field and remove reqsize from ahash_alg. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: acomp - Remove reqsize fieldHerbert Xu
Remove the type-specific reqsize field in favour of the common one. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: iaa - Use cra_reqsize for acompHerbert Xu
Use the common reqsize field for acomp algorithms. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: qat - Use cra_reqsize for acompHerbert Xu
Use the common reqsize field for acomp algorithms. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: acomp - Use cra_reqsizeHerbert Xu
Use the common reqsize if present. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: api - Add reqsize to crypto_algHerbert Xu
Add a reqsize field to crypto_alg with the intention of replacing the type-specific reqsize field currently used by ahash and acomp. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: api - Mark cra_init/cra_exit as deprecatedHerbert Xu
These functions have been obsoleted by the type-specific init/exit functions. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: atmel - add CRYPTO_ALG_KERN_DRIVER_ONLY flagZixun LI
This patch introduces the CRYPTO_ALG_KERN_DRIVER_ONLY flag to the atmel-aes, atmel-sha, and atmel-tdes drivers. This flag is set for hardware accelerated ciphers accessible through a kernel driver only, which is the case of these drivers. Signed-off-by: Zixun LI <admin@hifiphile.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: ctr - Remove unnecessary header inclusionsHerbert Xu
Now that the broken drivers have been fixed, remove the unnecessary inclusions from crypto/ctr.h. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: s5p-sss - Add missing header inclusionsHerbert Xu
The gutting of crypto/ctr.h uncovered missing header inclusions. Add them. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: ccp - Add missing header inclusionsHerbert Xu
The gutting of crypto/ctr.h uncovered missing header inclusions. Add them. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: nx - Add missing header inclusionsHerbert Xu
The gutting of crypto/ctr.h uncovered missing header inclusions. Add them. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: acomp - Simplify folio handlingHerbert Xu
Rather than storing the folio as is and handling it later, convert it to a scatterlist right away. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: acomp - Remove ACOMP_REQUEST_ALLOCHerbert Xu
Remove ACOMP_REQUEST_ALLOC in favour of ACOMP_REQUEST_ON_STACK with ACOMP_REQUEST_CLONE. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16ubifs: Use ACOMP_REQUEST_CLONEHerbert Xu
Switch to the new acomp API where stacks requests are used by default and a dynamic request is only allocted when necessary. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: acomp - Add ACOMP_REQUEST_CLONEHerbert Xu
Add a new helper ACOMP_REQUEST_CLONE that will transform a stack request into a dynamically allocated one if possible, and otherwise switch it over to the sycnrhonous fallback transform. The intended usage is: ACOMP_STACK_ON_REQUEST(req, tfm); ... err = crypto_acomp_compress(req); /* The request cannot complete synchronously. */ if (err == -EAGAIN) { /* This will not fail. */ req = ACOMP_REQUEST_CLONE(req, gfp); /* Redo operation. */ err = crypto_acomp_compress(req); } Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: iaa - Switch to ACOMP_FBREQ_ON_STACKHerbert Xu
Rather than copying the request by hand, use the ACOMP_FBREQ_ON_STACK helper to do it. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: acomp - Add ACOMP_FBREQ_ON_STACKHerbert Xu
Add a helper to create an on-stack fallback request from a given request. Use this helper in acomp_do_nondma. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: acomp - Use request flag helpers and add acomp_request_flagsHerbert Xu
Use the newly added request flag helpers to manage the request flags. Also add acomp_request_flags which lets bottom-level users to access the request flags without the bits private to the acomp API. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: api - Add helpers to manage request flagsHerbert Xu
Add helpers so that the ON_STACK request flag management is not duplicated all over the place. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: x509 - Replace kmalloc() + NUL-termination with kzalloc()Thorsten Blum
Use kzalloc() to zero out the one-element array instead of using kmalloc() followed by a manual NUL-termination. No functional changes intended. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: ahash - Remove request chainingHerbert Xu
Request chaining requires the user to do too much book keeping. Remove it from ahash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16Revert "crypto: tcrypt - Restore multibuffer ahash tests"Herbert Xu
This reverts commit c664f034172705a75f3f8a0c409b9bf95b633093. Remove the multibuffer ahash speed tests again. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: acomp - Remove request chainingHerbert Xu
Request chaining requires the user to do too much book keeping. Remove it from acomp. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2025-04-16crypto: deflate - Remove request chainingHerbert Xu
Remove request chaining support from deflate. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>