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: <aG3AVf8fbqHzk+OD@rli9-mobl>
Date: Wed, 9 Jul 2025 09:05:25 +0800
From: kernel test robot <lkp@...el.com>
To: Colin Ian King <colin.i.king@...il.com>, Phillip Lougher
	<phillip@...ashfs.org.uk>, Chanho Min <chanho.min@....com>
CC: <oe-kbuild-all@...ts.linux.dev>, <kernel-janitors@...r.kernel.org>,
	"Andrew Morton" <akpm@...ux-foundation.org>, Linux Memory Management List
	<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] squashfs: Fix incorrect argument to sizeof in
 kmalloc_array call

Hi Colin,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on next-20250708]
[cannot apply to linus/master v6.16-rc5]
[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/Colin-Ian-King/squashfs-Fix-incorrect-argument-to-sizeof-in-kmalloc_array-call/20250708-223017
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20250708142604.1891156-1-colin.i.king%40gmail.com
patch subject: [PATCH] squashfs: Fix incorrect argument to sizeof in kmalloc_array call
:::::: branch date: 10 hours ago
:::::: commit date: 10 hours ago
config: mips-randconfig-r071-20250709 (attached as .config)
compiler: mips64-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (attached as 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/202507090822.QI1bMiUV-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/percpu.h:5,
                    from include/linux/percpu_counter.h:14,
                    from include/linux/mm_types.h:21,
                    from include/linux/mmzone.h:22,
                    from include/linux/gfp.h:7,
                    from include/linux/xarray.h:16,
                    from include/linux/list_lru.h:14,
                    from include/linux/fs.h:14,
                    from include/linux/highmem.h:5,
                    from include/linux/bvec.h:10,
                    from include/linux/blk_types.h:10,
                    from include/linux/blkdev.h:9,
                    from fs/squashfs/block.c:16:
   fs/squashfs/block.c: In function 'squashfs_bio_read_cached':
>> fs/squashfs/block.c:92:12: error: 'folio' undeclared (first use in this function)
       sizeof(*folio), GFP_KERNEL | __GFP_ZERO);
               ^~~~~
   include/linux/alloc_tag.h:239:9: note: in definition of macro 'alloc_hooks_tag'
     typeof(_do_alloc) _res;      \
            ^~~~~~~~~
   include/linux/slab.h:950:30: note: in expansion of macro 'alloc_hooks'
    #define kmalloc_array(...)   alloc_hooks(kmalloc_array_noprof(__VA_ARGS__))
                                 ^~~~~~~~~~~
   fs/squashfs/block.c:91:32: note: in expansion of macro 'kmalloc_array'
     struct folio **cache_folios = kmalloc_array(page_count,
                                   ^~~~~~~~~~~~~
   fs/squashfs/block.c:92:12: note: each undeclared identifier is reported only once for each function it appears in
       sizeof(*folio), GFP_KERNEL | __GFP_ZERO);
               ^~~~~
   include/linux/alloc_tag.h:239:9: note: in definition of macro 'alloc_hooks_tag'
     typeof(_do_alloc) _res;      \
            ^~~~~~~~~
   include/linux/slab.h:950:30: note: in expansion of macro 'alloc_hooks'
    #define kmalloc_array(...)   alloc_hooks(kmalloc_array_noprof(__VA_ARGS__))
                                 ^~~~~~~~~~~
   fs/squashfs/block.c:91:32: note: in expansion of macro 'kmalloc_array'
     struct folio **cache_folios = kmalloc_array(page_count,
                                   ^~~~~~~~~~~~~
>> include/linux/alloc_tag.h:251:1: warning: initialization of 'struct folio **' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    ({         \
    ^
   include/linux/slab.h:950:30: note: in expansion of macro 'alloc_hooks'
    #define kmalloc_array(...)   alloc_hooks(kmalloc_array_noprof(__VA_ARGS__))
                                 ^~~~~~~~~~~
   fs/squashfs/block.c:91:32: note: in expansion of macro 'kmalloc_array'
     struct folio **cache_folios = kmalloc_array(page_count,
                                   ^~~~~~~~~~~~~
--
   In file included from include/linux/percpu.h:5,
                    from include/linux/percpu_counter.h:14,
                    from include/linux/mm_types.h:21,
                    from include/linux/mmzone.h:22,
                    from include/linux/gfp.h:7,
                    from include/linux/xarray.h:16,
                    from include/linux/list_lru.h:14,
                    from include/linux/fs.h:14,
                    from include/linux/highmem.h:5,
                    from include/linux/bvec.h:10,
                    from include/linux/blk_types.h:10,
                    from include/linux/blkdev.h:9,
                    from block.c:16:
   block.c: In function 'squashfs_bio_read_cached':
   block.c:92:12: error: 'folio' undeclared (first use in this function)
       sizeof(*folio), GFP_KERNEL | __GFP_ZERO);
               ^~~~~
   include/linux/alloc_tag.h:239:9: note: in definition of macro 'alloc_hooks_tag'
     typeof(_do_alloc) _res;      \
            ^~~~~~~~~
   include/linux/slab.h:950:30: note: in expansion of macro 'alloc_hooks'
    #define kmalloc_array(...)   alloc_hooks(kmalloc_array_noprof(__VA_ARGS__))
                                 ^~~~~~~~~~~
   block.c:91:32: note: in expansion of macro 'kmalloc_array'
     struct folio **cache_folios = kmalloc_array(page_count,
                                   ^~~~~~~~~~~~~
   block.c:92:12: note: each undeclared identifier is reported only once for each function it appears in
       sizeof(*folio), GFP_KERNEL | __GFP_ZERO);
               ^~~~~
   include/linux/alloc_tag.h:239:9: note: in definition of macro 'alloc_hooks_tag'
     typeof(_do_alloc) _res;      \
            ^~~~~~~~~
   include/linux/slab.h:950:30: note: in expansion of macro 'alloc_hooks'
    #define kmalloc_array(...)   alloc_hooks(kmalloc_array_noprof(__VA_ARGS__))
                                 ^~~~~~~~~~~
   block.c:91:32: note: in expansion of macro 'kmalloc_array'
     struct folio **cache_folios = kmalloc_array(page_count,
                                   ^~~~~~~~~~~~~
>> include/linux/alloc_tag.h:251:1: warning: initialization of 'struct folio **' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    ({         \
    ^
   include/linux/slab.h:950:30: note: in expansion of macro 'alloc_hooks'
    #define kmalloc_array(...)   alloc_hooks(kmalloc_array_noprof(__VA_ARGS__))
                                 ^~~~~~~~~~~
   block.c:91:32: note: in expansion of macro 'kmalloc_array'
     struct folio **cache_folios = kmalloc_array(page_count,
                                   ^~~~~~~~~~~~~


vim +/folio +92 fs/squashfs/block.c

93e72b3c612adc Philippe Liard          2020-06-01   78  
e994f5b677ee01 Vincent Whitchurch      2023-05-17   79  static int squashfs_bio_read_cached(struct bio *fullbio,
e994f5b677ee01 Vincent Whitchurch      2023-05-17   80  		struct address_space *cache_mapping, u64 index, int length,
e994f5b677ee01 Vincent Whitchurch      2023-05-17   81  		u64 read_start, u64 read_end, int page_count)
e994f5b677ee01 Vincent Whitchurch      2023-05-17   82  {
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12   83) 	struct folio *head_to_cache = NULL, *tail_to_cache = NULL;
e994f5b677ee01 Vincent Whitchurch      2023-05-17   84  	struct block_device *bdev = fullbio->bi_bdev;
e994f5b677ee01 Vincent Whitchurch      2023-05-17   85  	int start_idx = 0, end_idx = 0;
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12   86) 	struct folio_iter fi;;
e994f5b677ee01 Vincent Whitchurch      2023-05-17   87  	struct bio *bio = NULL;
e994f5b677ee01 Vincent Whitchurch      2023-05-17   88  	int idx = 0;
e994f5b677ee01 Vincent Whitchurch      2023-05-17   89  	int err = 0;
2e227ff5e2729b Chanho Min              2025-05-21   90  #ifdef CONFIG_SQUASHFS_COMP_CACHE_FULL
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12   91) 	struct folio **cache_folios = kmalloc_array(page_count,
45eb6ae283427f Colin Ian King          2025-07-08  @92  			sizeof(*folio), GFP_KERNEL | __GFP_ZERO);
2e227ff5e2729b Chanho Min              2025-05-21   93  #endif
e994f5b677ee01 Vincent Whitchurch      2023-05-17   94  
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12   95) 	bio_for_each_folio_all(fi, fullbio) {
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12   96) 		struct folio *folio = fi.folio;
e994f5b677ee01 Vincent Whitchurch      2023-05-17   97  
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12   98) 		if (folio->mapping == cache_mapping) {
e994f5b677ee01 Vincent Whitchurch      2023-05-17   99  			idx++;
e994f5b677ee01 Vincent Whitchurch      2023-05-17  100  			continue;
e994f5b677ee01 Vincent Whitchurch      2023-05-17  101  		}
e994f5b677ee01 Vincent Whitchurch      2023-05-17  102  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  103  		/*
e994f5b677ee01 Vincent Whitchurch      2023-05-17  104  		 * We only use this when the device block size is the same as
e994f5b677ee01 Vincent Whitchurch      2023-05-17  105  		 * the page size, so read_start and read_end cover full pages.
e994f5b677ee01 Vincent Whitchurch      2023-05-17  106  		 *
e994f5b677ee01 Vincent Whitchurch      2023-05-17  107  		 * Compare these to the original required index and length to
e994f5b677ee01 Vincent Whitchurch      2023-05-17  108  		 * only cache pages which were requested partially, since these
e994f5b677ee01 Vincent Whitchurch      2023-05-17  109  		 * are the ones which are likely to be needed when reading
e994f5b677ee01 Vincent Whitchurch      2023-05-17  110  		 * adjacent blocks.
e994f5b677ee01 Vincent Whitchurch      2023-05-17  111  		 */
e994f5b677ee01 Vincent Whitchurch      2023-05-17  112  		if (idx == 0 && index != read_start)
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12  113) 			head_to_cache = folio;
e994f5b677ee01 Vincent Whitchurch      2023-05-17  114  		else if (idx == page_count - 1 && index + length != read_end)
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12  115) 			tail_to_cache = folio;
2e227ff5e2729b Chanho Min              2025-05-21  116  #ifdef CONFIG_SQUASHFS_COMP_CACHE_FULL
2e227ff5e2729b Chanho Min              2025-05-21  117  		/* Cache all pages in the BIO for repeated reads */
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12  118) 		else if (cache_folios)
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12  119) 			cache_folios[idx] = folio;
2e227ff5e2729b Chanho Min              2025-05-21  120  #endif
e994f5b677ee01 Vincent Whitchurch      2023-05-17  121  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  122  		if (!bio || idx != end_idx) {
e994f5b677ee01 Vincent Whitchurch      2023-05-17  123  			struct bio *new = bio_alloc_clone(bdev, fullbio,
e994f5b677ee01 Vincent Whitchurch      2023-05-17  124  							  GFP_NOIO, &fs_bio_set);
e994f5b677ee01 Vincent Whitchurch      2023-05-17  125  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  126  			if (bio) {
e994f5b677ee01 Vincent Whitchurch      2023-05-17  127  				bio_trim(bio, start_idx * PAGE_SECTORS,
e994f5b677ee01 Vincent Whitchurch      2023-05-17  128  					 (end_idx - start_idx) * PAGE_SECTORS);
e994f5b677ee01 Vincent Whitchurch      2023-05-17  129  				bio_chain(bio, new);
e994f5b677ee01 Vincent Whitchurch      2023-05-17  130  				submit_bio(bio);
e994f5b677ee01 Vincent Whitchurch      2023-05-17  131  			}
e994f5b677ee01 Vincent Whitchurch      2023-05-17  132  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  133  			bio = new;
e994f5b677ee01 Vincent Whitchurch      2023-05-17  134  			start_idx = idx;
e994f5b677ee01 Vincent Whitchurch      2023-05-17  135  		}
e994f5b677ee01 Vincent Whitchurch      2023-05-17  136  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  137  		idx++;
e994f5b677ee01 Vincent Whitchurch      2023-05-17  138  		end_idx = idx;
e994f5b677ee01 Vincent Whitchurch      2023-05-17  139  	}
e994f5b677ee01 Vincent Whitchurch      2023-05-17  140  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  141  	if (bio) {
e994f5b677ee01 Vincent Whitchurch      2023-05-17  142  		bio_trim(bio, start_idx * PAGE_SECTORS,
e994f5b677ee01 Vincent Whitchurch      2023-05-17  143  			 (end_idx - start_idx) * PAGE_SECTORS);
e994f5b677ee01 Vincent Whitchurch      2023-05-17  144  		err = submit_bio_wait(bio);
e994f5b677ee01 Vincent Whitchurch      2023-05-17  145  		bio_put(bio);
e994f5b677ee01 Vincent Whitchurch      2023-05-17  146  	}
e994f5b677ee01 Vincent Whitchurch      2023-05-17  147  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  148  	if (err)
e994f5b677ee01 Vincent Whitchurch      2023-05-17  149  		return err;
e994f5b677ee01 Vincent Whitchurch      2023-05-17  150  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  151  	if (head_to_cache) {
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12  152) 		int ret = filemap_add_folio(cache_mapping, head_to_cache,
e994f5b677ee01 Vincent Whitchurch      2023-05-17  153  						read_start >> PAGE_SHIFT,
e994f5b677ee01 Vincent Whitchurch      2023-05-17  154  						GFP_NOIO);
e994f5b677ee01 Vincent Whitchurch      2023-05-17  155  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  156  		if (!ret) {
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12  157) 			folio_mark_uptodate(head_to_cache);
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12  158) 			folio_unlock(head_to_cache);
e994f5b677ee01 Vincent Whitchurch      2023-05-17  159  		}
e994f5b677ee01 Vincent Whitchurch      2023-05-17  160  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  161  	}
e994f5b677ee01 Vincent Whitchurch      2023-05-17  162  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  163  	if (tail_to_cache) {
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12  164) 		int ret = filemap_add_folio(cache_mapping, tail_to_cache,
e994f5b677ee01 Vincent Whitchurch      2023-05-17  165  						(read_end >> PAGE_SHIFT) - 1,
e994f5b677ee01 Vincent Whitchurch      2023-05-17  166  						GFP_NOIO);
e994f5b677ee01 Vincent Whitchurch      2023-05-17  167  
e994f5b677ee01 Vincent Whitchurch      2023-05-17  168  		if (!ret) {
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12  169) 			folio_mark_uptodate(tail_to_cache);
193770db0106b0 Matthew Wilcox (Oracle  2025-06-12  170) 			folio_unlock(tail_to_cache);
e994f5b677ee01 Vincent Whitchurch      2023-05-17  171  		}
e994f5b677ee01 Vincent Whitchurch      2023-05-17  172  	}
e994f5b677ee01 Vincent Whitchurch      2023-05-17  173  

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

Download attachment ".config.gz" of type "application/gzip" (43265 bytes)

View attachment "reproduce" of type "text/plain" (729 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ