From: Andrii Nakryiko <andrii@kernel.org>
To: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>
Cc: <andrii@kernel.org>, <kernel-team@fb.com>
Subject: [PATCH bpf-next 0/5] Add SEC("ksyscall") support
Date: Tue, 12 Jul 2022 18:52:59 -0700 [thread overview]
Message-ID: <20220713015304.3375777-1-andrii@kernel.org> (raw)
Add SEC("ksyscall")/SEC("kretsyscall") sections and corresponding
bpf_program__attach_ksyscall() API that simplifies tracing kernel syscalls
through kprobe mechanism. Kprobing syscalls isn't trivial due to varying
syscall handler names in the kernel and various ways syscall argument are
passed, depending on kernel architecture and configuration. SEC("ksyscall")
allows user to not care about such details and just get access to syscall
input arguments, while libbpf takes care of necessary feature detection logic.
There are still more quirks that are not straightforward to hide completely
(see comments about mmap(), clone() and compat syscalls), so in such more
advanced scenarios user might need to fall back to plain SEC("kprobe")
approach, but for absolute majority of users SEC("ksyscall") is a big
improvement.
As part of this patch set libbpf adds two more virtual __kconfig externs, in
addition to existing LINUX_KERNEL_VERSION: LINUX_HAS_BPF_COOKIE and
LINUX_HAS_SYSCALL_WRAPPER, which let's libbpf-provided BPF-side code minimize
external dependencies and assumptions and let's user-space part of libbpf to
perform all the feature detection logic. This benefits USDT support code,
which now doesn't depend on BPF CO-RE for its functionality.
rfc->v1:
- drop dependency on kallsyms and speed up SYSCALL_WRAPPER detection (Alexei);
- drop dependency on /proc/config.gz in bpf_tracing.h (Yaniv);
- add doc comment and ephasize mmap(), clone() and compat quirks that are
not supported (Ilya);
- use mechanism similar to LINUX_KERNEL_VERSION to also improve USDT code.
Andrii Nakryiko (5):
libbpf: generalize virtual __kconfig externs and use it for USDT
selftests/bpf: add test of __weak unknown virtual __kconfig extern
libbpf: improve BPF_KPROBE_SYSCALL macro and rename it to BPF_KSYSCALL
libbpf: add ksyscall/kretsyscall sections support for syscall kprobes
selftests/bpf: use BPF_KSYSCALL and SEC("ksyscall") in selftests
tools/lib/bpf/bpf_tracing.h | 51 +++--
tools/lib/bpf/libbpf.c | 188 +++++++++++++++---
tools/lib/bpf/libbpf.h | 46 +++++
tools/lib/bpf/libbpf.map | 1 +
tools/lib/bpf/libbpf_internal.h | 2 +
tools/lib/bpf/usdt.bpf.h | 16 +-
.../selftests/bpf/prog_tests/core_extern.c | 17 +-
.../selftests/bpf/progs/bpf_syscall_macro.c | 6 +-
.../selftests/bpf/progs/test_attach_probe.c | 15 +-
.../selftests/bpf/progs/test_core_extern.c | 3 +
.../selftests/bpf/progs/test_probe_user.c | 27 +--
11 files changed, 275 insertions(+), 97 deletions(-)
--
2.30.2
next reply other threads:[~2022-07-13 1:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-13 1:52 Andrii Nakryiko [this message]
2022-07-13 1:53 ` [PATCH bpf-next 1/5] libbpf: generalize virtual __kconfig externs and use it for USDT Andrii Nakryiko
2022-07-13 15:18 ` Alan Maguire
2022-07-13 18:02 ` Andrii Nakryiko
2022-07-13 16:24 ` sdf
2022-07-13 18:07 ` Andrii Nakryiko
2022-07-13 18:57 ` Stanislav Fomichev
2022-07-13 20:26 ` Andrii Nakryiko
2022-07-13 21:14 ` Stanislav Fomichev
2022-07-13 1:53 ` [PATCH bpf-next 2/5] selftests/bpf: add test of __weak unknown virtual __kconfig extern Andrii Nakryiko
2022-07-13 1:53 ` [PATCH bpf-next 3/5] libbpf: improve BPF_KPROBE_SYSCALL macro and rename it to BPF_KSYSCALL Andrii Nakryiko
2022-07-13 1:53 ` [PATCH bpf-next 4/5] libbpf: add ksyscall/kretsyscall sections support for syscall kprobes Andrii Nakryiko
2022-07-13 1:53 ` [PATCH bpf-next 5/5] selftests/bpf: use BPF_KSYSCALL and SEC("ksyscall") in selftests Andrii Nakryiko
2022-07-13 16:29 ` sdf
2022-07-13 17:57 ` Andrii Nakryiko
2022-07-13 18:57 ` Stanislav Fomichev
2022-07-13 20:30 ` Andrii Nakryiko
2022-07-13 21:17 ` Stanislav Fomichev
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=20220713015304.3375777-1-andrii@kernel.org \
--to=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox