Re: [PATCH] crypto: qat - Don't attempt to register algorithm multiple times

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 20, 2015 at 06:45:38PM -0700, Tadeusz Struk wrote:
> When multiple devices are present in the system the driver attempts
> to register the same algorithm many times.
> 
> Signed-off-by: Tadeusz Struk <tadeusz.struk@xxxxxxxxx>
> ---
>  drivers/crypto/qat/qat_common/qat_asym_algs.c |   13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto/qat/qat_common/qat_asym_algs.c
> index 557a740..3e3c5c8 100644
> --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
> +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
> @@ -58,6 +58,8 @@
>  #include "adf_common_drv.h"
>  #include "qat_crypto.h"
>  
> +static atomic_t active_devs;
> +
>  struct qat_rsa_input_params {
>  	union {
>  		struct {
> @@ -629,11 +631,16 @@ static struct akcipher_alg rsa = {
>  
>  int qat_asym_algs_register(void)
>  {
> -	rsa.base.cra_flags = 0;
> -	return crypto_register_akcipher(&rsa);
> +	if (atomic_add_return(1, &active_devs) == 1) {
> +		rsa.base.cra_flags = 0;
> +		return crypto_register_akcipher(&rsa);
> +	}
> +
> +	return 0;
>  }

This looks buggy.  Either this can be called in parallel in which
case the atomic is not enough because you're not synchronising
between the register and the unregister.  Or it cannot be called
in parallel in which case the atomic is redundant.

The same issue exists on the sym side as well.

Please clarify how this is supposed to be called and use the
correct synchronisation mechanism.

Thanks,
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux