crypto: nx - fix concurrency issue
The NX driver uses the transformation context to store several fields containing data related to the state of the operations in progress. Since a single tfm can be used by different kernel threads at the same time, we need to protect the data stored into the context. This patch makes use of spin locks to protect the data where a race condition can happen. Reviewed-by: Fionnuala Gunter <fin@linux.vnet.ibm.com> Reviewed-by: Joy Latten <jmlatten@linux.vnet.ibm.com> Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:

committed by
Herbert Xu

parent
f22d08111a
commit
c849163b80
@@ -61,8 +61,7 @@ int nx_hcall_sync(struct nx_crypto_ctx *nx_ctx,
|
||||
|
||||
do {
|
||||
rc = vio_h_cop_sync(viodev, op);
|
||||
} while ((rc == -EBUSY && !may_sleep && retries--) ||
|
||||
(rc == -EBUSY && may_sleep && cond_resched()));
|
||||
} while (rc == -EBUSY && !may_sleep && retries--);
|
||||
|
||||
if (rc) {
|
||||
dev_dbg(&viodev->dev, "vio_h_cop_sync failed: rc: %d "
|
||||
@@ -251,6 +250,7 @@ int nx_build_sg_lists(struct nx_crypto_ctx *nx_ctx,
|
||||
*/
|
||||
void nx_ctx_init(struct nx_crypto_ctx *nx_ctx, unsigned int function)
|
||||
{
|
||||
spin_lock_init(&nx_ctx->lock);
|
||||
memset(nx_ctx->kmem, 0, nx_ctx->kmem_len);
|
||||
nx_ctx->csbcpb->csb.valid |= NX_CSB_VALID_BIT;
|
||||
|
||||
|
Reference in New Issue
Block a user