Skip to content

Commit

Permalink
selftests/bpf: Fix kprobe_multi test.
Browse files Browse the repository at this point in the history
When compiler emits endbr insn the function address could
be different than what bpf_get_func_ip() reports.
This is a short term workaround.
bpf_get_func_ip() will be fixed later.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Alexei Starovoitov committed Mar 22, 2022
1 parent 4e8ca13 commit 7f0059b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/testing/selftests/bpf/progs/kprobe_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ __u64 kretprobe_test6_result = 0;
__u64 kretprobe_test7_result = 0;
__u64 kretprobe_test8_result = 0;

extern bool CONFIG_X86_KERNEL_IBT __kconfig __weak;

static void kprobe_multi_check(void *ctx, bool is_return)
{
if (bpf_get_current_pid_tgid() >> 32 != pid)
return;

__u64 cookie = test_cookie ? bpf_get_attach_cookie(ctx) : 0;
__u64 addr = bpf_get_func_ip(ctx);
__u64 addr = bpf_get_func_ip(ctx) - (CONFIG_X86_KERNEL_IBT ? 4 : 0);

#define SET(__var, __addr, __cookie) ({ \
if (((const void *) addr == __addr) && \
Expand Down

0 comments on commit 7f0059b

Please sign in to comment.