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]
Message-ID: <20250321215838.179be239@pumpkin>
Date: Fri, 21 Mar 2025 21:58:38 +0000
From: David Laight <david.laight.linux@...il.com>
To: kernel test robot <lkp@...el.com>
Cc: Huang Ying <ying.huang@...el.com>, oe-kbuild-all@...ts.linux.dev,
 linux-kernel@...r.kernel.org, Andrew Morton <akpm@...ux-foundation.org>,
 Linux Memory Management List <linux-mm@...ck.org>
Subject: Re: include/linux/minmax.h:93:30: warning: large integer implicitly
 truncated to unsigned type

On Thu, 20 Mar 2025 12:16:57 +0800
kernel test robot <lkp@...el.com> wrote:

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   a7f2e10ecd8f18b83951b0bab47ddaf48f93bf47
> commit: 99185c10d5d9214d0d0c8b7866660203e344ee3b resource, kunit: add test case for region_intersects()
> date:   6 months ago
> config: arm-randconfig-r063-20250320 (https://download.01.org/0day-ci/archive/20250320/202503201231.VrUIFcq2-lkp@intel.com/config)
> compiler: arm-linux-gnueabi-gcc (GCC) 7.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250320/202503201231.VrUIFcq2-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@...el.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202503201231.VrUIFcq2-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>    In file included from include/linux/ioport.h:15:0,
>                     from kernel/resource.c:15:
>    kernel/resource.c: In function 'gfr_start':
> >> include/linux/minmax.h:93:30: warning: large integer implicitly truncated to unsigned type [-Woverflow]  
>      ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
>                                  ^
>    include/linux/minmax.h:96:2: note: in expansion of macro '__cmp_once_unique'
>      __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
>      ^~~~~~~~~~~~~~~~~
>    include/linux/minmax.h:213:27: note: in expansion of macro '__cmp_once'
>     #define min_t(type, x, y) __cmp_once(min, type, x, y)
>                               ^~~~~~~~~~
>    kernel/resource.c:1838:9: note: in expansion of macro 'min_t'
>       end = min_t(resource_size_t, base->end, MAX_PHYS_ADDR);


The error is because MAX_PHYS_ADDR is too large for resource_size_t.
The constant seems to have been changed several times.
But I don't see the patch that changes it from DIRECT_MAP_PHYSMEM_END to MAX_PHYS_ADDR.
I'd guess this is a 32bit build and resource_size_t is 32 bits but MAX_PHYS_ADDR is 64.

Who knows what the code is supposed to do, but it is another case of min_t()
discarding significant bits.

It might be that just using min() will fix the compilation and DTRT.

	David




>             ^~~~~
>    kernel/resource.c: In function 'gfr_continue':
> >> include/linux/minmax.h:93:30: warning: large integer implicitly truncated to unsigned type [-Woverflow]  
>      ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
>                                  ^
>    include/linux/minmax.h:96:2: note: in expansion of macro '__cmp_once_unique'
>      __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
>      ^~~~~~~~~~~~~~~~~
>    include/linux/minmax.h:213:27: note: in expansion of macro '__cmp_once'
>     #define min_t(type, x, y) __cmp_once(min, type, x, y)
>                               ^~~~~~~~~~
>    kernel/resource.c:1855:11: note: in expansion of macro 'min_t'
>       addr <= min_t(resource_size_t, base->end, MAX_PHYS_ADDR);
>               ^~~~~
> 
> 
> vim +93 include/linux/minmax.h
> 
> d03eba99f5bf7c David Laight   2023-09-18  91  
> 017fa3e8918784 Linus Torvalds 2024-07-28  92  #define __cmp_once_unique(op, type, x, y, ux, uy) \
> 017fa3e8918784 Linus Torvalds 2024-07-28 @93  	({ type ux = (x); type uy = (y); __cmp(op, ux, uy); })
> 017fa3e8918784 Linus Torvalds 2024-07-28  94  
> 
> :::::: The code at line 93 was first introduced by commit
> :::::: 017fa3e89187848fd056af757769c9e66ac3e93d minmax: simplify and clarify min_t()/max_t() implementation
> 
> :::::: TO: Linus Torvalds <torvalds@...ux-foundation.org>
> :::::: CC: Linus Torvalds <torvalds@...ux-foundation.org>
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ