Message ID | 20230612151608.99661-6-laoar.shao@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf: Support ->fill_link_info for kprobe_multi and perf_event links | expand |
On 6/12/23 8:16 AM, Yafang Shao wrote: > 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: 41bdc4b40ed6 ("bpf: introduce bpf subcommand BPF_TASK_FD_QUERY") > Signed-off-by: Yafang Shao <laoar.shao@gmail.com> > Cc: Yonghong Song <yhs@fb.com> Thanks for the fix! LGTM. Acked-by: Yonghong Song <yhs@fb.com> > --- > kernel/trace/bpf_trace.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c > index 742047c..97a5235 100644 > --- a/kernel/trace/bpf_trace.c > +++ b/kernel/trace/bpf_trace.c > @@ -2372,10 +2372,12 @@ int bpf_get_perf_event_info(const struct perf_event *event, u32 *prog_id, > event->attr.type == PERF_TYPE_TRACEPOINT); > #endif > #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, > probe_offset, > event->attr.type == PERF_TYPE_TRACEPOINT); > + *probe_addr = 0x0; > + } > #endif > } >
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 742047c..97a5235 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -2372,10 +2372,12 @@ int bpf_get_perf_event_info(const struct perf_event *event, u32 *prog_id, event->attr.type == PERF_TYPE_TRACEPOINT); #endif #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, probe_offset, event->attr.type == PERF_TYPE_TRACEPOINT); + *probe_addr = 0x0; + } #endif }
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: 41bdc4b40ed6 ("bpf: introduce bpf subcommand BPF_TASK_FD_QUERY") Signed-off-by: Yafang Shao <laoar.shao@gmail.com> Cc: Yonghong Song <yhs@fb.com> --- kernel/trace/bpf_trace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)