All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 3948/12912] net/core/sysctl_net_core.c:129:42: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2020-05-28 10:12 kbuild test robot
  2020-05-28 13:11 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: kbuild test robot @ 2020-05-28 10:12 UTC (permalink / raw)
  To: kbuild-all

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   b0523c7b1c9d0edcd6c0fe6d2cb558a9ad5c60a8
commit: 32927393dc1ccd60fb2bdc05b9e8e88753761469 [3948/12912] sysctl: pass kernel pointers to ->proc_handler
config: openrisc-randconfig-s032-20200528 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-240-gf0fe1cd9-dirty
        git checkout 32927393dc1ccd60fb2bdc05b9e8e88753761469
        # save the attached .config to linux build tree
        make W=1 C=1 ARCH=openrisc CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

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


sparse warnings: (new ones prefixed by >>)

>> net/core/sysctl_net_core.c:129:42: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected char const [noderef] <asn:1> *buf @@     got void *buffer @@
   net/core/sysctl_net_core.c:129:42: sparse:     expected char const [noderef] <asn:1> *buf
   net/core/sysctl_net_core.c:129:42: sparse:     got void *buffer

vim +129 net/core/sysctl_net_core.c

99bbc70741903c Willem de Bruijn  2013-05-20  116  
fe2c6338fd2c6f Joe Perches       2013-06-11  117  static int flow_limit_cpu_sysctl(struct ctl_table *table, int write,
32927393dc1ccd Christoph Hellwig 2020-04-24  118  				 void *buffer, size_t *lenp, loff_t *ppos)
99bbc70741903c Willem de Bruijn  2013-05-20  119  {
99bbc70741903c Willem de Bruijn  2013-05-20  120  	struct sd_flow_limit *cur;
99bbc70741903c Willem de Bruijn  2013-05-20  121  	struct softnet_data *sd;
99bbc70741903c Willem de Bruijn  2013-05-20  122  	cpumask_var_t mask;
99bbc70741903c Willem de Bruijn  2013-05-20  123  	int i, len, ret = 0;
99bbc70741903c Willem de Bruijn  2013-05-20  124  
99bbc70741903c Willem de Bruijn  2013-05-20  125  	if (!alloc_cpumask_var(&mask, GFP_KERNEL))
99bbc70741903c Willem de Bruijn  2013-05-20  126  		return -ENOMEM;
99bbc70741903c Willem de Bruijn  2013-05-20  127  
99bbc70741903c Willem de Bruijn  2013-05-20  128  	if (write) {
99bbc70741903c Willem de Bruijn  2013-05-20 @129  		ret = cpumask_parse_user(buffer, *lenp, mask);
99bbc70741903c Willem de Bruijn  2013-05-20  130  		if (ret)
99bbc70741903c Willem de Bruijn  2013-05-20  131  			goto done;
99bbc70741903c Willem de Bruijn  2013-05-20  132  
99bbc70741903c Willem de Bruijn  2013-05-20  133  		mutex_lock(&flow_limit_update_mutex);
99bbc70741903c Willem de Bruijn  2013-05-20  134  		len = sizeof(*cur) + netdev_flow_limit_table_len;
99bbc70741903c Willem de Bruijn  2013-05-20  135  		for_each_possible_cpu(i) {
99bbc70741903c Willem de Bruijn  2013-05-20  136  			sd = &per_cpu(softnet_data, i);
99bbc70741903c Willem de Bruijn  2013-05-20  137  			cur = rcu_dereference_protected(sd->flow_limit,
99bbc70741903c Willem de Bruijn  2013-05-20  138  				     lockdep_is_held(&flow_limit_update_mutex));
99bbc70741903c Willem de Bruijn  2013-05-20  139  			if (cur && !cpumask_test_cpu(i, mask)) {
99bbc70741903c Willem de Bruijn  2013-05-20  140  				RCU_INIT_POINTER(sd->flow_limit, NULL);
99bbc70741903c Willem de Bruijn  2013-05-20  141  				synchronize_rcu();
99bbc70741903c Willem de Bruijn  2013-05-20  142  				kfree(cur);
99bbc70741903c Willem de Bruijn  2013-05-20  143  			} else if (!cur && cpumask_test_cpu(i, mask)) {
5b59d467ad9ff9 Eric Dumazet      2013-12-18  144  				cur = kzalloc_node(len, GFP_KERNEL,
5b59d467ad9ff9 Eric Dumazet      2013-12-18  145  						   cpu_to_node(i));
99bbc70741903c Willem de Bruijn  2013-05-20  146  				if (!cur) {
99bbc70741903c Willem de Bruijn  2013-05-20  147  					/* not unwinding previous changes */
99bbc70741903c Willem de Bruijn  2013-05-20  148  					ret = -ENOMEM;
99bbc70741903c Willem de Bruijn  2013-05-20  149  					goto write_unlock;
99bbc70741903c Willem de Bruijn  2013-05-20  150  				}
99bbc70741903c Willem de Bruijn  2013-05-20  151  				cur->num_buckets = netdev_flow_limit_table_len;
99bbc70741903c Willem de Bruijn  2013-05-20  152  				rcu_assign_pointer(sd->flow_limit, cur);
99bbc70741903c Willem de Bruijn  2013-05-20  153  			}
99bbc70741903c Willem de Bruijn  2013-05-20  154  		}
99bbc70741903c Willem de Bruijn  2013-05-20  155  write_unlock:
99bbc70741903c Willem de Bruijn  2013-05-20  156  		mutex_unlock(&flow_limit_update_mutex);
99bbc70741903c Willem de Bruijn  2013-05-20  157  	} else {
5f121b9a83b499 Willem de Bruijn  2013-06-13  158  		char kbuf[128];
5f121b9a83b499 Willem de Bruijn  2013-06-13  159  
99bbc70741903c Willem de Bruijn  2013-05-20  160  		if (*ppos || !*lenp) {
99bbc70741903c Willem de Bruijn  2013-05-20  161  			*lenp = 0;
99bbc70741903c Willem de Bruijn  2013-05-20  162  			goto done;
99bbc70741903c Willem de Bruijn  2013-05-20  163  		}
99bbc70741903c Willem de Bruijn  2013-05-20  164  
99bbc70741903c Willem de Bruijn  2013-05-20  165  		cpumask_clear(mask);
99bbc70741903c Willem de Bruijn  2013-05-20  166  		rcu_read_lock();
99bbc70741903c Willem de Bruijn  2013-05-20  167  		for_each_possible_cpu(i) {
99bbc70741903c Willem de Bruijn  2013-05-20  168  			sd = &per_cpu(softnet_data, i);
99bbc70741903c Willem de Bruijn  2013-05-20  169  			if (rcu_dereference(sd->flow_limit))
99bbc70741903c Willem de Bruijn  2013-05-20  170  				cpumask_set_cpu(i, mask);
99bbc70741903c Willem de Bruijn  2013-05-20  171  		}
99bbc70741903c Willem de Bruijn  2013-05-20  172  		rcu_read_unlock();
99bbc70741903c Willem de Bruijn  2013-05-20  173  
5f121b9a83b499 Willem de Bruijn  2013-06-13  174  		len = min(sizeof(kbuf) - 1, *lenp);
f09068276c5cbe Tejun Heo         2015-02-13  175  		len = scnprintf(kbuf, len, "%*pb", cpumask_pr_args(mask));
5f121b9a83b499 Willem de Bruijn  2013-06-13  176  		if (!len) {
5f121b9a83b499 Willem de Bruijn  2013-06-13  177  			*lenp = 0;
5f121b9a83b499 Willem de Bruijn  2013-06-13  178  			goto done;
5f121b9a83b499 Willem de Bruijn  2013-06-13  179  		}
5f121b9a83b499 Willem de Bruijn  2013-06-13  180  		if (len < *lenp)
5f121b9a83b499 Willem de Bruijn  2013-06-13  181  			kbuf[len++] = '\n';
32927393dc1ccd Christoph Hellwig 2020-04-24  182  		memcpy(buffer, kbuf, len);
5f121b9a83b499 Willem de Bruijn  2013-06-13  183  		*lenp = len;
5f121b9a83b499 Willem de Bruijn  2013-06-13  184  		*ppos += len;
99bbc70741903c Willem de Bruijn  2013-05-20  185  	}
99bbc70741903c Willem de Bruijn  2013-05-20  186  
99bbc70741903c Willem de Bruijn  2013-05-20  187  done:
99bbc70741903c Willem de Bruijn  2013-05-20  188  	free_cpumask_var(mask);
99bbc70741903c Willem de Bruijn  2013-05-20  189  	return ret;
99bbc70741903c Willem de Bruijn  2013-05-20  190  }
99bbc70741903c Willem de Bruijn  2013-05-20  191  

:::::: The code@line 129 was first introduced by commit
:::::: 99bbc70741903c063b3ccad90a3e06fc55df9245 rps: selective flow shedding during softnet overflow

:::::: TO: Willem de Bruijn <willemb@google.com>
:::::: CC: David S. Miller <davem@davemloft.net>

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

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

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

* Re: [linux-next:master 3948/12912] net/core/sysctl_net_core.c:129:42: sparse: sparse: incorrect type in argument 1 (different address spaces)
  2020-05-28 10:12 [linux-next:master 3948/12912] net/core/sysctl_net_core.c:129:42: sparse: sparse: incorrect type in argument 1 (different address spaces) kbuild test robot
@ 2020-05-28 13:11 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2020-05-28 13:11 UTC (permalink / raw)
  To: kbuild-all

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

Fix below:

---
>From 9fae1037a055b2d4c525e1bf36225641b0217a8d Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Thu, 28 May 2020 15:05:46 +0200
Subject: net/sysctl: use cpumask_parse in flow_limit_cpu_sysctl

cpumask_parse_user works on __user pointers, so this is wrong now.

Fixes: 32927393dc1c ("sysctl: pass kernel pointers to ->proc_handler")
Reported-by: build test robot <lkp@intel.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 net/core/sysctl_net_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index b109cc8a6dd848..f93f8ace6c5619 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -128,7 +128,7 @@ static int flow_limit_cpu_sysctl(struct ctl_table *table, int write,
 		return -ENOMEM;
 
 	if (write) {
-		ret = cpumask_parse_user(buffer, *lenp, mask);
+		ret = cpumask_parse(buffer, mask);
 		if (ret)
 			goto done;
 
-- 
2.26.2

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

end of thread, other threads:[~2020-05-28 13:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 10:12 [linux-next:master 3948/12912] net/core/sysctl_net_core.c:129:42: sparse: sparse: incorrect type in argument 1 (different address spaces) kbuild test robot
2020-05-28 13:11 ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.