]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
crypto: inside-secure - fix the invalidation step during cra_exit
authorAntoine Tenart <antoine.tenart@bootlin.com>
Tue, 13 Feb 2018 08:26:55 +0000 (09:26 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 22 Feb 2018 14:16:27 +0000 (22:16 +0800)
When exiting a transformation, the cra_exit() helper is called in each
driver providing one. The Inside Secure SafeXcel driver has one, which
is responsible of freeing some areas and of sending one invalidation
request to the crypto engine, to invalidate the context that was used
during the transformation.

We could see in some setups (when lots of transformations were being
used with a short lifetime, and hence lots of cra_exit() calls) NULL
pointer dereferences and other weird issues. All these issues were
coming from accessing the tfm context.

The issue is the invalidation request completion is checked using a
wait_for_completion_interruptible() call in both the cipher and hash
cra_exit() helpers. In some cases this was interrupted while the
invalidation request wasn't processed yet. And then cra_exit() returned,
and its caller was freeing the tfm instance. Only then the request was
being handled by the SafeXcel driver, which lead to the said issues.

This patch fixes this by using wait_for_completion() calls in these
specific cases.

Fixes: 1b44c5a60c13 ("crypto: inside-secure - add SafeXcel EIP197 crypto engine driver")
Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/inside-secure/safexcel_cipher.c
drivers/crypto/inside-secure/safexcel_hash.c

index 63a8768ed2ae7c2008c28af7b16978fca1f89984..17a7725a6f6dc14896b8928f5b5880a7d80470a4 100644 (file)
@@ -456,7 +456,7 @@ static int safexcel_cipher_exit_inv(struct crypto_tfm *tfm)
        queue_work(priv->ring[ring].workqueue,
                   &priv->ring[ring].work_data.work);
 
-       wait_for_completion_interruptible(&result.completion);
+       wait_for_completion(&result.completion);
 
        if (result.error) {
                dev_warn(priv->dev,
index 2951101e1831a63e11c558daed71e24cecca3843..43e94cd59c86619f8fde118d775d5ea8f6cf8540 100644 (file)
@@ -493,7 +493,7 @@ static int safexcel_ahash_exit_inv(struct crypto_tfm *tfm)
        queue_work(priv->ring[ring].workqueue,
                   &priv->ring[ring].work_data.work);
 
-       wait_for_completion_interruptible(&result.completion);
+       wait_for_completion(&result.completion);
 
        if (result.error) {
                dev_warn(priv->dev, "hash: completion error (%d)\n",