diff options
| author | Jiri Olsa <jolsa@kernel.org> | 2025-09-16 23:53:00 +0200 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2025-09-24 02:25:06 -0700 |
| commit | 1b881ee294b2d8929a77b0e489047765d55f0191 (patch) | |
| tree | af60f99eb90c4de4492e4e367a38ec9654248a04 /tools/testing/selftests/bpf/progs | |
| parent | selftests/bpf: Add uprobe context ip register change test (diff) | |
| download | linux-1b881ee294b2d8929a77b0e489047765d55f0191.tar.gz linux-1b881ee294b2d8929a77b0e489047765d55f0191.zip | |
selftests/bpf: Add kprobe write ctx attach test
Adding test to check we can't attach standard kprobe program that
writes to the context.
It's x86_64 specific test.
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20250916215301.664963-6-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/kprobe_write_ctx.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/kprobe_write_ctx.c b/tools/testing/selftests/bpf/progs/kprobe_write_ctx.c new file mode 100644 index 000000000000..4621a5bef4e2 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/kprobe_write_ctx.c @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "vmlinux.h" +#include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> + +char _license[] SEC("license") = "GPL"; + +#if defined(__TARGET_ARCH_x86) +SEC("kprobe") +int kprobe_write_ctx(struct pt_regs *ctx) +{ + ctx->ax = 0; + return 0; +} +#endif |
