linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [jgunthorpe:iommufd 12/14] drivers/iommu/iommufd/vfio_compat.c:244:17: sparse: sparse: cast removes address space '__user' of expression
@ 2022-06-04 19:42 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2022-06-04 19:42 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: kbuild-all, linux-kernel, Nicolin Chen

tree:   https://github.com/jgunthorpe/linux iommufd
head:   64e1d852f05dde79e9e54bd7e99282f8a5ba8259
commit: cbc039f0577bf8fc8b5203d795fcc63a76aec8cb [12/14] iommufd: vfio container FD ioctl compatibility
config: ia64-randconfig-s031-20220604 (https://download.01.org/0day-ci/archive/20220605/202206050334.sxxTb3Ar-lkp@intel.com/config)
compiler: ia64-linux-gcc (GCC) 11.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-18-g56afb504-dirty
        # https://github.com/jgunthorpe/linux/commit/cbc039f0577bf8fc8b5203d795fcc63a76aec8cb
        git remote add jgunthorpe https://github.com/jgunthorpe/linux
        git fetch --no-tags jgunthorpe iommufd
        git checkout cbc039f0577bf8fc8b5203d795fcc63a76aec8cb
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/iommu/iommufd/

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


sparse warnings: (new ones prefixed by >>)
>> drivers/iommu/iommufd/vfio_compat.c:244:17: sparse: sparse: cast removes address space '__user' of expression
>> drivers/iommu/iommufd/vfio_compat.c:244:17: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected struct vfio_iommu_type1_info_cap_iova_range [noderef] __user *ucap_iovas @@     got struct vfio_iommu_type1_info_cap_iova_range * @@
   drivers/iommu/iommufd/vfio_compat.c:244:17: sparse:     expected struct vfio_iommu_type1_info_cap_iova_range [noderef] __user *ucap_iovas
   drivers/iommu/iommufd/vfio_compat.c:244:17: sparse:     got struct vfio_iommu_type1_info_cap_iova_range *

vim +/__user +244 drivers/iommu/iommufd/vfio_compat.c

   238	
   239	static int iommufd_fill_cap_iova(struct iommufd_ioas *ioas,
   240					 struct vfio_info_cap_header __user *cur,
   241					 size_t avail)
   242	{
   243		struct vfio_iommu_type1_info_cap_iova_range __user *ucap_iovas =
 > 244			container_of(cur, struct vfio_iommu_type1_info_cap_iova_range,
   245				     header);
   246		struct vfio_iommu_type1_info_cap_iova_range cap_iovas = {
   247			.header = {
   248				.id = VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE,
   249				.version = 1,
   250			},
   251		};
   252		struct interval_tree_span_iter span;
   253	
   254		for (interval_tree_span_iter_first(
   255			     &span, &ioas->iopt.reserved_iova_itree, 0, ULONG_MAX);
   256		     !interval_tree_span_iter_done(&span);
   257		     interval_tree_span_iter_next(&span)) {
   258			struct vfio_iova_range range;
   259	
   260			if (!span.is_hole)
   261				continue;
   262			range.start = span.start_hole;
   263			range.end = span.last_hole;
   264			if (avail >= struct_size(&cap_iovas, iova_ranges,
   265						 cap_iovas.nr_iovas + 1) &&
   266			    copy_to_user(&ucap_iovas->iova_ranges[cap_iovas.nr_iovas],
   267					 &range, sizeof(range)))
   268				return -EFAULT;
   269			cap_iovas.nr_iovas++;
   270		}
   271		if (avail >= struct_size(&cap_iovas, iova_ranges, cap_iovas.nr_iovas) &&
   272		    copy_to_user(ucap_iovas, &cap_iovas, sizeof(cap_iovas)))
   273			return -EFAULT;
   274		return struct_size(&cap_iovas, iova_ranges, cap_iovas.nr_iovas);
   275	}
   276	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

only message in thread, other threads:[~2022-06-04 19:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-04 19:42 [jgunthorpe:iommufd 12/14] drivers/iommu/iommufd/vfio_compat.c:244:17: sparse: sparse: cast removes address space '__user' of expression kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).