lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 11 Feb 2020 12:25:49 +0000
From:   Horia Geanta <horia.geanta@....com>
To:     Iuliana Prodan <iuliana.prodan@....com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        Aymen Sghaier <aymen.sghaier@....com>
CC:     "David S. Miller" <davem@...emloft.net>,
        Silvano Di Ninno <silvano.dininno@....com>,
        Franck Lenormand <franck.lenormand@....com>,
        "linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        dl-linux-imx <linux-imx@....com>
Subject: Re: [PATCH v5 9/9] crypto: caam - add crypto_engine support for HASH
 algorithms

On 1/30/2020 2:49 AM, Iuliana Prodan wrote:
> @@ -123,6 +128,9 @@ struct caam_export_state {
>  	int (*update)(struct ahash_request *req);
>  	int (*final)(struct ahash_request *req);
>  	int (*finup)(struct ahash_request *req);
> +	struct ahash_edesc *edesc;
> +	void (*ahash_op_done)(struct device *jrdev, u32 *desc, u32 err,
> +			      void *context);
These members are used internally by the driver,
during ahash request processing.
They are recomputed each time a new request is received.

This means .import/.export callbacks don't have to deal with them.

>  /* submit ahash update if it the first job descriptor after update */
> @@ -1209,9 +1280,8 @@ static int ahash_update_no_ctx(struct ahash_request *req)
>  				     DUMP_PREFIX_ADDRESS, 16, 4, desc,
>  				     desc_bytes(desc), 1);
>  
> -		ret = caam_jr_enqueue(jrdev, desc, ahash_done_ctx_dst, req);
> -		if (ret != -EINPROGRESS)
> -			goto unmap_ctx;
> +		ret = ahash_enqueue_req(jrdev, ahash_done_ctx_dst, req,
> +					ctx->ctx_len, DMA_TO_DEVICE);
In case ahash_enqueue_req() fails, driver's callbacks state machine
changes since the code falls through.

>  
>  		state->update = ahash_update_ctx;
>  		state->finup = ahash_finup_ctx;

> @@ -1394,9 +1459,8 @@ static int ahash_update_first(struct ahash_request *req)
>  				     DUMP_PREFIX_ADDRESS, 16, 4, desc,
>  				     desc_bytes(desc), 1);
>  
> -		ret = caam_jr_enqueue(jrdev, desc, ahash_done_ctx_dst, req);
> -		if (ret != -EINPROGRESS)
> -			goto unmap_ctx;
> +		ret = ahash_enqueue_req(jrdev, ahash_done_ctx_dst, req,
> +					ctx->ctx_len, DMA_TO_DEVICE);
Same here.

>  
>  		state->update = ahash_update_ctx;
>  		state->finup = ahash_finup_ctx;

> @@ -1752,7 +1820,9 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
>  	}
>  
>  	dma_addr = dma_map_single_attrs(ctx->jrdev, ctx->sh_desc_update,
> -					offsetof(struct caam_hash_ctx, key),
> +					offsetof(struct caam_hash_ctx, key) -
> +					offsetof(struct caam_hash_ctx,
> +						 sh_desc_update),
>  					ctx->dir, DMA_ATTR_SKIP_CPU_SYNC);
>  	if (dma_mapping_error(ctx->jrdev, dma_addr)) {
>  		dev_err(ctx->jrdev, "unable to map shared descriptors\n");
> @@ -1770,11 +1840,19 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
>  	ctx->sh_desc_update_dma = dma_addr;
>  	ctx->sh_desc_update_first_dma = dma_addr +
>  					offsetof(struct caam_hash_ctx,
> -						 sh_desc_update_first);
> +						 sh_desc_update_first) -
> +					offsetof(struct caam_hash_ctx,
> +						 sh_desc_update);
>  	ctx->sh_desc_fin_dma = dma_addr + offsetof(struct caam_hash_ctx,
> -						   sh_desc_fin);
> +						   sh_desc_fin) -
> +					  offsetof(struct caam_hash_ctx,
> +						   sh_desc_update);
>  	ctx->sh_desc_digest_dma = dma_addr + offsetof(struct caam_hash_ctx,
> -						      sh_desc_digest);
> +						      sh_desc_digest) -
> +					     offsetof(struct caam_hash_ctx,
> +						      sh_desc_update);
offsetof(struct caam_hash_ctx, sh_desc_update) is used several times,
it deserves a local variable.

Horia

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ