[Intel-gfx] [PATCH v3 5/7] drm/i915: Check if the size is too big while creating shmem file

kernel test robot lkp at intel.com
Sat Jul 16 03:12:00 UTC 2022


Hi Gwan-gyeong,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on drm-tip/drm-tip]

url:    https://github.com/intel-lab-lkp/linux/commits/Gwan-gyeong-Mun/Fixes-integer-overflow-or-integer-truncation-issues-in-page-lookups-ttm-place-configuration-and-scatterlist-creation/20220714-171019
base:   git://anongit.freedesktop.org/drm/drm-tip drm-tip
config: i386-randconfig-a004 (https://download.01.org/0day-ci/archive/20220716/202207161058.dmOZoQzg-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 2da550140aa98cf6a3e96417c87f1e89e3a26047)
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://github.com/intel-lab-lkp/linux/commit/2938379499047baf3189503913f438fda6ea92eb
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Gwan-gyeong-Mun/Fixes-integer-overflow-or-integer-truncation-issues-in-page-lookups-ttm-place-configuration-and-scatterlist-creation/20220714-171019
        git checkout 2938379499047baf3189503913f438fda6ea92eb
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/gpu/drm/i915/

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

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/gem/i915_gem_shmem.c:550:11: warning: result of comparison of constant 17592186040320 with expression of type 'resource_size_t' (aka 'unsigned int') is always false [-Wtautological-constant-out-of-range-compare]
           if (size > MAX_LFS_FILESIZE)
               ~~~~ ^ ~~~~~~~~~~~~~~~~
   1 warning generated.


vim +550 drivers/gpu/drm/i915/gem/i915_gem_shmem.c

   534	
   535	static int __create_shmem(struct drm_i915_private *i915,
   536				  struct drm_gem_object *obj,
   537				  resource_size_t size)
   538	{
   539		unsigned long flags = VM_NORESERVE;
   540		struct file *filp;
   541	
   542		drm_gem_private_object_init(&i915->drm, obj, size);
   543	
   544		/* XXX: The __shmem_file_setup() function returns -EINVAL if size is
   545		 * greater than MAX_LFS_FILESIZE.
   546		 * To handle the same error as other code that returns -E2BIG when
   547		 * the size is too large, we add a code that returns -E2BIG when the
   548		 * size is larger than the size that can be handled.
   549		 */
 > 550		if (size > MAX_LFS_FILESIZE)
   551			return -E2BIG;
   552	
   553		if (i915->mm.gemfs)
   554			filp = shmem_file_setup_with_mnt(i915->mm.gemfs, "i915", size,
   555							 flags);
   556		else
   557			filp = shmem_file_setup("i915", size, flags);
   558		if (IS_ERR(filp))
   559			return PTR_ERR(filp);
   560	
   561		obj->filp = filp;
   562		return 0;
   563	}
   564	

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


More information about the dri-devel mailing list