Re: [PATCHv3 bpf-next 3/7] bpf: Add bpf_get_func_ip helper for tracing programs
From: Andrii Nakryiko <hidden>
Date: 2021-07-08 00:06:34
Also in:
bpf
On Wed, Jul 7, 2021 at 2:53 PM Jiri Olsa [off-list ref] wrote:
Adding bpf_get_func_ip helper for BPF_PROG_TYPE_TRACING programs, specifically for all trampoline attach types. The trampoline's caller IP address is stored in (ctx - 8) address. so there's no reason to actually call the helper, but rather fixup the call instruction and return [ctx - 8] value directly (suggested by Alexei). [fixed has_get_func_ip wrong return type] Reported-by: kernel test robot <redacted> Reported-by: Dan Carpenter <redacted> Signed-off-by: Jiri Olsa <jolsa@kernel.org> --- include/uapi/linux/bpf.h | 7 +++++ kernel/bpf/verifier.c | 53 ++++++++++++++++++++++++++++++++++ kernel/trace/bpf_trace.c | 15 ++++++++++ tools/include/uapi/linux/bpf.h | 7 +++++ 4 files changed, 82 insertions(+)
[...]
quoted hunk ↗ jump to hunk
static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn, int *insn_idx_p) {@@ -6225,6 +6256,12 @@ static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn if (func_id == BPF_FUNC_get_stackid || func_id == BPF_FUNC_get_stack) env->prog->call_get_stack = true; + if (func_id == BPF_FUNC_get_func_ip) { + if (has_get_func_ip(env))
from has_xxx name I'd expect it returns true/false, so this reads super confusing. check_get_func_ip would be a bit more consistent with other cases like this (still reads confusing to me, but that's ok)
+ return -ENOTSUPP;
+ env->prog->call_get_func_ip = true;
+ }
+
if (changes_data)
clear_all_pkt_pointers(env);
return 0;[...]