[hch-misc:m68k-set_fs 5/6] mm/maccess.c:31:9: sparse: sparse: incorrect type in initializer (different address spaces)

kernel test robot
2021-07-07T21:09:25Z

[-- Attachment #1: Type: text/plain, Size: 8531 bytes --]

tree: git://git.infradead.org/users/hch/misc.git m68k-set_fs
head: dc7590aca76df8c1ead0ebf59e3787d5555779d6
commit: bd01d8a7268b406331c39707183b2c42626eff8e [5/6] m68k: provide __{get,put}_kernel_nofault
config: m68k-randconfig-s031-20210707 (attached as .config)
compiler: m68k-linux-gcc (GCC) 9.3.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-341-g8af24329-dirty
git remote add hch-misc git://git.infradead.org/users/hch/misc.git
git fetch --no-tags hch-misc m68k-set_fs
git checkout bd01d8a7268b406331c39707183b2c42626eff8e
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=m68k

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

sparse warnings: (new ones prefixed by >>)
>> mm/maccess.c:31:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__gu_ptr @@ got unsigned long long [usertype] *__gk_src @@
mm/maccess.c:31:9: sparse: expected void const [noderef] __user *__gu_ptr
mm/maccess.c:31:9: sparse: got unsigned long long [usertype] *__gk_src
>> mm/maccess.c:32:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__gu_ptr @@ got unsigned int [usertype] *__gk_src @@
mm/maccess.c:32:9: sparse: expected void const [noderef] __user *__gu_ptr
mm/maccess.c:32:9: sparse: got unsigned int [usertype] *__gk_src
>> mm/maccess.c:33:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__gu_ptr @@ got unsigned short [usertype] *__gk_src @@
mm/maccess.c:33:9: sparse: expected void const [noderef] __user *__gu_ptr
mm/maccess.c:33:9: sparse: got unsigned short [usertype] *__gk_src
>> mm/maccess.c:34:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__gu_ptr @@ got unsigned char [usertype] *__gk_src @@
mm/maccess.c:34:9: sparse: expected void const [noderef] __user *__gu_ptr
mm/maccess.c:34:9: sparse: got unsigned char [usertype] *__gk_src
>> mm/maccess.c:54:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__pu_ptr @@ got unsigned long long [usertype] *__pk_dst @@
mm/maccess.c:54:9: sparse: expected void const [noderef] __user *__pu_ptr
mm/maccess.c:54:9: sparse: got unsigned long long [usertype] *__pk_dst
>> mm/maccess.c:55:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__pu_ptr @@ got unsigned int [usertype] *__pk_dst @@
mm/maccess.c:55:9: sparse: expected void const [noderef] __user *__pu_ptr
mm/maccess.c:55:9: sparse: got unsigned int [usertype] *__pk_dst
>> mm/maccess.c:56:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__pu_ptr @@ got unsigned short [usertype] *__pk_dst @@
mm/maccess.c:56:9: sparse: expected void const [noderef] __user *__pu_ptr
mm/maccess.c:56:9: sparse: got unsigned short [usertype] *__pk_dst
>> mm/maccess.c:57:9: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__pu_ptr @@ got unsigned char [usertype] *__pk_dst @@
mm/maccess.c:57:9: sparse: expected void const [noderef] __user *__pu_ptr
mm/maccess.c:57:9: sparse: got unsigned char [usertype] *__pk_dst
mm/maccess.c:76:17: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __user *__gu_ptr @@ got unsigned char [usertype] *__gk_src @@
mm/maccess.c:76:17: sparse: expected void const [noderef] __user *__gu_ptr
mm/maccess.c:76:17: sparse: got unsigned char [usertype] *__gk_src

vim +31 mm/maccess.c

b58294ead14cde Christoph Hellwig 2020-06-08 16
fe557319aa06c2 Christoph Hellwig 2020-06-17 17 #define copy_from_kernel_nofault_loop(dst, src, len, type, err_label) \
b58294ead14cde Christoph Hellwig 2020-06-08 18 while (len >= sizeof(type)) { \
b58294ead14cde Christoph Hellwig 2020-06-08 19 __get_kernel_nofault(dst, src, type, err_label); \
b58294ead14cde Christoph Hellwig 2020-06-08 20 dst += sizeof(type); \
b58294ead14cde Christoph Hellwig 2020-06-08 21 src += sizeof(type); \
b58294ead14cde Christoph Hellwig 2020-06-08 22 len -= sizeof(type); \
b58294ead14cde Christoph Hellwig 2020-06-08 23 }
b58294ead14cde Christoph Hellwig 2020-06-08 24
fe557319aa06c2 Christoph Hellwig 2020-06-17 25 long copy_from_kernel_nofault(void *dst, const void *src, size_t size)
b58294ead14cde Christoph Hellwig 2020-06-08 26 {
fe557319aa06c2 Christoph Hellwig 2020-06-17 27 if (!copy_from_kernel_nofault_allowed(src, size))
2a71e81d321987 Christoph Hellwig 2020-06-08 28 return -ERANGE;
b58294ead14cde Christoph Hellwig 2020-06-08 29
b58294ead14cde Christoph Hellwig 2020-06-08 30 pagefault_disable();
fe557319aa06c2 Christoph Hellwig 2020-06-17 @31 copy_from_kernel_nofault_loop(dst, src, size, u64, Efault);
fe557319aa06c2 Christoph Hellwig 2020-06-17 @32 copy_from_kernel_nofault_loop(dst, src, size, u32, Efault);
fe557319aa06c2 Christoph Hellwig 2020-06-17 @33 copy_from_kernel_nofault_loop(dst, src, size, u16, Efault);
fe557319aa06c2 Christoph Hellwig 2020-06-17 @34 copy_from_kernel_nofault_loop(dst, src, size, u8, Efault);
b58294ead14cde Christoph Hellwig 2020-06-08 35 pagefault_enable();
b58294ead14cde Christoph Hellwig 2020-06-08 36 return 0;
b58294ead14cde Christoph Hellwig 2020-06-08 37 Efault:
b58294ead14cde Christoph Hellwig 2020-06-08 38 pagefault_enable();
b58294ead14cde Christoph Hellwig 2020-06-08 39 return -EFAULT;
b58294ead14cde Christoph Hellwig 2020-06-08 40 }
fe557319aa06c2 Christoph Hellwig 2020-06-17 41 EXPORT_SYMBOL_GPL(copy_from_kernel_nofault);
b58294ead14cde Christoph Hellwig 2020-06-08 42
fe557319aa06c2 Christoph Hellwig 2020-06-17 43 #define copy_to_kernel_nofault_loop(dst, src, len, type, err_label) \
b58294ead14cde Christoph Hellwig 2020-06-08 44 while (len >= sizeof(type)) { \
b58294ead14cde Christoph Hellwig 2020-06-08 45 __put_kernel_nofault(dst, src, type, err_label); \
b58294ead14cde Christoph Hellwig 2020-06-08 46 dst += sizeof(type); \
b58294ead14cde Christoph Hellwig 2020-06-08 47 src += sizeof(type); \
b58294ead14cde Christoph Hellwig 2020-06-08 48 len -= sizeof(type); \
b58294ead14cde Christoph Hellwig 2020-06-08 49 }
b58294ead14cde Christoph Hellwig 2020-06-08 50
fe557319aa06c2 Christoph Hellwig 2020-06-17 51 long copy_to_kernel_nofault(void *dst, const void *src, size_t size)
b58294ead14cde Christoph Hellwig 2020-06-08 52 {
b58294ead14cde Christoph Hellwig 2020-06-08 53 pagefault_disable();
fe557319aa06c2 Christoph Hellwig 2020-06-17 @54 copy_to_kernel_nofault_loop(dst, src, size, u64, Efault);
fe557319aa06c2 Christoph Hellwig 2020-06-17 @55 copy_to_kernel_nofault_loop(dst, src, size, u32, Efault);
fe557319aa06c2 Christoph Hellwig 2020-06-17 @56 copy_to_kernel_nofault_loop(dst, src, size, u16, Efault);
fe557319aa06c2 Christoph Hellwig 2020-06-17 @57 copy_to_kernel_nofault_loop(dst, src, size, u8, Efault);
b58294ead14cde Christoph Hellwig 2020-06-08 58 pagefault_enable();
b58294ead14cde Christoph Hellwig 2020-06-08 59 return 0;
b58294ead14cde Christoph Hellwig 2020-06-08 60 Efault:
b58294ead14cde Christoph Hellwig 2020-06-08 61 pagefault_enable();
b58294ead14cde Christoph Hellwig 2020-06-08 62 return -EFAULT;
b58294ead14cde Christoph Hellwig 2020-06-08 63 }
b58294ead14cde Christoph Hellwig 2020-06-08 64

:::::: The code at line 31 was first introduced by commit
:::::: fe557319aa06c23cffc9346000f119547e0f289a maccess: rename probe_kernel_{read,write} to copy_{from,to}_kernel_nofault

:::::: TO: Christoph Hellwig <hch@lst.de>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 22748 bytes --]