linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* drivers/infiniband/core/uverbs_std_types_device.c:299:29: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2021-02-01 17:40 kernel test robot
  2021-02-05 16:51 ` Jason Gunthorpe
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2021-02-01 17:40 UTC (permalink / raw)
  To: Avihai Horon; +Cc: kbuild-all, linux-kernel, Jason Gunthorpe, Leon Romanovsky

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   1048ba83fb1c00cd24172e23e8263972f6b5d9ac
commit: 9f85cbe50aa044a46f0a22fda323fa27b80c82da RDMA/uverbs: Expose the new GID query API to user space
date:   4 months ago
config: sh-randconfig-s031-20210201 (attached as .config)
compiler: sh4-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-215-g0fb77bb6-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9f85cbe50aa044a46f0a22fda323fa27b80c82da
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 9f85cbe50aa044a46f0a22fda323fa27b80c82da
        # 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=sh 

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 >>)"
>> drivers/infiniband/core/uverbs_std_types_device.c:299:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void *addr @@     got void [noderef] __user *__cl_addr @@
   drivers/infiniband/core/uverbs_std_types_device.c:299:29: sparse:     expected void *addr
   drivers/infiniband/core/uverbs_std_types_device.c:299:29: sparse:     got void [noderef] __user *__cl_addr
   drivers/infiniband/core/uverbs_std_types_device.c:115:15: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
   drivers/infiniband/core/uverbs_std_types_device.c:195:15: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)

vim +299 drivers/infiniband/core/uverbs_std_types_device.c

   270	
   271	static int copy_gid_entries_to_user(struct uverbs_attr_bundle *attrs,
   272					    struct ib_uverbs_gid_entry *entries,
   273					    size_t num_entries, size_t user_entry_size)
   274	{
   275		const struct uverbs_attr *attr;
   276		void __user *user_entries;
   277		size_t copy_len;
   278		int ret;
   279		int i;
   280	
   281		if (user_entry_size == sizeof(*entries)) {
   282			ret = uverbs_copy_to(attrs,
   283					     UVERBS_ATTR_QUERY_GID_TABLE_RESP_ENTRIES,
   284					     entries, sizeof(*entries) * num_entries);
   285			return ret;
   286		}
   287	
   288		copy_len = min_t(size_t, user_entry_size, sizeof(*entries));
   289		attr = uverbs_attr_get(attrs, UVERBS_ATTR_QUERY_GID_TABLE_RESP_ENTRIES);
   290		if (IS_ERR(attr))
   291			return PTR_ERR(attr);
   292	
   293		user_entries = u64_to_user_ptr(attr->ptr_attr.data);
   294		for (i = 0; i < num_entries; i++) {
   295			if (copy_to_user(user_entries, entries, copy_len))
   296				return -EFAULT;
   297	
   298			if (user_entry_size > sizeof(*entries)) {
 > 299				if (clear_user(user_entries + sizeof(*entries),
   300					       user_entry_size - sizeof(*entries)))
   301					return -EFAULT;
   302			}
   303	
   304			entries++;
   305			user_entries += user_entry_size;
   306		}
   307	
   308		return uverbs_output_written(attrs,
   309					     UVERBS_ATTR_QUERY_GID_TABLE_RESP_ENTRIES);
   310	}
   311	

---
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: 30808 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: drivers/infiniband/core/uverbs_std_types_device.c:299:29: sparse: sparse: incorrect type in argument 1 (different address spaces)
  2021-02-01 17:40 drivers/infiniband/core/uverbs_std_types_device.c:299:29: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot
@ 2021-02-05 16:51 ` Jason Gunthorpe
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2021-02-05 16:51 UTC (permalink / raw)
  To: kernel test robot
  Cc: Avihai Horon, kbuild-all, linux-kernel, Leon Romanovsky,
	Yoshinori Sato, Rich Felker, linux-sh

On Tue, Feb 02, 2021 at 01:40:33AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   1048ba83fb1c00cd24172e23e8263972f6b5d9ac
> commit: 9f85cbe50aa044a46f0a22fda323fa27b80c82da RDMA/uverbs: Expose the new GID query API to user space
> date:   4 months ago
> config: sh-randconfig-s031-20210201 (attached as .config)
> compiler: sh4-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-215-g0fb77bb6-dirty
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9f85cbe50aa044a46f0a22fda323fa27b80c82da
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout 9f85cbe50aa044a46f0a22fda323fa27b80c82da
>         # 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=sh 
> 
> 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 >>)"
> >> drivers/infiniband/core/uverbs_std_types_device.c:299:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void *addr @@     got void [noderef] __user *__cl_addr @@
>    drivers/infiniband/core/uverbs_std_types_device.c:299:29: sparse:     expected void *addr
>    drivers/infiniband/core/uverbs_std_types_device.c:299:29: sparse:     got void [noderef] __user *__cl_addr
>    drivers/infiniband/core/uverbs_std_types_device.c:115:15: sparse: sparse: cast truncates bits from constant value (ffff0001 becomes 1)
>    drivers/infiniband/core/uverbs_std_types_device.c:195:15: sparse: sparse: cast truncates bits from constant value (ffffff01 becomes 1)

This is a bug in  arch/sh/include/asm/page.h:

__kernel_size_t __clear_user(void *addr, __kernel_size_t size);

#define clear_user(addr,n)						\
...
		__cl_size = __clear_user(__cl_addr, __cl_size);		\

__clear_user() needs to take a void __user *addr

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-05 20:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 17:40 drivers/infiniband/core/uverbs_std_types_device.c:299:29: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot
2021-02-05 16:51 ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).