CC: [email protected]
CC: [email protected]
TO: Allison Henderson <[email protected]>

tree:   https://github.com/allisonhenderson/xfs_work.git 
refs/heads/pptrs_restart130
head:   81b586ed999042613d6e120407086764e8ebf095
commit: 8ce1153c5c1fb72fe7b7a05d9e6ed4aa306d1c72 [30/32] xfs: Add parent 
pointer ioctl
:::::: branch date: 9 days ago
:::::: commit date: 9 days ago
config: riscv-randconfig-m031-20211103 (attached as .config)
compiler: riscv64-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

smatch warnings:
fs/xfs/xfs_ioctl.c:1833 xfs_ioc_get_parent_pointer() warn: maybe return -EFAULT 
instead of the bytes remaining?

vim +1833 fs/xfs/xfs_ioctl.c

36fd6e863cb732 Darrick J. Wong   2017-10-17  1754  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1755  /*
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1756   * IOCTL routine to get the 
parent pointers of an inode and return it to user
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1757   * space.  Caller must pass 
a buffer space containing a struct xfs_pptr_info,
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1758   * followed by a region 
large enough to contain an array of struct
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1759   * xfs_parent_ptr of a size 
specified in pi_ptrs_size.  If the inode contains
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1760   * more parent pointers than 
can fit in the buffer space, caller may re-call
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1761   * the function using the 
returned pi_cursor to resume iteration.  The
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1762   * number of xfs_parent_ptr 
returned will be stored in pi_ptrs_used.
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1763   *
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1764   * Returns 0 on success or 
non-zero on failure
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1765   */
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1766  STATIC int
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1767  xfs_ioc_get_parent_pointer(
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1768       struct file             
        *filp,
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1769       void                    
        __user *arg)
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1770  {
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1771       struct xfs_pptr_info    
        *ppi = NULL;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1772       int                     
        error = 0;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1773       struct xfs_inode        
        *ip = XFS_I(file_inode(filp));
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1774       struct xfs_mount        
        *mp = ip->i_mount;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1775  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1776       if 
(!capable(CAP_SYS_ADMIN))
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1777               return -EPERM;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1778  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1779       /* Allocate an 
xfs_pptr_info to put the user data */
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1780       ppi = 
kmem_alloc(sizeof(struct xfs_pptr_info), 0);
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1781       if (!ppi)
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1782               return -ENOMEM;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1783  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1784       /* Copy the data from 
the user */
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1785       error = 
copy_from_user(ppi, arg, sizeof(struct xfs_pptr_info));
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1786       if (error)
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1787               goto out;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1788  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1789       /* Check size of buffer 
requested by user */
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1790       if 
(XFS_PPTR_INFO_SIZEOF(ppi->pi_ptrs_size) > XFS_XATTR_LIST_MAX) {
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1791               error = -ENOMEM;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1792               goto out;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1793       }
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1794  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1795       /*
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1796        * Now that we know how 
big the trailing buffer is, expand
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1797        * our kernel 
xfs_pptr_info to be the same size
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1798        */
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1799       ppi = krealloc(ppi, 
XFS_PPTR_INFO_SIZEOF(ppi->pi_ptrs_size),
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1800                      GFP_NOFS 
| __GFP_NOFAIL);
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1801       if (!ppi)
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1802               return -ENOMEM;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1803  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1804       if (ppi->pi_flags != 0 
&& ppi->pi_flags != XFS_PPTR_IFLAG_HANDLE) {
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1805               error = -EINVAL;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1806               goto out;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1807       }
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1808  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1809       if (ppi->pi_flags == 
XFS_PPTR_IFLAG_HANDLE) {
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1810               error = 
xfs_iget(mp, NULL, ppi->pi_handle.ha_fid.fid_ino,
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1811                               
0, 0, &ip);
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1812               if (error)
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1813                       goto 
out;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1814       }
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1815  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1816       if (ip->i_ino == 
mp->m_sb.sb_rootino)
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1817               ppi->pi_flags 
|= XFS_PPTR_OFLAG_ROOT;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1818  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1819       /* Get the parent 
pointers */
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1820       error = 
xfs_attr_get_parent_pointer(ip, ppi);
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1821  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1822       if (error)
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1823               goto out;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1824  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1825       /* Copy the parent 
pointers back to the user */
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1826       error = 
copy_to_user(arg, ppi,
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1827                       
XFS_PPTR_INFO_SIZEOF(ppi->pi_ptrs_size));
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1828       if (error)
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1829               goto out;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1830  
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1831  out:
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1832       kmem_free(ppi);
8ce1153c5c1fb7 Allison Henderson 2021-07-23 @1833       return error;
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1834  }
8ce1153c5c1fb7 Allison Henderson 2021-07-23  1835  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to