include/asm-generic/uaccess.h:287:16: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: kernel test robot
Date: Sun Aug 15 2021 - 18:22:00 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: ecf93431963a95c0f475921101bedc0dd62ec96d
commit: 9530141455c968938a913d602a236c2a7b0322e1 riscv: Add ARCH_HAS_FORTIFY_SOURCE
date: 5 months ago
config: riscv-randconfig-s032-20210816 (attached as .config)
compiler: riscv64-linux-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.3-348-gf0e6938b-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9530141455c968938a913d602a236c2a7b0322e1
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 9530141455c968938a913d602a236c2a7b0322e1
# save the attached .config 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=riscv

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


sparse warnings: (new ones prefixed by >>)
mm/maccess.c: note: in included file (through arch/riscv/include/asm/uaccess.h, include/linux/uaccess.h, include/linux/sched/task.h, ...):
>> include/asm-generic/uaccess.h:287:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const *p @@ got char const [noderef] __user *src @@
include/asm-generic/uaccess.h:287:16: sparse: expected char const *p
include/asm-generic/uaccess.h:287:16: sparse: got char const [noderef] __user *src
--
mm/util.c:124:6: sparse: sparse: multiple definitions for function 'kmemdup'
mm/util.c: note: in included file (through include/linux/string.h, include/linux/bitmap.h, include/linux/cpumask.h, ...):
include/linux/fortify-string.h:262:23: sparse: the previous one is here
mm/util.c: note: in included file (through arch/riscv/include/asm/uaccess.h, include/linux/uaccess.h, include/linux/sched/task.h, ...):
>> include/asm-generic/uaccess.h:287:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const *p @@ got char const [noderef] __user *src @@
include/asm-generic/uaccess.h:287:16: sparse: expected char const *p
include/asm-generic/uaccess.h:287:16: sparse: got char const [noderef] __user *src
--
fs/exec.c:422:31: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected char const [noderef] __user * @@ got void * @@
fs/exec.c:422:31: sparse: expected char const [noderef] __user *
fs/exec.c:422:31: sparse: got void *
fs/exec.c:879:35: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __user *to @@ got void * @@
fs/exec.c:879:35: sparse: expected void [noderef] __user *to
fs/exec.c:879:35: sparse: got void *
fs/exec.c:1041:48: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct sighand_struct *oldsighand @@ got struct sighand_struct [noderef] __rcu *sighand @@
fs/exec.c:1041:48: sparse: expected struct sighand_struct *oldsighand
fs/exec.c:1041:48: sparse: got struct sighand_struct [noderef] __rcu *sighand
fs/exec.c:1148:56: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected struct task_struct *parent @@ got struct task_struct [noderef] __rcu *parent @@
fs/exec.c:1148:56: sparse: expected struct task_struct *parent
fs/exec.c:1148:56: sparse: got struct task_struct [noderef] __rcu *parent
fs/exec.c:1183:47: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct sighand_struct *oldsighand @@ got struct sighand_struct [noderef] __rcu *sighand @@
fs/exec.c:1183:47: sparse: expected struct sighand_struct *oldsighand
fs/exec.c:1183:47: sparse: got struct sighand_struct [noderef] __rcu *sighand
fs/exec.c:1752:70: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected struct task_struct *tsk @@ got struct task_struct [noderef] __rcu *parent @@
fs/exec.c:1752:70: sparse: expected struct task_struct *tsk
fs/exec.c:1752:70: sparse: got struct task_struct [noderef] __rcu *parent
fs/exec.c: note: in included file (through arch/riscv/include/asm/uaccess.h, include/linux/uaccess.h, include/linux/sched/task.h, ...):
>> include/asm-generic/uaccess.h:287:16: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const *p @@ got char const [noderef] __user *src @@
include/asm-generic/uaccess.h:287:16: sparse: expected char const *p
include/asm-generic/uaccess.h:287:16: sparse: got char const [noderef] __user *src

vim +287 include/asm-generic/uaccess.h

7f509a9ef7af0d GuanXuetao 2011-01-15 277
830f5800acae17 Mark Salter 2011-10-04 278 /*
830f5800acae17 Mark Salter 2011-10-04 279 * Unlike strnlen, strnlen_user includes the nul terminator in
830f5800acae17 Mark Salter 2011-10-04 280 * its returned count. Callers should check for a returned value
830f5800acae17 Mark Salter 2011-10-04 281 * greater than N as an indication the string is too long.
830f5800acae17 Mark Salter 2011-10-04 282 */
eed417ddd52146 Arnd Bergmann 2009-05-13 283 static inline long strnlen_user(const char __user *src, long n)
eed417ddd52146 Arnd Bergmann 2009-05-13 284 {
96d4f267e40f95 Linus Torvalds 2019-01-03 285 if (!access_ok(src, 1))
9844813f226f6d Mike Frysinger 2009-06-14 286 return 0;
7f509a9ef7af0d GuanXuetao 2011-01-15 @287 return __strnlen_user(src, n);
eed417ddd52146 Arnd Bergmann 2009-05-13 288 }
eed417ddd52146 Arnd Bergmann 2009-05-13 289

:::::: The code at line 287 was first introduced by commit
:::::: 7f509a9ef7af0d6ac852d49eb87ed2b9857821cc asm-generic headers: add arch-specific __strnlen_user calling in uaccess.h

:::::: TO: GuanXuetao <gxt@xxxxxxxxxxxxxxx>
:::::: CC: GuanXuetao <gxt@xxxxxxxxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip