bpf: Clear the probe_addr for uprobe
[ Upstream commit5125e757e6
] To avoid returning uninitialized or random values when querying the file descriptor (fd) and accessing probe_addr, it is necessary to clear the variable prior to its use. Fixes:41bdc4b40e
("bpf: introduce bpf subcommand BPF_TASK_FD_QUERY") Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Acked-by: Yonghong Song <yhs@fb.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20230709025630.3735-6-laoar.shao@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Родитель
75d3960be7
Коммит
7b75b4c90a
|
@ -846,7 +846,8 @@ extern int perf_uprobe_init(struct perf_event *event,
|
||||||
extern void perf_uprobe_destroy(struct perf_event *event);
|
extern void perf_uprobe_destroy(struct perf_event *event);
|
||||||
extern int bpf_get_uprobe_info(const struct perf_event *event,
|
extern int bpf_get_uprobe_info(const struct perf_event *event,
|
||||||
u32 *fd_type, const char **filename,
|
u32 *fd_type, const char **filename,
|
||||||
u64 *probe_offset, bool perf_type_tracepoint);
|
u64 *probe_offset, u64 *probe_addr,
|
||||||
|
bool perf_type_tracepoint);
|
||||||
#endif
|
#endif
|
||||||
extern int ftrace_profile_set_filter(struct perf_event *event, int event_id,
|
extern int ftrace_profile_set_filter(struct perf_event *event, int event_id,
|
||||||
char *filter_str);
|
char *filter_str);
|
||||||
|
|
|
@ -1996,7 +1996,7 @@ int bpf_get_perf_event_info(const struct perf_event *event, u32 *prog_id,
|
||||||
#ifdef CONFIG_UPROBE_EVENTS
|
#ifdef CONFIG_UPROBE_EVENTS
|
||||||
if (flags & TRACE_EVENT_FL_UPROBE)
|
if (flags & TRACE_EVENT_FL_UPROBE)
|
||||||
err = bpf_get_uprobe_info(event, fd_type, buf,
|
err = bpf_get_uprobe_info(event, fd_type, buf,
|
||||||
probe_offset,
|
probe_offset, probe_addr,
|
||||||
event->attr.type == PERF_TYPE_TRACEPOINT);
|
event->attr.type == PERF_TYPE_TRACEPOINT);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1423,7 +1423,7 @@ static void uretprobe_perf_func(struct trace_uprobe *tu, unsigned long func,
|
||||||
|
|
||||||
int bpf_get_uprobe_info(const struct perf_event *event, u32 *fd_type,
|
int bpf_get_uprobe_info(const struct perf_event *event, u32 *fd_type,
|
||||||
const char **filename, u64 *probe_offset,
|
const char **filename, u64 *probe_offset,
|
||||||
bool perf_type_tracepoint)
|
u64 *probe_addr, bool perf_type_tracepoint)
|
||||||
{
|
{
|
||||||
const char *pevent = trace_event_name(event->tp_event);
|
const char *pevent = trace_event_name(event->tp_event);
|
||||||
const char *group = event->tp_event->class->system;
|
const char *group = event->tp_event->class->system;
|
||||||
|
@ -1440,6 +1440,7 @@ int bpf_get_uprobe_info(const struct perf_event *event, u32 *fd_type,
|
||||||
: BPF_FD_TYPE_UPROBE;
|
: BPF_FD_TYPE_UPROBE;
|
||||||
*filename = tu->filename;
|
*filename = tu->filename;
|
||||||
*probe_offset = tu->offset;
|
*probe_offset = tu->offset;
|
||||||
|
*probe_addr = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_PERF_EVENTS */
|
#endif /* CONFIG_PERF_EVENTS */
|
||||||
|
|
Загрузка…
Ссылка в новой задаче