crypto: caam - fix signals handling
authorHoria Geantă <horia.geanta@nxp.com>
Fri, 7 Jul 2017 13:57:06 +0000 (16:57 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 12 Jul 2017 10:38:04 +0000 (18:38 +0800)
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).

Cc: <stable@vger.kernel.org>
Fixes: 045e36780f115 ("crypto: caam - ahash hmac support")
Fixes: 4c1ec1f930154 ("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>
drivers/crypto/caam/caamhash.c
drivers/crypto/caam/key_gen.c

index 7c44c90ad59365d131322bd8799aff450b4027c9..910ec61cae0984a99c745d86a25ef1dcbddd3bac 100644 (file)
@@ -396,7 +396,7 @@ static int hash_digest_key(struct caam_hash_ctx *ctx, const u8 *key_in,
        ret = caam_jr_enqueue(jrdev, desc, split_key_done, &result);
        if (!ret) {
                /* in progress */
-               wait_for_completion_interruptible(&result.completion);
+               wait_for_completion(&result.completion);
                ret = result.err;
 #ifdef DEBUG
                print_hex_dump(KERN_ERR,
index 1bb2816a9b4d992330a7d18ce31e475700a27afe..c425d4adaf2af69a85ea830a78f41238c980720d 100644 (file)
@@ -149,7 +149,7 @@ int gen_split_key(struct device *jrdev, u8 *key_out,
        ret = caam_jr_enqueue(jrdev, desc, split_key_done, &result);
        if (!ret) {
                /* in progress */
-               wait_for_completion_interruptible(&result.completion);
+               wait_for_completion(&result.completion);
                ret = result.err;
 #ifdef DEBUG
                print_hex_dump(KERN_ERR, "ctx.key@"__stringify(__LINE__)": ",