Skip to content

Commit 7bbe449

Browse files
hfreudeAlexander Gordeev
authored andcommitted
s390/paes: Reestablish retry loop in paes
With commit ed6776c ("s390/crypto: remove retry loop with sleep from PAES pkey invocation") the retry loop to retry derivation of a protected key from a secure key has been removed. This was based on the assumption that theses retries are not needed any more as proper retries are done in the zcrypt layer. However, tests have revealed that there exist some cases with master key change in the HSM and immediately (< 1 second) attempt to derive a protected key from a secure key with exact this HSM may eventually fail. The low level functions in zcrypt_ccamisc.c and zcrypt_ep11misc.c detect and report this temporary failure and report it to the caller as -EBUSY. The re-established retry loop in the paes implementation catches exactly this -EBUSY and eventually may run some retries. Fixes: ed6776c ("s390/crypto: remove retry loop with sleep from PAES pkey invocation") Signed-off-by: Harald Freudenberger <[email protected]> Reviewed-by: Ingo Franzki <[email protected]> Reviewed-by: Holger Dengler <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent da56583 commit 7bbe449

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

arch/s390/crypto/paes_s390.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,19 @@ struct s390_pxts_ctx {
125125
static inline int __paes_keyblob2pkey(struct key_blob *kb,
126126
struct pkey_protkey *pk)
127127
{
128-
return pkey_keyblob2pkey(kb->key, kb->keylen,
129-
pk->protkey, &pk->len, &pk->type);
128+
int i, ret = -EIO;
129+
130+
/* try three times in case of busy card */
131+
for (i = 0; ret && i < 3; i++) {
132+
if (ret == -EBUSY && in_task()) {
133+
if (msleep_interruptible(1000))
134+
return -EINTR;
135+
}
136+
ret = pkey_keyblob2pkey(kb->key, kb->keylen,
137+
pk->protkey, &pk->len, &pk->type);
138+
}
139+
140+
return ret;
130141
}
131142

132143
static inline int __paes_convert_key(struct s390_paes_ctx *ctx)

0 commit comments

Comments
 (0)