:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check warning: 
fs/remap_range.c:571:17: warning: use of uninitialized value '<unknown>' 
[CWE-457] [-Wanalyzer-use-of-uninitialized-value]"
:::::: 

BCC: l...@intel.com
CC: kbuild-...@lists.01.org
TO: "Darrick J. Wong" <darrick.w...@oracle.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git 
vectorized-scrub
head:   1d79555b9e2bc74efef217aee3f208794112be10
commit: 23eba991e1a20b4a71314c01541d2e30af80a809 [202/411] vfs: introduce new 
file range exchange ioctl
:::::: branch date: 12 days ago
:::::: commit date: 12 days ago
config: arm-randconfig-c002-20220804 
(https://download.01.org/0day-ci/archive/20220807/202208072326.y46dqvlu-...@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git/commit/?id=23eba991e1a20b4a71314c01541d2e30af80a809
        git remote add djwong-xfs 
https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git
        git fetch --no-tags djwong-xfs vectorized-scrub
        git checkout 23eba991e1a20b4a71314c01541d2e30af80a809
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross 
ARCH=arm KBUILD_USERCFLAGS='-fanalyzer -Wno-error' 

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <l...@intel.com>

gcc-analyzer warnings: (new ones prefixed by >>)
   fs/remap_range.c: In function 'generic_xchg_file_range_checks':
>> fs/remap_range.c:571:17: warning: use of uninitialized value '<unknown>' 
>> [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
     571 |         int64_t test_len;
         |                 ^~~~~~~~
     'generic_xchg_file_range_checks': event 1
       |
       |  571 |         int64_t test_len;
       |      |                 ^~~~~~~~
       |      |                 |
       |      |                 (1) use of uninitialized value '<unknown>' here
       |

vim +571 fs/remap_range.c

23eba991e1a20b Darrick J. Wong 2022-07-14  561  
23eba991e1a20b Darrick J. Wong 2022-07-14  562  /* Performs necessary checks 
before doing a range exchange. */
23eba991e1a20b Darrick J. Wong 2022-07-14  563  static int 
generic_xchg_file_range_checks(struct file *file1,
23eba991e1a20b Darrick J. Wong 2022-07-14  564                                  
          struct file *file2,
23eba991e1a20b Darrick J. Wong 2022-07-14  565                                  
          struct file_xchg_range *fxr,
23eba991e1a20b Darrick J. Wong 2022-07-14  566                                  
          unsigned int blocksize)
23eba991e1a20b Darrick J. Wong 2022-07-14  567  {
23eba991e1a20b Darrick J. Wong 2022-07-14  568          struct inode *inode1 = 
file1->f_mapping->host;
23eba991e1a20b Darrick J. Wong 2022-07-14  569          struct inode *inode2 = 
file2->f_mapping->host;
23eba991e1a20b Darrick J. Wong 2022-07-14  570          uint64_t blkmask = 
blocksize - 1;
23eba991e1a20b Darrick J. Wong 2022-07-14 @571          int64_t test_len;
23eba991e1a20b Darrick J. Wong 2022-07-14  572          uint64_t blen;
23eba991e1a20b Darrick J. Wong 2022-07-14  573          loff_t size1, size2;
23eba991e1a20b Darrick J. Wong 2022-07-14  574          int ret;
23eba991e1a20b Darrick J. Wong 2022-07-14  575  
23eba991e1a20b Darrick J. Wong 2022-07-14  576          /* Don't touch certain 
kinds of inodes */
23eba991e1a20b Darrick J. Wong 2022-07-14  577          if 
(IS_IMMUTABLE(inode1) || IS_IMMUTABLE(inode2))
23eba991e1a20b Darrick J. Wong 2022-07-14  578                  return -EPERM;
23eba991e1a20b Darrick J. Wong 2022-07-14  579          if (IS_SWAPFILE(inode1) 
|| IS_SWAPFILE(inode2))
23eba991e1a20b Darrick J. Wong 2022-07-14  580                  return -ETXTBSY;
23eba991e1a20b Darrick J. Wong 2022-07-14  581  
23eba991e1a20b Darrick J. Wong 2022-07-14  582          size1 = 
i_size_read(inode1);
23eba991e1a20b Darrick J. Wong 2022-07-14  583          size2 = 
i_size_read(inode2);
23eba991e1a20b Darrick J. Wong 2022-07-14  584  
23eba991e1a20b Darrick J. Wong 2022-07-14  585          /* Ranges cannot start 
after EOF. */
23eba991e1a20b Darrick J. Wong 2022-07-14  586          if (fxr->file1_offset > 
size1 || fxr->file2_offset > size2)
23eba991e1a20b Darrick J. Wong 2022-07-14  587                  return -EINVAL;
23eba991e1a20b Darrick J. Wong 2022-07-14  588  
23eba991e1a20b Darrick J. Wong 2022-07-14  589          /*
23eba991e1a20b Darrick J. Wong 2022-07-14  590           * If the caller asked 
for full files, check that the offset/length
23eba991e1a20b Darrick J. Wong 2022-07-14  591           * values cover all of 
both files.
23eba991e1a20b Darrick J. Wong 2022-07-14  592           */
23eba991e1a20b Darrick J. Wong 2022-07-14  593          if ((fxr->flags & 
FILE_XCHG_RANGE_FULL_FILES) &&
23eba991e1a20b Darrick J. Wong 2022-07-14  594              (fxr->file1_offset 
!= 0 || fxr->file2_offset != 0 ||
23eba991e1a20b Darrick J. Wong 2022-07-14  595               fxr->length != 
size1 || fxr->length != size2))
23eba991e1a20b Darrick J. Wong 2022-07-14  596                  return -EDOM;
23eba991e1a20b Darrick J. Wong 2022-07-14  597  
23eba991e1a20b Darrick J. Wong 2022-07-14  598          /*
23eba991e1a20b Darrick J. Wong 2022-07-14  599           * If the caller said 
to exchange to EOF, we set the length of the
23eba991e1a20b Darrick J. Wong 2022-07-14  600           * request large enough 
to cover everything to the end of both files.
23eba991e1a20b Darrick J. Wong 2022-07-14  601           */
23eba991e1a20b Darrick J. Wong 2022-07-14  602          if (fxr->flags & 
FILE_XCHG_RANGE_TO_EOF)
23eba991e1a20b Darrick J. Wong 2022-07-14  603                  fxr->length = 
max_t(int64_t, size1 - fxr->file1_offset,
23eba991e1a20b Darrick J. Wong 2022-07-14  604                                  
             size2 - fxr->file2_offset);
23eba991e1a20b Darrick J. Wong 2022-07-14  605  
23eba991e1a20b Darrick J. Wong 2022-07-14  606          /* The start of both 
ranges must be aligned to an fs block. */
23eba991e1a20b Darrick J. Wong 2022-07-14  607          if 
(!IS_ALIGNED(fxr->file1_offset, blocksize) ||
23eba991e1a20b Darrick J. Wong 2022-07-14  608              
!IS_ALIGNED(fxr->file2_offset, blocksize))
23eba991e1a20b Darrick J. Wong 2022-07-14  609                  return -EINVAL;
23eba991e1a20b Darrick J. Wong 2022-07-14  610  
23eba991e1a20b Darrick J. Wong 2022-07-14  611          /* Ensure offsets don't 
wrap. */
23eba991e1a20b Darrick J. Wong 2022-07-14  612          if (fxr->file1_offset + 
fxr->length < fxr->file1_offset ||
23eba991e1a20b Darrick J. Wong 2022-07-14  613              fxr->file2_offset + 
fxr->length < fxr->file2_offset)
23eba991e1a20b Darrick J. Wong 2022-07-14  614                  return -EINVAL;
23eba991e1a20b Darrick J. Wong 2022-07-14  615  
23eba991e1a20b Darrick J. Wong 2022-07-14  616          /*
23eba991e1a20b Darrick J. Wong 2022-07-14  617           * We require both 
ranges to be within EOF, unless we're exchanging
23eba991e1a20b Darrick J. Wong 2022-07-14  618           * to EOF.  
generic_xchg_range_prep already checked that both
23eba991e1a20b Darrick J. Wong 2022-07-14  619           * fxr->file1_offset 
and fxr->file2_offset are within EOF.
23eba991e1a20b Darrick J. Wong 2022-07-14  620           */
23eba991e1a20b Darrick J. Wong 2022-07-14  621          if (!(fxr->flags & 
FILE_XCHG_RANGE_TO_EOF) &&
23eba991e1a20b Darrick J. Wong 2022-07-14  622              (fxr->file1_offset 
+ fxr->length > size1 ||
23eba991e1a20b Darrick J. Wong 2022-07-14  623               fxr->file2_offset 
+ fxr->length > size2))
23eba991e1a20b Darrick J. Wong 2022-07-14  624                  return -EINVAL;
23eba991e1a20b Darrick J. Wong 2022-07-14  625  
23eba991e1a20b Darrick J. Wong 2022-07-14  626          /*
23eba991e1a20b Darrick J. Wong 2022-07-14  627           * Make sure we don't 
hit any file size limits.  If we hit any size
23eba991e1a20b Darrick J. Wong 2022-07-14  628           * limits such that 
test_length was adjusted, we abort the whole
23eba991e1a20b Darrick J. Wong 2022-07-14  629           * operation.
23eba991e1a20b Darrick J. Wong 2022-07-14  630           */
23eba991e1a20b Darrick J. Wong 2022-07-14  631          test_len = fxr->length;
23eba991e1a20b Darrick J. Wong 2022-07-14  632          ret = 
generic_write_check_limits(file2, fxr->file2_offset, &test_len);
23eba991e1a20b Darrick J. Wong 2022-07-14  633          if (ret)
23eba991e1a20b Darrick J. Wong 2022-07-14  634                  return ret;
23eba991e1a20b Darrick J. Wong 2022-07-14  635          ret = 
generic_write_check_limits(file1, fxr->file1_offset, &test_len);
23eba991e1a20b Darrick J. Wong 2022-07-14  636          if (ret)
23eba991e1a20b Darrick J. Wong 2022-07-14  637                  return ret;
23eba991e1a20b Darrick J. Wong 2022-07-14  638          if (test_len != 
fxr->length)
23eba991e1a20b Darrick J. Wong 2022-07-14  639                  return -EINVAL;
23eba991e1a20b Darrick J. Wong 2022-07-14  640  
23eba991e1a20b Darrick J. Wong 2022-07-14  641          /*
23eba991e1a20b Darrick J. Wong 2022-07-14  642           * If the user wanted 
us to exchange up to the infile's EOF, round up
23eba991e1a20b Darrick J. Wong 2022-07-14  643           * to the next block 
boundary for this check.  Do the same for the
23eba991e1a20b Darrick J. Wong 2022-07-14  644           * outfile.
23eba991e1a20b Darrick J. Wong 2022-07-14  645           *
23eba991e1a20b Darrick J. Wong 2022-07-14  646           * Otherwise, reject 
the range length if it's not block aligned.  We
23eba991e1a20b Darrick J. Wong 2022-07-14  647           * already confirmed 
the starting offsets' block alignment.
23eba991e1a20b Darrick J. Wong 2022-07-14  648           */
23eba991e1a20b Darrick J. Wong 2022-07-14  649          if (fxr->file1_offset + 
fxr->length == size1)
23eba991e1a20b Darrick J. Wong 2022-07-14  650                  blen = 
ALIGN(size1, blocksize) - fxr->file1_offset;
23eba991e1a20b Darrick J. Wong 2022-07-14  651          else if 
(fxr->file2_offset + fxr->length == size2)
23eba991e1a20b Darrick J. Wong 2022-07-14  652                  blen = 
ALIGN(size2, blocksize) - fxr->file2_offset;
23eba991e1a20b Darrick J. Wong 2022-07-14  653          else if 
(!IS_ALIGNED(fxr->length, blocksize))
23eba991e1a20b Darrick J. Wong 2022-07-14  654                  return -EINVAL;
23eba991e1a20b Darrick J. Wong 2022-07-14  655          else
23eba991e1a20b Darrick J. Wong 2022-07-14  656                  blen = 
fxr->length;
23eba991e1a20b Darrick J. Wong 2022-07-14  657  
23eba991e1a20b Darrick J. Wong 2022-07-14  658          /* Don't allow 
overlapped exchanges within the same file. */
23eba991e1a20b Darrick J. Wong 2022-07-14  659          if (inode1 == inode2 &&
23eba991e1a20b Darrick J. Wong 2022-07-14  660              fxr->file2_offset + 
blen > fxr->file1_offset &&
23eba991e1a20b Darrick J. Wong 2022-07-14  661              fxr->file1_offset + 
blen > fxr->file2_offset)
23eba991e1a20b Darrick J. Wong 2022-07-14  662                  return -EINVAL;
23eba991e1a20b Darrick J. Wong 2022-07-14  663  
23eba991e1a20b Darrick J. Wong 2022-07-14  664          /* If we already failed 
the freshness check, we're done. */
23eba991e1a20b Darrick J. Wong 2022-07-14  665          ret = 
generic_xchg_file_range_check_fresh(inode2, fxr);
23eba991e1a20b Darrick J. Wong 2022-07-14  666          if (ret)
23eba991e1a20b Darrick J. Wong 2022-07-14  667                  return ret;
23eba991e1a20b Darrick J. Wong 2022-07-14  668  
23eba991e1a20b Darrick J. Wong 2022-07-14  669          /*
23eba991e1a20b Darrick J. Wong 2022-07-14  670           * Ensure that we don't 
exchange a partial EOF block into the middle of
23eba991e1a20b Darrick J. Wong 2022-07-14  671           * another file.
23eba991e1a20b Darrick J. Wong 2022-07-14  672           */
23eba991e1a20b Darrick J. Wong 2022-07-14  673          if ((fxr->length & 
blkmask) == 0)
23eba991e1a20b Darrick J. Wong 2022-07-14  674                  return 0;
23eba991e1a20b Darrick J. Wong 2022-07-14  675  
23eba991e1a20b Darrick J. Wong 2022-07-14  676          blen = fxr->length;
23eba991e1a20b Darrick J. Wong 2022-07-14  677          if (fxr->file2_offset + 
blen < size2)
23eba991e1a20b Darrick J. Wong 2022-07-14  678                  blen &= 
~blkmask;
23eba991e1a20b Darrick J. Wong 2022-07-14  679  
23eba991e1a20b Darrick J. Wong 2022-07-14  680          if (fxr->file1_offset + 
blen < size1)
23eba991e1a20b Darrick J. Wong 2022-07-14  681                  blen &= 
~blkmask;
23eba991e1a20b Darrick J. Wong 2022-07-14  682  
23eba991e1a20b Darrick J. Wong 2022-07-14  683          return blen == 
fxr->length ? 0 : -EINVAL;
23eba991e1a20b Darrick J. Wong 2022-07-14  684  }
23eba991e1a20b Darrick J. Wong 2022-07-14  685  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-le...@lists.01.org

Reply via email to