Files
linux/tools/testing/selftests/bpf/progs/kprobe_write_ctx.c
Jiri Olsa 3d237467a4 selftests/bpf: Add kprobe multi write ctx attach test
Adding test to check we can't attach kprobe multi 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-7-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2025-09-24 02:25:06 -07:00

23 lines
378 B
C

// 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;
}
SEC("kprobe.multi")
int kprobe_multi_write_ctx(struct pt_regs *ctx)
{
ctx->ax = 0;
return 0;
}
#endif