On 2024-11-25 07:09, Herbert Xu wrote:
On Fri, Nov 22, 2024 at 03:34:27PM +0100, Harald Freudenberger wrote:
+static inline int phmac_keyblob2pkey(const u8 *key, unsigned int
keylen,
+ struct phmac_protkey *pk)
+{
+ int i, rc = -EIO;
+
+ /* try three times in case of busy card */
+ for (i = 0; rc && i < 3; i++) {
+ if (rc == -EBUSY && msleep_interruptible(1000))
+ return -EINTR;
You can't sleep in crypto calls in general.
Now there are specific circumstances where sleeping is allowed,
e.g., when the MAY_SLEEP flag is set, but I don't think this will
be acceptable for your purpose.
I see the same problem exists in paes_s390, which was not reviewed
on linux-crypto.
So what exactly causes the EBUSY? The 3 retries followed by failure
seem rather dangerous too given that this could be used by the block
layer for critical data that cannot fail.
Cheers,
Well, I fear the paes implementation is similar broken. The EBUSY
is a reaction of the zcrpyt/AP bus when no eligible crypto card has
been found and a ansynchronous bus scan is running. In that case the
caller should retry in the hope that the bus scan detects a eligible
card.
Please note that the sleep only happens in in_task() context for the
paes implementation.
For the phmac implementation - didn't you suggest to wrap this with
an asynchronous hmac to be able to sleep in the wrapped synchronous
hmac?