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: <202411220455.2X9OAAvt-lkp@intel.com>
Date: Fri, 22 Nov 2024 04:30:33 +0800
From: kernel test robot <lkp@...el.com>
To: Dan Carpenter <error27@...il.com>, Kees Cook <kees@...nel.org>
Cc: llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev,
	"Gustavo A. R. Silva" <gustavoars@...nel.org>,
	linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] overflow: improve size_add/mul for 32bit systems

Hi Dan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on kees/for-next/hardening]
[also build test WARNING on kees/for-next/pstore kees/for-next/kspp linus/master v6.12 next-20241121]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Dan-Carpenter/overflow-improve-size_add-mul-for-32bit-systems/20241121-124847
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
patch link:    https://lore.kernel.org/r/ebdae636-11f3-4f02-a158-f15bbed2847f%40stanley.mountain
patch subject: [PATCH] overflow: improve size_add/mul for 32bit systems
config: arm-allnoconfig (https://download.01.org/0day-ci/archive/20241122/202411220455.2X9OAAvt-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 592c0fe55f6d9a811028b5f3507be91458ab2713)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241122/202411220455.2X9OAAvt-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/202411220455.2X9OAAvt-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from block/bio.c:5:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
>> block/bio.c:616:17: warning: result of comparison of constant 4294967295 with expression of type 'typeof (nr_vecs)' (aka 'unsigned short') is always false [-Wtautological-constant-out-of-range-compare]
     616 |         return kmalloc(struct_size(bio, bi_inline_vecs, nr_vecs), gfp_mask);
         |                ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/overflow.h:396:18: note: expanded from macro 'struct_size'
     396 |                 sizeof(*(p)) + flex_array_size(p, member, count),       \
         |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/overflow.h:381:3: note: expanded from macro 'flex_array_size'
     381 |                 size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member)))
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/overflow.h:281:11: note: expanded from macro 'size_mul'
     281 |             (__a >= (u64)SIZE_MAX || __b >= (u64)SIZE_MAX))             \
         |              ~~~ ^
   include/linux/slab.h:884:52: note: expanded from macro 'kmalloc'
     884 | #define kmalloc(...)                            alloc_hooks(kmalloc_noprof(__VA_ARGS__))
         |                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
   include/linux/alloc_tag.h:210:31: note: expanded from macro 'alloc_hooks'
     210 |         alloc_hooks_tag(&_alloc_tag, _do_alloc);                        \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
   include/linux/alloc_tag.h:202:27: note: expanded from macro 'alloc_hooks_tag'
     202 |         typeof(_do_alloc) _res = _do_alloc;                             \
         |                                  ^~~~~~~~~
>> block/bio.c:616:17: warning: result of comparison of constant 4294967295 with expression of type 'typeof (nr_vecs)' (aka 'unsigned short') is always false [-Wtautological-constant-out-of-range-compare]
     616 |         return kmalloc(struct_size(bio, bi_inline_vecs, nr_vecs), gfp_mask);
         |                ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/overflow.h:397:26: note: expanded from macro 'struct_size'
     397 |                 size_add(sizeof(*(p)), flex_array_size(p, member, count)))
         |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/overflow.h:381:3: note: expanded from macro 'flex_array_size'
     381 |                 size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member)))
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/overflow.h:281:11: note: expanded from macro 'size_mul'
     281 |             (__a >= (u64)SIZE_MAX || __b >= (u64)SIZE_MAX))             \
         |              ~~~ ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/slab.h:884:52: note: expanded from macro 'kmalloc'
     884 | #define kmalloc(...)                            alloc_hooks(kmalloc_noprof(__VA_ARGS__))
         |                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
   include/linux/alloc_tag.h:210:31: note: expanded from macro 'alloc_hooks'
     210 |         alloc_hooks_tag(&_alloc_tag, _do_alloc);                        \
         |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
   include/linux/alloc_tag.h:202:27: note: expanded from macro 'alloc_hooks_tag'
     202 |         typeof(_do_alloc) _res = _do_alloc;                             \
         |                                  ^~~~~~~~~
   3 warnings generated.


vim +616 block/bio.c

^1da177e4c3f41 fs/bio.c    Linus Torvalds    2005-04-16  593  
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  594  /**
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06  595   * bio_kmalloc - kmalloc a bio
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06  596   * @nr_vecs:	number of bio_vecs to allocate
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  597   * @gfp_mask:   the GFP_* mask given to the slab allocator
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  598   *
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06  599   * Use kmalloc to allocate a bio (including bvecs).  The bio must be initialized
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06  600   * using bio_init() before use.  To free a bio returned from this function use
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06  601   * kfree() after calling bio_uninit().  A bio returned from this function can
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06  602   * be reused by calling bio_uninit() before calling bio_init() again.
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06  603   *
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06  604   * Note that unlike bio_alloc() or bio_alloc_bioset() allocations from this
340e134727c9ad block/bio.c Deming Wang       2022-10-06  605   * function are not backed by a mempool can fail.  Do not use this function
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06  606   * for allocations in the file system I/O path.
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  607   *
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  608   * Returns: Pointer to new bio on success, NULL on failure.
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  609   */
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06  610  struct bio *bio_kmalloc(unsigned short nr_vecs, gfp_t gfp_mask)
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  611  {
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  612  	struct bio *bio;
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  613  
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06  614  	if (nr_vecs > UIO_MAXIOV)
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  615  		return NULL;
066ff571011d84 block/bio.c Christoph Hellwig 2022-04-06 @616  	return kmalloc(struct_size(bio, bi_inline_vecs, nr_vecs), gfp_mask);
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  617  }
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  618  EXPORT_SYMBOL(bio_kmalloc);
3175199ab0ac8c block/bio.c Christoph Hellwig 2021-01-26  619  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ