[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20220322204450.a09369b16d3e585be31dc394@kernel.org>
Date: Tue, 22 Mar 2022 20:44:50 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: kernel test robot <lkp@...el.com>
Cc: kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
Alexei Starovoitov <ast@...nel.org>,
"Steven Rostedt (Google)" <rostedt@...dmis.org>
Subject: Re: [bpf-next:master 209/265] kernel/trace/fprobe.c:201:14: sparse:
sparse: incorrect type in assignment (different address spaces)
On Tue, 22 Mar 2022 15:22:30 +0800
kernel test robot <lkp@...el.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@...el.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@...nel.org>
Powered by blists - more mailing lists