Skip to content

Commit 4e3c118

Browse files
horiaggregkh
authored andcommitted
crypto: caam - fix signals handling
commit 7459e1d25ffefa2b1be799477fcc1f6c62f6cec7 upstream. Driver does not properly handle the case when signals interrupt wait_for_completion_interruptible(): -it does not check for return value -completion structure is allocated on stack; in case a signal interrupts the sleep, it will go out of scope, causing the worker thread (caam_jr_dequeue) to fail when it accesses it wait_for_completion_interruptible() is replaced with uninterruptable wait_for_completion(). We choose to block all signals while waiting for I/O (device executing the split key generation job descriptor) since the alternative - in order to have a deterministic device state - would be to flush the job ring (aborting *all* in-progress jobs). Fixes: 045e367 ("crypto: caam - ahash hmac support") Fixes: 4c1ec1f ("crypto: caam - refactor key_gen, sg") Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f1bf5d8 commit 4e3c118

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/crypto/caam/caamhash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static int hash_digest_key(struct caam_hash_ctx *ctx, const u8 *key_in,
498498
ret = caam_jr_enqueue(jrdev, desc, split_key_done, &result);
499499
if (!ret) {
500500
/* in progress */
501-
wait_for_completion_interruptible(&result.completion);
501+
wait_for_completion(&result.completion);
502502
ret = result.err;
503503
#ifdef DEBUG
504504
print_hex_dump(KERN_ERR,

drivers/crypto/caam/key_gen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int gen_split_key(struct device *jrdev, u8 *key_out, int split_key_len,
103103
ret = caam_jr_enqueue(jrdev, desc, split_key_done, &result);
104104
if (!ret) {
105105
/* in progress */
106-
wait_for_completion_interruptible(&result.completion);
106+
wait_for_completion(&result.completion);
107107
ret = result.err;
108108
#ifdef DEBUG
109109
print_hex_dump(KERN_ERR, "ctx.key@"__stringify(__LINE__)": ",

0 commit comments

Comments
 (0)