All of lore.kernel.org
 help / color / mirror / Atom feed
* [bpf-next:master 209/265] kernel/trace/fprobe.c:201:14: sparse: sparse: incorrect type in assignment (different address spaces)
@ 2022-03-22  7:22 kernel test robot
  2022-03-22 11:44   ` Masami Hiramatsu
  0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2022-03-22  7:22 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: kbuild-all, linux-kernel, Alexei Starovoitov, Steven Rostedt (Google)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
head:   f97b8b9bd630fb76c0e9e11cbf390e3d64a144d7
commit: 5b0ab78998e32564a011b14c4c7f9c81e2d42b9d [209/265] fprobe: Add exit_handler support
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20220322/202203221549.JQIr40CT-lkp@intel.com/config)
compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=5b0ab78998e32564a011b14c4c7f9c81e2d42b9d
        git remote add bpf-next https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git
        git fetch --no-tags bpf-next master
        git checkout 5b0ab78998e32564a011b14c4c7f9c81e2d42b9d
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash kernel/trace/ samples/

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 >>)
>> kernel/trace/rethook.c:68:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
>> kernel/trace/rethook.c:68:9: sparse:    void ( [noderef] __rcu * )( ... )
>> kernel/trace/rethook.c:68:9: sparse:    void ( * )( ... )
--
>> kernel/trace/fprobe.c:201:14: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct ftrace_hash *hash @@     got struct ftrace_hash [noderef] __rcu *filter_hash @@
   kernel/trace/fprobe.c:201:14: sparse:     expected struct ftrace_hash *hash
   kernel/trace/fprobe.c:201:14: sparse:     got struct ftrace_hash [noderef] __rcu *filter_hash

vim +201 kernel/trace/fprobe.c

   158	
   159	/**
   160	 * register_fprobe() - Register fprobe to ftrace by pattern.
   161	 * @fp: A fprobe data structure to be registered.
   162	 * @filter: A wildcard pattern of probed symbols.
   163	 * @notfilter: A wildcard pattern of NOT probed symbols.
   164	 *
   165	 * Register @fp to ftrace for enabling the probe on the symbols matched to @filter.
   166	 * If @notfilter is not NULL, the symbols matched the @notfilter are not probed.
   167	 *
   168	 * Return 0 if @fp is registered successfully, -errno if not.
   169	 */
   170	int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter)
   171	{
   172		struct ftrace_hash *hash;
   173		unsigned char *str;
   174		int ret, len;
   175	
   176		if (!fp || !filter)
   177			return -EINVAL;
   178	
   179		fprobe_init(fp);
   180	
   181		len = strlen(filter);
   182		str = kstrdup(filter, GFP_KERNEL);
   183		ret = ftrace_set_filter(&fp->ops, str, len, 0);
   184		kfree(str);
   185		if (ret)
   186			return ret;
   187	
   188		if (notfilter) {
   189			len = strlen(notfilter);
   190			str = kstrdup(notfilter, GFP_KERNEL);
   191			ret = ftrace_set_notrace(&fp->ops, str, len, 0);
   192			kfree(str);
   193			if (ret)
   194				goto out;
   195		}
   196	
   197		/* TODO:
   198		 * correctly calculate the total number of filtered symbols
   199		 * from both filter and notfilter.
   200		 */
 > 201		hash = fp->ops.local_hash.filter_hash;
   202		if (WARN_ON_ONCE(!hash))
   203			goto out;
   204	
   205		ret = fprobe_init_rethook(fp, (int)hash->count);
   206		if (!ret)
   207			ret = register_ftrace_function(&fp->ops);
   208	
   209	out:
   210		if (ret)
   211			fprobe_fail_cleanup(fp);
   212		return ret;
   213	}
   214	EXPORT_SYMBOL_GPL(register_fprobe);
   215	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

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

* Re: [bpf-next:master 209/265] kernel/trace/fprobe.c:201:14: sparse: sparse: incorrect type in assignment (different address spaces)
  2022-03-22  7:22 [bpf-next:master 209/265] kernel/trace/fprobe.c:201:14: sparse: sparse: incorrect type in assignment (different address spaces) kernel test robot
@ 2022-03-22 11:44   ` Masami Hiramatsu
  0 siblings, 0 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2022-03-22 11:44 UTC (permalink / raw)
  To: kernel test robot
  Cc: kbuild-all, linux-kernel, Alexei Starovoitov, Steven Rostedt (Google)

On Tue, 22 Mar 2022 15:22:30 +0800
kernel test robot <lkp@intel.com> wrote:

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
> head:   f97b8b9bd630fb76c0e9e11cbf390e3d64a144d7
> commit: 5b0ab78998e32564a011b14c4c7f9c81e2d42b9d [209/265] fprobe: Add exit_handler support
> config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20220322/202203221549.JQIr40CT-lkp@intel.com/config)
> compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
> reproduce:
>         # apt-get install sparse
>         # sparse version: v0.6.4-dirty
>         # https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=5b0ab78998e32564a011b14c4c7f9c81e2d42b9d
>         git remote add bpf-next https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git
>         git fetch --no-tags bpf-next master
>         git checkout 5b0ab78998e32564a011b14c4c7f9c81e2d42b9d
>         # save the config file to linux build tree
>         mkdir build_dir
>         make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash kernel/trace/ samples/
> 
> 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 >>)
> >> kernel/trace/rethook.c:68:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
> >> kernel/trace/rethook.c:68:9: sparse:    void ( [noderef] __rcu * )( ... )
> >> kernel/trace/rethook.c:68:9: sparse:    void ( * )( ... )
> --
> >> kernel/trace/fprobe.c:201:14: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct ftrace_hash *hash @@     got struct ftrace_hash [noderef] __rcu *filter_hash @@
>    kernel/trace/fprobe.c:201:14: sparse:     expected struct ftrace_hash *hash
>    kernel/trace/fprobe.c:201:14: sparse:     got struct ftrace_hash [noderef] __rcu *filter_hash
> 
> vim +201 kernel/trace/fprobe.c
> 
>    158	
>    159	/**
>    160	 * register_fprobe() - Register fprobe to ftrace by pattern.
>    161	 * @fp: A fprobe data structure to be registered.
>    162	 * @filter: A wildcard pattern of probed symbols.
>    163	 * @notfilter: A wildcard pattern of NOT probed symbols.
>    164	 *
>    165	 * Register @fp to ftrace for enabling the probe on the symbols matched to @filter.
>    166	 * If @notfilter is not NULL, the symbols matched the @notfilter are not probed.
>    167	 *
>    168	 * Return 0 if @fp is registered successfully, -errno if not.
>    169	 */
>    170	int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter)
>    171	{
>    172		struct ftrace_hash *hash;
>    173		unsigned char *str;
>    174		int ret, len;
>    175	
>    176		if (!fp || !filter)
>    177			return -EINVAL;
>    178	
>    179		fprobe_init(fp);
>    180	
>    181		len = strlen(filter);
>    182		str = kstrdup(filter, GFP_KERNEL);
>    183		ret = ftrace_set_filter(&fp->ops, str, len, 0);
>    184		kfree(str);
>    185		if (ret)
>    186			return ret;
>    187	
>    188		if (notfilter) {
>    189			len = strlen(notfilter);
>    190			str = kstrdup(notfilter, GFP_KERNEL);
>    191			ret = ftrace_set_notrace(&fp->ops, str, len, 0);
>    192			kfree(str);
>    193			if (ret)
>    194				goto out;
>    195		}
>    196	
>    197		/* TODO:
>    198		 * correctly calculate the total number of filtered symbols
>    199		 * from both filter and notfilter.
>    200		 */
>  > 201		hash = fp->ops.local_hash.filter_hash;

Hm, I need to use rcu_access_pointer() to access the filter_hash field,
because it is a __rcu pointer.

Thank you,

>    202		if (WARN_ON_ONCE(!hash))
>    203			goto out;
>    204	
>    205		ret = fprobe_init_rethook(fp, (int)hash->count);
>    206		if (!ret)
>    207			ret = register_ftrace_function(&fp->ops);
>    208	
>    209	out:
>    210		if (ret)
>    211			fprobe_fail_cleanup(fp);
>    212		return ret;
>    213	}
>    214	EXPORT_SYMBOL_GPL(register_fprobe);
>    215	
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://01.org/lkp


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

* Re: [bpf-next:master 209/265] kernel/trace/fprobe.c:201:14: sparse: sparse: incorrect type in assignment (different address spaces)
@ 2022-03-22 11:44   ` Masami Hiramatsu
  0 siblings, 0 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2022-03-22 11:44 UTC (permalink / raw)
  To: kbuild-all

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

On Tue, 22 Mar 2022 15:22:30 +0800
kernel test robot <lkp@intel.com> wrote:

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
> head:   f97b8b9bd630fb76c0e9e11cbf390e3d64a144d7
> commit: 5b0ab78998e32564a011b14c4c7f9c81e2d42b9d [209/265] fprobe: Add exit_handler support
> config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20220322/202203221549.JQIr40CT-lkp(a)intel.com/config)
> compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
> reproduce:
>         # apt-get install sparse
>         # sparse version: v0.6.4-dirty
>         # https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=5b0ab78998e32564a011b14c4c7f9c81e2d42b9d
>         git remote add bpf-next https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git
>         git fetch --no-tags bpf-next master
>         git checkout 5b0ab78998e32564a011b14c4c7f9c81e2d42b9d
>         # save the config file to linux build tree
>         mkdir build_dir
>         make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash kernel/trace/ samples/
> 
> 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 >>)
> >> kernel/trace/rethook.c:68:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
> >> kernel/trace/rethook.c:68:9: sparse:    void ( [noderef] __rcu * )( ... )
> >> kernel/trace/rethook.c:68:9: sparse:    void ( * )( ... )
> --
> >> kernel/trace/fprobe.c:201:14: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct ftrace_hash *hash @@     got struct ftrace_hash [noderef] __rcu *filter_hash @@
>    kernel/trace/fprobe.c:201:14: sparse:     expected struct ftrace_hash *hash
>    kernel/trace/fprobe.c:201:14: sparse:     got struct ftrace_hash [noderef] __rcu *filter_hash
> 
> vim +201 kernel/trace/fprobe.c
> 
>    158	
>    159	/**
>    160	 * register_fprobe() - Register fprobe to ftrace by pattern.
>    161	 * @fp: A fprobe data structure to be registered.
>    162	 * @filter: A wildcard pattern of probed symbols.
>    163	 * @notfilter: A wildcard pattern of NOT probed symbols.
>    164	 *
>    165	 * Register @fp to ftrace for enabling the probe on the symbols matched to @filter.
>    166	 * If @notfilter is not NULL, the symbols matched the @notfilter are not probed.
>    167	 *
>    168	 * Return 0 if @fp is registered successfully, -errno if not.
>    169	 */
>    170	int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter)
>    171	{
>    172		struct ftrace_hash *hash;
>    173		unsigned char *str;
>    174		int ret, len;
>    175	
>    176		if (!fp || !filter)
>    177			return -EINVAL;
>    178	
>    179		fprobe_init(fp);
>    180	
>    181		len = strlen(filter);
>    182		str = kstrdup(filter, GFP_KERNEL);
>    183		ret = ftrace_set_filter(&fp->ops, str, len, 0);
>    184		kfree(str);
>    185		if (ret)
>    186			return ret;
>    187	
>    188		if (notfilter) {
>    189			len = strlen(notfilter);
>    190			str = kstrdup(notfilter, GFP_KERNEL);
>    191			ret = ftrace_set_notrace(&fp->ops, str, len, 0);
>    192			kfree(str);
>    193			if (ret)
>    194				goto out;
>    195		}
>    196	
>    197		/* TODO:
>    198		 * correctly calculate the total number of filtered symbols
>    199		 * from both filter and notfilter.
>    200		 */
>  > 201		hash = fp->ops.local_hash.filter_hash;

Hm, I need to use rcu_access_pointer() to access the filter_hash field,
because it is a __rcu pointer.

Thank you,

>    202		if (WARN_ON_ONCE(!hash))
>    203			goto out;
>    204	
>    205		ret = fprobe_init_rethook(fp, (int)hash->count);
>    206		if (!ret)
>    207			ret = register_ftrace_function(&fp->ops);
>    208	
>    209	out:
>    210		if (ret)
>    211			fprobe_fail_cleanup(fp);
>    212		return ret;
>    213	}
>    214	EXPORT_SYMBOL_GPL(register_fprobe);
>    215	
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://01.org/lkp


-- 
Masami Hiramatsu <mhiramat@kernel.org>

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

end of thread, other threads:[~2022-03-22 11:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22  7:22 [bpf-next:master 209/265] kernel/trace/fprobe.c:201:14: sparse: sparse: incorrect type in assignment (different address spaces) kernel test robot
2022-03-22 11:44 ` Masami Hiramatsu
2022-03-22 11:44   ` Masami Hiramatsu

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.