summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2021-12-08 20:32:42 +0100
committerAlexei Starovoitov <ast@kernel.org>2021-12-13 09:24:22 -0800
commit2b070c2bc885977ca8fe76ba8f6b9d73d8d20e39 (patch)
tree0e88fc1b311d784d927c307fe684853c62a11f01 /tools
parentbb6728d756112596881a5fdf2040544031905840 (diff)
downloadlinux-2b070c2bc885977ca8fe76ba8f6b9d73d8d20e39.tar.bz2
selftests/bpf: Add test to access int ptr argument in tracing program
Adding verifier test for accessing int pointer argument in tracing programs. The test program loads 2nd argument of bpf_modify_return_test function which is int pointer and checks that verifier allows that. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20211208193245.172141-3-jolsa@kernel.org
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/verifier/btf_ctx_access.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/verifier/btf_ctx_access.c b/tools/testing/selftests/bpf/verifier/btf_ctx_access.c
new file mode 100644
index 000000000000..6340db6b46dc
--- /dev/null
+++ b/tools/testing/selftests/bpf/verifier/btf_ctx_access.c
@@ -0,0 +1,12 @@
+{
+ "btf_ctx_access accept",
+ .insns = {
+ BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, 8), /* load 2nd argument value (int pointer) */
+ BPF_MOV64_IMM(BPF_REG_0, 0),
+ BPF_EXIT_INSN(),
+ },
+ .result = ACCEPT,
+ .prog_type = BPF_PROG_TYPE_TRACING,
+ .expected_attach_type = BPF_TRACE_FENTRY,
+ .kfunc = "bpf_modify_return_test",
+},