arch/arm/kernel/sys_oabi-compat.c:251:51: sparse: sparse: incorrect type in argument 3 (different address spaces)

From: kernel test robot
Date: Tue Nov 23 2021 - 10:12:50 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 136057256686de39cc3a07c2e39ef6bc43003ff6
commit: 7e2d8c29ecdd86afbcedb9d9a977bab8af527add ARM: 9111/1: oabi-compat: rework fcntl64() emulation
date: 3 months ago
config: arm-randconfig-s032-20211123 (https://download.01.org/0day-ci/archive/20211123/202111232352.1I2ZjeBh-lkp@xxxxxxxxx/config.gz)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.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-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7e2d8c29ecdd86afbcedb9d9a977bab8af527add
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 7e2d8c29ecdd86afbcedb9d9a977bab8af527add
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


sparse warnings: (new ones prefixed by >>)
>> arch/arm/kernel/sys_oabi-compat.c:251:51: sparse: sparse: incorrect type in argument 3 (different address spaces) @@ expected struct flock64 [noderef] __user *user @@ got struct flock64 * @@
arch/arm/kernel/sys_oabi-compat.c:251:51: sparse: expected struct flock64 [noderef] __user *user
arch/arm/kernel/sys_oabi-compat.c:251:51: sparse: got struct flock64 *
arch/arm/kernel/sys_oabi-compat.c:265:55: sparse: sparse: incorrect type in argument 4 (different address spaces) @@ expected struct flock64 [noderef] __user *user @@ got struct flock64 * @@
arch/arm/kernel/sys_oabi-compat.c:265:55: sparse: expected struct flock64 [noderef] __user *user
arch/arm/kernel/sys_oabi-compat.c:265:55: sparse: got struct flock64 *
arch/arm/kernel/sys_oabi-compat.c:292:23: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __poll_t [usertype] events @@ got unsigned int [addressable] [usertype] events @@
arch/arm/kernel/sys_oabi-compat.c:292:23: sparse: expected restricted __poll_t [usertype] events
arch/arm/kernel/sys_oabi-compat.c:292:23: sparse: got unsigned int [addressable] [usertype] events
arch/arm/kernel/sys_oabi-compat.c:312:21: sparse: sparse: incorrect type in initializer (different base types) @@ expected unsigned int __pu_val @@ got restricted __poll_t [usertype] revents @@
arch/arm/kernel/sys_oabi-compat.c:312:21: sparse: expected unsigned int __pu_val
arch/arm/kernel/sys_oabi-compat.c:312:21: sparse: got restricted __poll_t [usertype] revents

vim +251 arch/arm/kernel/sys_oabi-compat.c

230
231 asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd,
232 unsigned long arg)
233 {
234 void __user *argp = (void __user *)arg;
235 struct fd f = fdget_raw(fd);
236 struct flock64 flock;
237 long err = -EBADF;
238
239 if (!f.file)
240 goto out;
241
242 switch (cmd) {
243 case F_GETLK64:
244 case F_OFD_GETLK:
245 err = security_file_fcntl(f.file, cmd, arg);
246 if (err)
247 break;
248 err = get_oabi_flock(&flock, argp);
249 if (err)
250 break;
> 251 err = fcntl_getlk64(f.file, cmd, &flock);
252 if (!err)
253 err = put_oabi_flock(&flock, argp);
254 break;
255 case F_SETLK64:
256 case F_SETLKW64:
257 case F_OFD_SETLK:
258 case F_OFD_SETLKW:
259 err = security_file_fcntl(f.file, cmd, arg);
260 if (err)
261 break;
262 err = get_oabi_flock(&flock, argp);
263 if (err)
264 break;
265 err = fcntl_setlk64(fd, f.file, cmd, &flock);
266 break;
267 default:
268 err = sys_fcntl64(fd, cmd, arg);
269 break;
270 }
271 fdput(f);
272 out:
273 return err;
274 }
275

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx