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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdkB0BViLgVyWBQZw4jZgFjp-3m2ndjiJmutsbevYjy7nA@mail.gmail.com>
Date:   Tue, 11 Dec 2018 15:40:04 -0800
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Nathan Chancellor <natechancellor@...il.com>
Cc:     Herbert Xu <herbert@...dor.apana.org.au>,
        linux-crypto@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] crypto: ux500 - Use proper enum in cryp_set_dma_transfer

On Mon, Dec 10, 2018 at 3:49 PM Nathan Chancellor
<natechancellor@...il.com> wrote:
>
> Clang warns when one enumerated type is implicitly converted to another:
>
> drivers/crypto/ux500/cryp/cryp_core.c:559:5: warning: implicit
> conversion from enumeration type 'enum dma_data_direction' to different
> enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
>                                 direction, DMA_CTRL_ACK);
>                                 ^~~~~~~~~
> drivers/crypto/ux500/cryp/cryp_core.c:583:5: warning: implicit
> conversion from enumeration type 'enum dma_data_direction' to different
> enumeration type 'enum dma_transfer_direction' [-Wenum-conversion]
>                                 direction,
>                                 ^~~~~~~~~
> 2 warnings generated.
>
> dmaengine_prep_slave_sg expects an enum from dma_transfer_direction.
> Because we know the value of the dma_data_direction enum from the
> switch statement, we can just use the proper value from
> dma_transfer_direction so there is no more conversion.
>
> DMA_TO_DEVICE = DMA_MEM_TO_DEV = 1
> DMA_FROM_DEVICE = DMA_DEV_TO_MEM = 2
>
> Signed-off-by: Nathan Chancellor <natechancellor@...il.com>

Deja vu!
These particular enums get mixed up ALL THE TIME. Thanks for fixing
probably every instance of this bug (via patches before this one).
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>

> ---
>  drivers/crypto/ux500/cryp/cryp_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c
> index d2663a4e1f5e..a92a66b1ff46 100644
> --- a/drivers/crypto/ux500/cryp/cryp_core.c
> +++ b/drivers/crypto/ux500/cryp/cryp_core.c
> @@ -556,7 +556,7 @@ static int cryp_set_dma_transfer(struct cryp_ctx *ctx,
>                 desc = dmaengine_prep_slave_sg(channel,
>                                 ctx->device->dma.sg_src,
>                                 ctx->device->dma.sg_src_len,
> -                               direction, DMA_CTRL_ACK);
> +                               DMA_MEM_TO_DEV, DMA_CTRL_ACK);
>                 break;
>
>         case DMA_FROM_DEVICE:
> @@ -580,7 +580,7 @@ static int cryp_set_dma_transfer(struct cryp_ctx *ctx,
>                 desc = dmaengine_prep_slave_sg(channel,
>                                 ctx->device->dma.sg_dst,
>                                 ctx->device->dma.sg_dst_len,
> -                               direction,
> +                               DMA_DEV_TO_MEM,
>                                 DMA_CTRL_ACK |
>                                 DMA_PREP_INTERRUPT);
>
> --
> 2.20.0
>


-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ