All of lore.kernel.org
 help / color / mirror / Atom feed
* [osandov:btrfs-send-encoded 9/15] fs/btrfs/inode.c:10315 btrfs_encoded_read_regular() warn: potentially one past the end of array
@ 2021-01-12 23:18 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-01-12 23:18 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 6611 bytes --]

CC: kbuild-all(a)lists.01.org
CC: Omar Sandoval <osandov@osandov.com>
TO: Omar Sandoval <osandov@fb.com>
CC: Josef Bacik <josef@toxicpanda.com>

tree:   https://github.com/osandov/linux.git btrfs-send-encoded
head:   13342ab655c1ecc88634938f716739afe532e018
commit: ec42884e7540902d9480ef58858d419cbcdf6b72 [9/15] btrfs: implement RWF_ENCODED reads
:::::: branch date: 23 hours ago
:::::: commit date: 23 hours ago
config: i386-randconfig-m021-20210112 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
fs/btrfs/inode.c:10315 btrfs_encoded_read_regular() warn: potentially one past the end of array 'pages[i]'
fs/btrfs/inode.c:10315 btrfs_encoded_read_regular() warn: potentially one past the end of array 'pages[i]'

Old smatch warnings:
fs/btrfs/inode.c:255 insert_inline_extent() error: we previously assumed 'compressed_pages' could be null (see line 224)

vim +10315 fs/btrfs/inode.c

ec42884e7540902d Omar Sandoval 2019-10-09  10261  
ec42884e7540902d Omar Sandoval 2019-10-09  10262  static ssize_t btrfs_encoded_read_regular(struct kiocb *iocb,
ec42884e7540902d Omar Sandoval 2019-10-09  10263  					  struct iov_iter *iter,
ec42884e7540902d Omar Sandoval 2019-10-09  10264  					  u64 start, u64 lockend,
ec42884e7540902d Omar Sandoval 2019-10-09  10265  					  struct extent_state **cached_state,
ec42884e7540902d Omar Sandoval 2019-10-09  10266  					  u64 offset, u64 disk_io_size,
ec42884e7540902d Omar Sandoval 2019-10-09  10267  					  size_t count,
ec42884e7540902d Omar Sandoval 2019-10-09  10268  					  const struct encoded_iov *encoded,
ec42884e7540902d Omar Sandoval 2019-10-09  10269  					  bool *unlocked)
ec42884e7540902d Omar Sandoval 2019-10-09  10270  {
ec42884e7540902d Omar Sandoval 2019-10-09  10271  	struct inode *inode = file_inode(iocb->ki_filp);
ec42884e7540902d Omar Sandoval 2019-10-09  10272  	struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
ec42884e7540902d Omar Sandoval 2019-10-09  10273  	struct page **pages;
ec42884e7540902d Omar Sandoval 2019-10-09  10274  	unsigned long nr_pages, i;
ec42884e7540902d Omar Sandoval 2019-10-09  10275  	u64 cur;
ec42884e7540902d Omar Sandoval 2019-10-09  10276  	size_t page_offset;
ec42884e7540902d Omar Sandoval 2019-10-09  10277  	ssize_t ret;
ec42884e7540902d Omar Sandoval 2019-10-09  10278  
ec42884e7540902d Omar Sandoval 2019-10-09  10279  	nr_pages = DIV_ROUND_UP(disk_io_size, PAGE_SIZE);
ec42884e7540902d Omar Sandoval 2019-10-09  10280  	pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
ec42884e7540902d Omar Sandoval 2019-10-09  10281  	if (!pages)
ec42884e7540902d Omar Sandoval 2019-10-09  10282  		return -ENOMEM;
ec42884e7540902d Omar Sandoval 2019-10-09  10283  	for (i = 0; i < nr_pages; i++) {
ec42884e7540902d Omar Sandoval 2019-10-09  10284  		pages[i] = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
ec42884e7540902d Omar Sandoval 2019-10-09  10285  		if (!pages[i]) {
ec42884e7540902d Omar Sandoval 2019-10-09  10286  			ret = -ENOMEM;
ec42884e7540902d Omar Sandoval 2019-10-09  10287  			goto out;
ec42884e7540902d Omar Sandoval 2019-10-09  10288  		}
ec42884e7540902d Omar Sandoval 2019-10-09  10289  	}
ec42884e7540902d Omar Sandoval 2019-10-09  10290  
ec42884e7540902d Omar Sandoval 2019-10-09  10291  	ret = btrfs_encoded_read_regular_fill_pages(inode, offset, disk_io_size,
ec42884e7540902d Omar Sandoval 2019-10-09  10292  						    pages);
ec42884e7540902d Omar Sandoval 2019-10-09  10293  	if (ret)
ec42884e7540902d Omar Sandoval 2019-10-09  10294  		goto out;
ec42884e7540902d Omar Sandoval 2019-10-09  10295  
ec42884e7540902d Omar Sandoval 2019-10-09  10296  	unlock_extent_cached(io_tree, start, lockend, cached_state);
ec42884e7540902d Omar Sandoval 2019-10-09  10297  	inode_unlock_shared(inode);
ec42884e7540902d Omar Sandoval 2019-10-09  10298  	*unlocked = true;
ec42884e7540902d Omar Sandoval 2019-10-09  10299  
ec42884e7540902d Omar Sandoval 2019-10-09  10300  	ret = copy_encoded_iov_to_iter(encoded, iter);
ec42884e7540902d Omar Sandoval 2019-10-09  10301  	if (ret)
ec42884e7540902d Omar Sandoval 2019-10-09  10302  		goto out;
ec42884e7540902d Omar Sandoval 2019-10-09  10303  	if (encoded->compression) {
ec42884e7540902d Omar Sandoval 2019-10-09  10304  		i = 0;
ec42884e7540902d Omar Sandoval 2019-10-09  10305  		page_offset = 0;
ec42884e7540902d Omar Sandoval 2019-10-09  10306  	} else {
ec42884e7540902d Omar Sandoval 2019-10-09  10307  		i = (iocb->ki_pos - start) >> PAGE_SHIFT;
ec42884e7540902d Omar Sandoval 2019-10-09  10308  		page_offset = (iocb->ki_pos - start) & (PAGE_SIZE - 1);
ec42884e7540902d Omar Sandoval 2019-10-09  10309  	}
ec42884e7540902d Omar Sandoval 2019-10-09  10310  	cur = 0;
ec42884e7540902d Omar Sandoval 2019-10-09  10311  	while (cur < count) {
ec42884e7540902d Omar Sandoval 2019-10-09  10312  		size_t bytes = min_t(size_t, count - cur,
ec42884e7540902d Omar Sandoval 2019-10-09  10313  				     PAGE_SIZE - page_offset);
ec42884e7540902d Omar Sandoval 2019-10-09  10314  
ec42884e7540902d Omar Sandoval 2019-10-09 @10315  		if (copy_page_to_iter(pages[i], page_offset, bytes,
ec42884e7540902d Omar Sandoval 2019-10-09  10316  				      iter) != bytes) {
ec42884e7540902d Omar Sandoval 2019-10-09  10317  			ret = -EFAULT;
ec42884e7540902d Omar Sandoval 2019-10-09  10318  			goto out;
ec42884e7540902d Omar Sandoval 2019-10-09  10319  		}
ec42884e7540902d Omar Sandoval 2019-10-09  10320  		i++;
ec42884e7540902d Omar Sandoval 2019-10-09  10321  		cur += bytes;
ec42884e7540902d Omar Sandoval 2019-10-09  10322  		page_offset = 0;
ec42884e7540902d Omar Sandoval 2019-10-09  10323  	}
ec42884e7540902d Omar Sandoval 2019-10-09  10324  	ret = count;
ec42884e7540902d Omar Sandoval 2019-10-09  10325  out:
ec42884e7540902d Omar Sandoval 2019-10-09  10326  	for (i = 0; i < nr_pages; i++) {
ec42884e7540902d Omar Sandoval 2019-10-09  10327  		if (pages[i])
ec42884e7540902d Omar Sandoval 2019-10-09  10328  			__free_page(pages[i]);
ec42884e7540902d Omar Sandoval 2019-10-09  10329  	}
ec42884e7540902d Omar Sandoval 2019-10-09  10330  	kfree(pages);
ec42884e7540902d Omar Sandoval 2019-10-09  10331  	return ret;
ec42884e7540902d Omar Sandoval 2019-10-09  10332  }
ec42884e7540902d Omar Sandoval 2019-10-09  10333  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34379 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-12 23:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 23:18 [osandov:btrfs-send-encoded 9/15] fs/btrfs/inode.c:10315 btrfs_encoded_read_regular() warn: potentially one past the end of array kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.