mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: "Clément Léger" <cleger@rivosinc.com>
Cc: oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Alexandre Ghiti <alexghiti@rivosinc.com>
Subject: mm/maccess.c:41:17: sparse: sparse: incorrect type in argument 2 (different address spaces)
Date: Sat, 7 Jun 2025 19:43:38 +0800	[thread overview]
Message-ID: <202506071929.Ane6iZuz-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   bdc7f8c5adad50dad2ec762e317f8b212f5782ac
commit: ca1a66cdd685030738cf077e3955fdedfe39fbb9 riscv: uaccess: do not do misaligned accesses in get/put_user()
date:   2 days ago
config: riscv-randconfig-r133-20250607 (https://download.01.org/0day-ci/archive/20250607/202506071929.Ane6iZuz-lkp@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 12.4.0
reproduce: (https://download.01.org/0day-ci/archive/20250607/202506071929.Ane6iZuz-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506071929.Ane6iZuz-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> mm/maccess.c:41:17: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got unsigned long long [usertype] * @@
   mm/maccess.c:41:17: sparse:     expected void const [noderef] __user *from
   mm/maccess.c:41:17: sparse:     got unsigned long long [usertype] *
>> mm/maccess.c:43:17: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got unsigned int [usertype] * @@
   mm/maccess.c:43:17: sparse:     expected void const [noderef] __user *from
   mm/maccess.c:43:17: sparse:     got unsigned int [usertype] *
>> mm/maccess.c:45:17: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got unsigned short [usertype] * @@
   mm/maccess.c:45:17: sparse:     expected void const [noderef] __user *from
   mm/maccess.c:45:17: sparse:     got unsigned short [usertype] *
>> mm/maccess.c:46:9: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got unsigned char [usertype] * @@
   mm/maccess.c:46:9: sparse:     expected void const [noderef] __user *from
   mm/maccess.c:46:9: sparse:     got unsigned char [usertype] *
>> mm/maccess.c:73:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got unsigned long long [usertype] * @@
   mm/maccess.c:73:17: sparse:     expected void [noderef] __user *to
   mm/maccess.c:73:17: sparse:     got unsigned long long [usertype] *
>> mm/maccess.c:75:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got unsigned int [usertype] * @@
   mm/maccess.c:75:17: sparse:     expected void [noderef] __user *to
   mm/maccess.c:75:17: sparse:     got unsigned int [usertype] *
>> mm/maccess.c:77:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got unsigned short [usertype] * @@
   mm/maccess.c:77:17: sparse:     expected void [noderef] __user *to
   mm/maccess.c:77:17: sparse:     got unsigned short [usertype] *
>> mm/maccess.c:78:9: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got unsigned char [usertype] * @@
   mm/maccess.c:78:9: sparse:     expected void [noderef] __user *to
   mm/maccess.c:78:9: sparse:     got unsigned char [usertype] *
   mm/maccess.c:98:17: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got unsigned char [usertype] * @@
   mm/maccess.c:98:17: sparse:     expected void const [noderef] __user *from
   mm/maccess.c:98:17: sparse:     got unsigned char [usertype] *

vim +41 mm/maccess.c

eab0c6089b6897 Christoph Hellwig    2020-06-08  15  
e4137f08816bbf Sabyrzhan Tasbolatov 2024-10-11  16  /*
e4137f08816bbf Sabyrzhan Tasbolatov 2024-10-11  17   * The below only uses kmsan_check_memory() to ensure uninitialized kernel
e4137f08816bbf Sabyrzhan Tasbolatov 2024-10-11  18   * memory isn't leaked.
e4137f08816bbf Sabyrzhan Tasbolatov 2024-10-11  19   */
fe557319aa06c2 Christoph Hellwig    2020-06-17  20  #define copy_from_kernel_nofault_loop(dst, src, len, type, err_label)	\
b58294ead14cde Christoph Hellwig    2020-06-08  21  	while (len >= sizeof(type)) {					\
b58294ead14cde Christoph Hellwig    2020-06-08  22  		__get_kernel_nofault(dst, src, type, err_label);	\
e4137f08816bbf Sabyrzhan Tasbolatov 2024-10-11  23  		kmsan_check_memory(src, sizeof(type));			\
b58294ead14cde Christoph Hellwig    2020-06-08  24  		dst += sizeof(type);					\
b58294ead14cde Christoph Hellwig    2020-06-08  25  		src += sizeof(type);					\
b58294ead14cde Christoph Hellwig    2020-06-08  26  		len -= sizeof(type);					\
b58294ead14cde Christoph Hellwig    2020-06-08  27  	}
b58294ead14cde Christoph Hellwig    2020-06-08  28  
fe557319aa06c2 Christoph Hellwig    2020-06-17  29  long copy_from_kernel_nofault(void *dst, const void *src, size_t size)
b58294ead14cde Christoph Hellwig    2020-06-08  30  {
2423de2e6f4d86 Arnd Bergmann        2021-08-11  31  	unsigned long align = 0;
2423de2e6f4d86 Arnd Bergmann        2021-08-11  32  
2423de2e6f4d86 Arnd Bergmann        2021-08-11  33  	if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
2423de2e6f4d86 Arnd Bergmann        2021-08-11  34  		align = (unsigned long)dst | (unsigned long)src;
2423de2e6f4d86 Arnd Bergmann        2021-08-11  35  
fe557319aa06c2 Christoph Hellwig    2020-06-17  36  	if (!copy_from_kernel_nofault_allowed(src, size))
2a71e81d321987 Christoph Hellwig    2020-06-08  37  		return -ERANGE;
b58294ead14cde Christoph Hellwig    2020-06-08  38  
b58294ead14cde Christoph Hellwig    2020-06-08  39  	pagefault_disable();
2423de2e6f4d86 Arnd Bergmann        2021-08-11  40  	if (!(align & 7))
fe557319aa06c2 Christoph Hellwig    2020-06-17 @41  		copy_from_kernel_nofault_loop(dst, src, size, u64, Efault);
2423de2e6f4d86 Arnd Bergmann        2021-08-11  42  	if (!(align & 3))
fe557319aa06c2 Christoph Hellwig    2020-06-17 @43  		copy_from_kernel_nofault_loop(dst, src, size, u32, Efault);
2423de2e6f4d86 Arnd Bergmann        2021-08-11  44  	if (!(align & 1))
fe557319aa06c2 Christoph Hellwig    2020-06-17 @45  		copy_from_kernel_nofault_loop(dst, src, size, u16, Efault);
fe557319aa06c2 Christoph Hellwig    2020-06-17 @46  	copy_from_kernel_nofault_loop(dst, src, size, u8, Efault);
b58294ead14cde Christoph Hellwig    2020-06-08  47  	pagefault_enable();
b58294ead14cde Christoph Hellwig    2020-06-08  48  	return 0;
b58294ead14cde Christoph Hellwig    2020-06-08  49  Efault:
b58294ead14cde Christoph Hellwig    2020-06-08  50  	pagefault_enable();
b58294ead14cde Christoph Hellwig    2020-06-08  51  	return -EFAULT;
b58294ead14cde Christoph Hellwig    2020-06-08  52  }
fe557319aa06c2 Christoph Hellwig    2020-06-17  53  EXPORT_SYMBOL_GPL(copy_from_kernel_nofault);
b58294ead14cde Christoph Hellwig    2020-06-08  54  
fe557319aa06c2 Christoph Hellwig    2020-06-17  55  #define copy_to_kernel_nofault_loop(dst, src, len, type, err_label)	\
b58294ead14cde Christoph Hellwig    2020-06-08  56  	while (len >= sizeof(type)) {					\
b58294ead14cde Christoph Hellwig    2020-06-08  57  		__put_kernel_nofault(dst, src, type, err_label);	\
e4137f08816bbf Sabyrzhan Tasbolatov 2024-10-11  58  		instrument_write(dst, sizeof(type));			\
b58294ead14cde Christoph Hellwig    2020-06-08  59  		dst += sizeof(type);					\
b58294ead14cde Christoph Hellwig    2020-06-08  60  		src += sizeof(type);					\
b58294ead14cde Christoph Hellwig    2020-06-08  61  		len -= sizeof(type);					\
b58294ead14cde Christoph Hellwig    2020-06-08  62  	}
b58294ead14cde Christoph Hellwig    2020-06-08  63  
fe557319aa06c2 Christoph Hellwig    2020-06-17  64  long copy_to_kernel_nofault(void *dst, const void *src, size_t size)
b58294ead14cde Christoph Hellwig    2020-06-08  65  {
2423de2e6f4d86 Arnd Bergmann        2021-08-11  66  	unsigned long align = 0;
2423de2e6f4d86 Arnd Bergmann        2021-08-11  67  
2423de2e6f4d86 Arnd Bergmann        2021-08-11  68  	if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS))
2423de2e6f4d86 Arnd Bergmann        2021-08-11  69  		align = (unsigned long)dst | (unsigned long)src;
2423de2e6f4d86 Arnd Bergmann        2021-08-11  70  
b58294ead14cde Christoph Hellwig    2020-06-08  71  	pagefault_disable();
2423de2e6f4d86 Arnd Bergmann        2021-08-11  72  	if (!(align & 7))
fe557319aa06c2 Christoph Hellwig    2020-06-17 @73  		copy_to_kernel_nofault_loop(dst, src, size, u64, Efault);
2423de2e6f4d86 Arnd Bergmann        2021-08-11  74  	if (!(align & 3))
fe557319aa06c2 Christoph Hellwig    2020-06-17 @75  		copy_to_kernel_nofault_loop(dst, src, size, u32, Efault);
2423de2e6f4d86 Arnd Bergmann        2021-08-11  76  	if (!(align & 1))
fe557319aa06c2 Christoph Hellwig    2020-06-17 @77  		copy_to_kernel_nofault_loop(dst, src, size, u16, Efault);
fe557319aa06c2 Christoph Hellwig    2020-06-17 @78  	copy_to_kernel_nofault_loop(dst, src, size, u8, Efault);
b58294ead14cde Christoph Hellwig    2020-06-08  79  	pagefault_enable();
b58294ead14cde Christoph Hellwig    2020-06-08  80  	return 0;
b58294ead14cde Christoph Hellwig    2020-06-08  81  Efault:
b58294ead14cde Christoph Hellwig    2020-06-08  82  	pagefault_enable();
b58294ead14cde Christoph Hellwig    2020-06-08  83  	return -EFAULT;
b58294ead14cde Christoph Hellwig    2020-06-08  84  }
ca79a00bb9a899 Sabyrzhan Tasbolatov 2024-10-16  85  EXPORT_SYMBOL_GPL(copy_to_kernel_nofault);
b58294ead14cde Christoph Hellwig    2020-06-08  86  

:::::: The code at line 41 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
https://github.com/intel/lkp-tests/wiki

             reply	other threads:[~2025-06-07 11:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-07 11:43 kernel test robot [this message]
2025-07-14 12:48 kernel test robot
2025-08-16  9:28 kernel test robot
2025-08-16 16:19 ` Al Viro
2025-08-16 16:54   ` Palmer Dabbelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202506071929.Ane6iZuz-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=alexghiti@rivosinc.com \
    --cc=cleger@rivosinc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=palmer@dabbelt.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®