OSDN Git Service

fprobe: Fix sparse warning for acccessing __rcu ftrace_hash
authorMasami Hiramatsu <mhiramat@kernel.org>
Wed, 23 Mar 2022 07:35:36 +0000 (16:35 +0900)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 29 Mar 2022 02:05:40 +0000 (19:05 -0700)
Since ftrace_ops::local_hash::filter_hash field is an __rcu pointer,
we have to use rcu_access_pointer() to access it.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/164802093635.1732982.4938094876018890866.stgit@devnote2
kernel/trace/fprobe.c

index 63b2321..89d9f99 100644 (file)
@@ -215,7 +215,7 @@ int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter
         * correctly calculate the total number of filtered symbols
         * from both filter and notfilter.
         */
-       hash = fp->ops.local_hash.filter_hash;
+       hash = rcu_access_pointer(fp->ops.local_hash.filter_hash);
        if (WARN_ON_ONCE(!hash))
                goto out;