diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2023-12-15 04:13:34 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2023-12-20 05:06:47 +0300 |
commit | f0a5056222f2cfa6d40b4c888cb6b01e8569e282 (patch) | |
tree | 48f3b6ea5e3a22eed329e643098b62564b85e910 /tools/testing/selftests/bpf/progs/freplace_unreliable_prog.c | |
parent | 0a0ffcac92d5b41133c97d260ad1f320572783a5 (diff) | |
download | linux-f0a5056222f2cfa6d40b4c888cb6b01e8569e282.tar.xz |
selftests/bpf: add freplace of BTF-unreliable main prog test
Add a test validating that freplace'ing another main (entry) BPF program
fails if the target BPF program doesn't have valid/expected func proto BTF.
We extend fexit_bpf2bpf test to allow to specify expected log message
for negative test cases (where freplace program is expected to fail to
load).
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20231215011334.2307144-11-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/freplace_unreliable_prog.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/freplace_unreliable_prog.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/freplace_unreliable_prog.c b/tools/testing/selftests/bpf/progs/freplace_unreliable_prog.c new file mode 100644 index 000000000000..624078abf3de --- /dev/null +++ b/tools/testing/selftests/bpf/progs/freplace_unreliable_prog.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2020 Facebook + +#include "vmlinux.h" +#include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> + +SEC("freplace/btf_unreliable_kprobe") +/* context type is what BPF verifier expects for kprobe context, but target + * program has `stuct whatever *ctx` argument, so freplace operation will be + * rejected with the following message: + * + * arg0 replace_btf_unreliable_kprobe(struct pt_regs *) doesn't match btf_unreliable_kprobe(struct whatever *) + */ +int replace_btf_unreliable_kprobe(bpf_user_pt_regs_t *ctx) +{ + return 0; +} + +char _license[] SEC("license") = "GPL"; |