lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202208201640.D1cUWPeR-lkp@intel.com>
Date:   Sat, 20 Aug 2022 16:35:55 +0800
From:   kernel test robot <lkp@...el.com>
To:     Jens Wiklander <jens.wiklander@...aro.org>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        Sasha Levin <sashal@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: [linux-stable-rc:queue/5.4 285/287] drivers/tee/tee_shm.c:242:14:
 error: implicit declaration of function 'access_ok'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git queue/5.4
head:   7ef356c708cbb2e28b3adaaf8bb6011f50fe4ee5
commit: 51bcd4a8616806b5ecfaa54dfacf072cc920a3aa [285/287] tee: add overflow check in register_shm_helper()
config: powerpc-randconfig-s033-20220820 (https://download.01.org/0day-ci/archive/20220820/202208201640.D1cUWPeR-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 12.1.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-39-gce1a6720-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/commit/?id=51bcd4a8616806b5ecfaa54dfacf072cc920a3aa
        git remote add linux-stable-rc https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
        git fetch --no-tags linux-stable-rc queue/5.4
        git checkout 51bcd4a8616806b5ecfaa54dfacf072cc920a3aa
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/tee/

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

All errors (new ones prefixed by >>):

   drivers/tee/tee_shm.c: In function 'tee_shm_register':
>> drivers/tee/tee_shm.c:242:14: error: implicit declaration of function 'access_ok' [-Werror=implicit-function-declaration]
     242 |         if (!access_ok((void __user *)addr, length))
         |              ^~~~~~~~~
   cc1: some warnings being treated as errors


vim +/access_ok +242 drivers/tee/tee_shm.c

   168	
   169	struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
   170					 size_t length, u32 flags)
   171	{
   172		struct tee_device *teedev = ctx->teedev;
   173		const u32 req_flags = TEE_SHM_DMA_BUF | TEE_SHM_USER_MAPPED;
   174		struct tee_shm *shm;
   175		void *ret;
   176		int rc;
   177		int num_pages;
   178		unsigned long start;
   179	
   180		if (flags != req_flags)
   181			return ERR_PTR(-ENOTSUPP);
   182	
   183		if (!tee_device_get(teedev))
   184			return ERR_PTR(-EINVAL);
   185	
   186		if (!teedev->desc->ops->shm_register ||
   187		    !teedev->desc->ops->shm_unregister) {
   188			tee_device_put(teedev);
   189			return ERR_PTR(-ENOTSUPP);
   190		}
   191	
   192		teedev_ctx_get(ctx);
   193	
   194		shm = kzalloc(sizeof(*shm), GFP_KERNEL);
   195		if (!shm) {
   196			ret = ERR_PTR(-ENOMEM);
   197			goto err;
   198		}
   199	
   200		refcount_set(&shm->refcount, 1);
   201		shm->flags = flags | TEE_SHM_REGISTER;
   202		shm->teedev = teedev;
   203		shm->ctx = ctx;
   204		shm->id = -1;
   205		addr = untagged_addr(addr);
   206		start = rounddown(addr, PAGE_SIZE);
   207		shm->offset = addr - start;
   208		shm->size = length;
   209		num_pages = (roundup(addr + length, PAGE_SIZE) - start) / PAGE_SIZE;
   210		shm->pages = kcalloc(num_pages, sizeof(*shm->pages), GFP_KERNEL);
   211		if (!shm->pages) {
   212			ret = ERR_PTR(-ENOMEM);
   213			goto err;
   214		}
   215	
   216		rc = get_user_pages_fast(start, num_pages, FOLL_WRITE, shm->pages);
   217		if (rc > 0)
   218			shm->num_pages = rc;
   219		if (rc != num_pages) {
   220			if (rc >= 0)
   221				rc = -ENOMEM;
   222			ret = ERR_PTR(rc);
   223			goto err;
   224		}
   225	
   226		mutex_lock(&teedev->mutex);
   227		shm->id = idr_alloc(&teedev->idr, shm, 1, 0, GFP_KERNEL);
   228		mutex_unlock(&teedev->mutex);
   229	
   230		if (shm->id < 0) {
   231			ret = ERR_PTR(shm->id);
   232			goto err;
   233		}
   234	
   235		rc = teedev->desc->ops->shm_register(ctx, shm, shm->pages,
   236						     shm->num_pages, start);
   237		if (rc) {
   238			ret = ERR_PTR(rc);
   239			goto err;
   240		}
   241	
 > 242		if (!access_ok((void __user *)addr, length))
   243			return ERR_PTR(-EFAULT);
   244	
   245		mutex_lock(&teedev->mutex);
   246		list_add_tail(&shm->link, &ctx->list_shm);
   247		mutex_unlock(&teedev->mutex);
   248	
   249		return shm;
   250	err:
   251		if (shm) {
   252			size_t n;
   253	
   254			if (shm->id >= 0) {
   255				mutex_lock(&teedev->mutex);
   256				idr_remove(&teedev->idr, shm->id);
   257				mutex_unlock(&teedev->mutex);
   258			}
   259			if (shm->pages) {
   260				for (n = 0; n < shm->num_pages; n++)
   261					put_page(shm->pages[n]);
   262				kfree(shm->pages);
   263			}
   264		}
   265		kfree(shm);
   266		teedev_ctx_put(ctx);
   267		tee_device_put(teedev);
   268		return ret;
   269	}
   270	EXPORT_SYMBOL_GPL(tee_shm_register);
   271	

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ