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: <5614461b-02ae-5cb5-cca8-0525ffaacc13@roeck-us.net>
Date:   Sat, 29 Aug 2020 08:08:02 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Herbert Xu <herbert@...dor.apana.org.au>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Joerg Roedel <joerg.roedel@....com>,
        Luc Van Oostenryck <luc.vanoostenryck@...il.com>,
        Wen He <wen.he_1@....com>, Peng Ma <peng.ma@....com>,
        Vinod Koul <vkoul@...nel.org>
Subject: Re: [PATCH] dmaengine: fsldma: Do not pass pointers to lower_32_bits

On 8/29/20 5:45 AM, Herbert Xu wrote:
> On Sat, Aug 29, 2020 at 03:51:16AM -0700, Guenter Roeck wrote:
>>
>> This patch results in the following compile error when compiling 
>> ppc:mpc85xx_defconfig.
>>
>> Error log:
>> In file included from ./include/linux/list.h:9,
>>                  from ./include/linux/module.h:12,
>>                  from drivers/dma/fsldma.c:23:
>> drivers/dma/fsldma.h: In function 'fsl_ioread64':
>> ./include/linux/kernel.h:189:37: error: invalid operands to binary & (have 'const u64 *' {aka 'const long long unsigned int *'} and 'unsigned int')
>>   189 | #define lower_32_bits(n) ((u32)((n) & 0xffffffff))
>>       |                                     ^
>> drivers/dma/fsldma.h:208:17: note: in expansion of macro 'lower_32_bits'
>>   208 |  u32 fsl_addr = lower_32_bits(addr);
>>       |                 ^~~~~~~~~~~~~
>> drivers/dma/fsldma.h: In function 'fsl_ioread64be':
>> ./include/linux/kernel.h:189:37: error: invalid operands to binary & (have 'const u64 *' {aka 'const long long unsigned int *'} and 'unsigned int')
>>   189 | #define lower_32_bits(n) ((u32)((n) & 0xffffffff))
>>       |                                     ^
>> drivers/dma/fsldma.h:222:17: note: in expansion of macro 'lower_32_bits'
>>   222 |  u32 fsl_addr = lower_32_bits(addr);
>>       |                 ^~~~~~~~~~~~~
>> make[2]: *** [drivers/dma/fsldma.o] Error 1
> 
> Thanks for the report.  Passing a pointer to lower_32_bits is just
> bad.
> 
> ---8<---
> The functions fsl_ioread64* were passing a pointer to lower_32_bits
> which just happened to work because it was a macro that simply did
> a cast on the argument.
> 
> However, now that lower_32_bits does a mask on the argument it no
> longer works.  Passing a pointer to lower_32_bits doesn't look
> right anyway.
> 
> This patch adds explicit casts so that an integer is passed along
> as the argument to lower_32_bits.
> 
> Reported-by: Guenter Roeck <linux@...ck-us.net>
> Signed-off-by: Herbert Xu <herbert@...dor.apana.org.au>

Works as well as the other patch.

Tested-by: Guenter Roeck <linux@...ck-us.net>

Guenter

> 
> diff --git a/drivers/dma/fsldma.h b/drivers/dma/fsldma.h
> index 56f18ae99233..da5816b1706e 100644
> --- a/drivers/dma/fsldma.h
> +++ b/drivers/dma/fsldma.h
> @@ -205,7 +205,7 @@ struct fsldma_chan {
>  #else
>  static u64 fsl_ioread64(const u64 __iomem *addr)
>  {
> -	u32 fsl_addr = lower_32_bits(addr);
> +	u32 fsl_addr = lower_32_bits((unsigned long)addr);
>  	u64 fsl_addr_hi = (u64)in_le32((u32 *)(fsl_addr + 1)) << 32;
>  
>  	return fsl_addr_hi | in_le32((u32 *)fsl_addr);
> @@ -219,7 +219,7 @@ static void fsl_iowrite64(u64 val, u64 __iomem *addr)
>  
>  static u64 fsl_ioread64be(const u64 __iomem *addr)
>  {
> -	u32 fsl_addr = lower_32_bits(addr);
> +	u32 fsl_addr = lower_32_bits((unsigned long)addr);
>  	u64 fsl_addr_hi = (u64)in_be32((u32 *)fsl_addr) << 32;
>  
>  	return fsl_addr_hi | in_be32((u32 *)(fsl_addr + 1));
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ