summaryrefslogtreecommitdiff
path: root/kernel/trace
diff options
context:
space:
mode:
authorYafang Shao <laoar.shao@gmail.com>2023-07-09 02:56:26 +0000
committerAlexei Starovoitov <ast@kernel.org>2023-07-11 20:07:51 -0700
commitcd3910d005052382901fe3d0a3aeed48b1b64906 (patch)
tree06009c94c667c85e87770828a0cac18304481519 /kernel/trace
parent5125e757e62f6c1d5478db4c2b61a744060ddf3f (diff)
bpf: Expose symbol's respective address
Since different symbols can share the same name, it is insufficient to only expose the symbol name. It is essential to also expose the symbol address so that users can accurately identify which one is being probed. Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20230709025630.3735-7-laoar.shao@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/trace_kprobe.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 249eb14d0f7a..bf2872ca5aaf 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -1544,18 +1544,10 @@ int bpf_get_kprobe_info(const struct perf_event *event, u32 *fd_type,
*fd_type = trace_kprobe_is_return(tk) ? BPF_FD_TYPE_KRETPROBE
: BPF_FD_TYPE_KPROBE;
- if (tk->symbol) {
- *symbol = tk->symbol;
- *probe_offset = tk->rp.kp.offset;
- *probe_addr = 0;
- } else {
- *symbol = NULL;
- *probe_offset = 0;
- if (kallsyms_show_value(current_cred()))
- *probe_addr = (unsigned long)tk->rp.kp.addr;
- else
- *probe_addr = 0;
- }
+ *probe_offset = tk->rp.kp.offset;
+ *probe_addr = kallsyms_show_value(current_cred()) ?
+ (unsigned long)tk->rp.kp.addr : 0;
+ *symbol = tk->symbol;
return 0;
}
#endif /* CONFIG_PERF_EVENTS */