arch/loongarch/kernel/stacktrace.c:47:25: sparse: sparse: incorrect type in assignment (different address spaces)

From: kernel test robot
Date: Sat Jul 01 2023 - 06:59:16 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: a507db1d8fdc39802415e4d2ef6d1aecd67927fa
commit: 4d7bf939df08218e682f7a42952eee3bad4dceb7 LoongArch: Add USER_STACKTRACE support
date: 11 months ago
config: loongarch-randconfig-r073-20230627 (https://download.01.org/0day-ci/archive/20230701/202307011821.uIMwFiL1-lkp@xxxxxxxxx/config)
compiler: loongarch64-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230701/202307011821.uIMwFiL1-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307011821.uIMwFiL1-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> arch/loongarch/kernel/stacktrace.c:47:25: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected unsigned long [noderef] __user *user_frame_tail @@ got unsigned long * @@
arch/loongarch/kernel/stacktrace.c:47:25: sparse: expected unsigned long [noderef] __user *user_frame_tail
arch/loongarch/kernel/stacktrace.c:47:25: sparse: got unsigned long *

vim +47 arch/loongarch/kernel/stacktrace.c

39
40 static int
41 copy_stack_frame(unsigned long fp, struct stack_frame *frame)
42 {
43 int ret = 1;
44 unsigned long err;
45 unsigned long __user *user_frame_tail;
46
> 47 user_frame_tail = (unsigned long *)(fp - sizeof(struct stack_frame));
48 if (!access_ok(user_frame_tail, sizeof(*frame)))
49 return 0;
50
51 pagefault_disable();
52 err = (__copy_from_user_inatomic(frame, user_frame_tail, sizeof(*frame)));
53 if (err || (unsigned long)user_frame_tail >= frame->fp)
54 ret = 0;
55 pagefault_enable();
56
57 return ret;
58 }
59

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki