]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Force cookies array to follow symbols sorting
authorJiri Olsa <jolsa@kernel.org>
Wed, 15 Jun 2022 11:21:17 +0000 (13:21 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 17 Jun 2022 02:42:21 +0000 (19:42 -0700)
commitede25e3f799c3d6c0d1494e9abe01c1237c35826
treec0f26fc64a8678d3317c0d88c55f1aa1e746afcc
parent36fd2053eb222c92eea28f121d7de4daef607d88
bpf: Force cookies array to follow symbols sorting

When user specifies symbols and cookies for kprobe_multi link
interface it's very likely the cookies will be misplaced and
returned to wrong functions (via get_attach_cookie helper).

The reason is that to resolve the provided functions we sort
them before passing them to ftrace_lookup_symbols, but we do
not do the same sort on the cookie values.

Fixing this by using sort_r function with custom swap callback
that swaps cookie values as well.

Fixes: 4983e8bd8f71 ("bpf: Resolve symbols with ftrace_lookup_symbols for kprobe multi link")
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20220615112118.497303-4-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/trace/bpf_trace.c