On 2024-08-13 10:12, Herbert Xu wrote:
On Tue, Aug 13, 2024 at 09:37:24AM +0200, Harald Freudenberger wrote:
+static int hash(const u8 *in, unsigned int inlen,
+ u8 *digest, unsigned int digestsize)
+{
+ struct crypto_shash *htfm;
+ const char *alg_name;
+ int ret;
+
+ switch (digestsize) {
+ case SHA224_DIGEST_SIZE:
+ alg_name = "sha224";
+ break;
+ case SHA256_DIGEST_SIZE:
+ alg_name = "sha256";
+ break;
+ case SHA384_DIGEST_SIZE:
+ alg_name = "sha384";
+ break;
+ case SHA512_DIGEST_SIZE:
+ alg_name = "sha512";
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ htfm = crypto_alloc_shash(alg_name, 0, CRYPTO_ALG_NEED_FALLBACK);
+ if (IS_ERR(htfm))
+ return PTR_ERR(htfm);
+
+ ret = crypto_shash_tfm_digest(htfm, in, inlen, digest);
+ if (ret)
+ pr_err("shash digest error: %d\n", ret);
+
+ crypto_free_shash(htfm);
+ return ret;
+}
The setkey function can be called in softirq context. Therefore
calling crypto_alloc_* from it is not allowed. You could either
move the allocation to init_tfm and carry it throughout the life
of the tfm, or perhaps you could call the s390 underlying sha hash
function directly?
Cheers,
Ok, good catch. I'll discuss this with Holger when he is back from
vacation.
Thanks for your work.