[allisonhenderson-xfs_work:delayed_attrs_v22_extended 32/32] fs/xfs/xfs_ioctl.c:1834 xfs_ioc_get_parent_pointer() warn: maybe return -EFAULT instead of the bytes remaining?
From: Dan Carpenter
Date: Wed Aug 04 2021 - 07:06:31 EST
tree: https://github.com/allisonhenderson/xfs_work.git delayed_attrs_v22_extended
head: aff89515c2d9aca9b24ac0296f3806af62cd9206
commit: aff89515c2d9aca9b24ac0296f3806af62cd9206 [32/32] xfs: Add parent pointer ioctl
config: microblaze-randconfig-m031-20210730 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 10.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
New smatch warnings:
fs/xfs/xfs_ioctl.c:1834 xfs_ioc_get_parent_pointer() warn: maybe return -EFAULT instead of the bytes remaining?
vim +1834 fs/xfs/xfs_ioctl.c
aff89515c2d9aca Allison Henderson 2021-07-23 1817 if (ip->i_ino == mp->m_sb.sb_rootino)
aff89515c2d9aca Allison Henderson 2021-07-23 1818 ppi->pi_flags |= XFS_PPTR_OFLAG_ROOT;
aff89515c2d9aca Allison Henderson 2021-07-23 1819
aff89515c2d9aca Allison Henderson 2021-07-23 1820 /* Get the parent pointers */
aff89515c2d9aca Allison Henderson 2021-07-23 1821 error = xfs_attr_get_parent_pointer(ip, ppi);
aff89515c2d9aca Allison Henderson 2021-07-23 1822
aff89515c2d9aca Allison Henderson 2021-07-23 1823 if (error)
aff89515c2d9aca Allison Henderson 2021-07-23 1824 goto out;
aff89515c2d9aca Allison Henderson 2021-07-23 1825
aff89515c2d9aca Allison Henderson 2021-07-23 1826 /* Copy the parent pointers back to the user */
aff89515c2d9aca Allison Henderson 2021-07-23 1827 error = copy_to_user(arg, ppi,
aff89515c2d9aca Allison Henderson 2021-07-23 1828 XFS_PPTR_INFO_SIZEOF(ppi->pi_ptrs_size));
aff89515c2d9aca Allison Henderson 2021-07-23 1829 if (error)
aff89515c2d9aca Allison Henderson 2021-07-23 1830 goto out;
This needs to be:
if (copy_to_user(arg, ppi, XFS_PPTR_INFO_SIZEOF(ppi->pi_ptrs_size))) {
error = -EFAULT;
goto out;
}
aff89515c2d9aca Allison Henderson 2021-07-23 1831
aff89515c2d9aca Allison Henderson 2021-07-23 1832 out:
aff89515c2d9aca Allison Henderson 2021-07-23 1833 kmem_free(ppi);
aff89515c2d9aca Allison Henderson 2021-07-23 @1834 return error;
aff89515c2d9aca Allison Henderson 2021-07-23 1835 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx