From: Jiri Olsa <jolsa@redhat.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>
Subject: [PATCHv2 bpf-next 0/5] bpf: Add helpers to access traced function arguments
Date: Wed, 8 Dec 2021 20:32:40 +0100 [thread overview]
Message-ID: <20211208193245.172141-1-jolsa@kernel.org> (raw)
hi,
adding new helpers to access traced function arguments that
came out of the trampoline batch changes [1].
Get n-th argument of the traced function:
long bpf_get_func_arg(void *ctx, u32 n, u64 *value)
Get return value of the traced function:
long bpf_get_func_ret(void *ctx, u64 *value)
Get arguments count of the traced funtion:
long bpf_get_func_arg_cnt(void *ctx)
v2 changes:
- added acks
- updated stack diagram
- return -EOPNOTSUPP instead of -EINVAL in bpf_get_func_ret
- removed gpl_only for all helpers
- added verifier fix to allow proper arguments checks,
Andrii asked for checking also 'int *b' argument in
bpf_modify_return_test programs and it turned out that it's currently
not supported by verifier - we can't read argument that is int pointer,
so I had to add verifier change to allow that + adding verifier selftest
- checking all arguments in bpf_modify_return_test test programs
- moved helpers proto gets in tracing_prog_func_proto with attach type check
thanks,
jirka
[1] https://lore.kernel.org/bpf/20211118112455.475349-1-jolsa@kernel.org/
---
Jiri Olsa (5):
bpf: Allow access to int pointer arguments in tracing programs
selftests/bpf: Add test to access int ptr argument in tracing program
bpf, x64: Replace some stack_size usage with offset variables
bpf: Add get_func_[arg|ret|arg_cnt] helpers
selftests/bpf: Add tests for get_func_[arg|ret|arg_cnt] helpers
arch/x86/net/bpf_jit_comp.c | 55 ++++++++++++++++++++++++++++++-----------
include/linux/bpf.h | 5 ++++
include/uapi/linux/bpf.h | 28 +++++++++++++++++++++
kernel/bpf/btf.c | 7 +++---
kernel/bpf/trampoline.c | 8 ++++++
kernel/bpf/verifier.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
kernel/trace/bpf_trace.c | 55 ++++++++++++++++++++++++++++++++++++++++-
tools/include/uapi/linux/bpf.h | 28 +++++++++++++++++++++
tools/testing/selftests/bpf/prog_tests/get_func_args_test.c | 44 +++++++++++++++++++++++++++++++++
tools/testing/selftests/bpf/progs/get_func_args_test.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/testing/selftests/bpf/verifier/btf_ctx_access.c | 12 +++++++++
11 files changed, 418 insertions(+), 24 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/get_func_args_test.c
create mode 100644 tools/testing/selftests/bpf/progs/get_func_args_test.c
create mode 100644 tools/testing/selftests/bpf/verifier/btf_ctx_access.c
next reply other threads:[~2021-12-08 19:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-08 19:32 Jiri Olsa [this message]
2021-12-08 19:32 ` [PATCHv2 bpf-next 1/5] bpf: Allow access to int pointer arguments in tracing programs Jiri Olsa
2021-12-08 19:32 ` [PATCHv2 bpf-next 2/5] selftests/bpf: Add test to access int ptr argument in tracing program Jiri Olsa
2021-12-08 19:32 ` [PATCHv2 bpf-next 3/5] bpf, x64: Replace some stack_size usage with offset variables Jiri Olsa
2021-12-08 19:32 ` [PATCHv2 bpf-next 4/5] bpf: Add get_func_[arg|ret|arg_cnt] helpers Jiri Olsa
2021-12-13 17:45 ` Alexei Starovoitov
2021-12-08 19:32 ` [PATCHv2 bpf-next 5/5] selftests/bpf: Add tests for " Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211208193245.172141-1-jolsa@kernel.org \
--to=jolsa@redhat.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.