summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/wq_failures.c
diff options
context:
space:
mode:
authorMykyta Yatsenko <yatsenko@meta.com>2025-10-10 17:46:05 +0100
committerAlexei Starovoitov <ast@kernel.org>2025-10-10 11:12:51 -0700
commitbca2b74ea9a8a194d4545448e883940daaaa1c38 (patch)
tree38bcf29c724249383879584b600610d5aef992f7 /tools/testing/selftests/bpf/progs/wq_failures.c
parent5f8d41172931a92339c5cce81a3142065fa56e45 (diff)
selftests/bpf: Add more bpf_wq tests
Add bpf_wq selftests to verify: * BPF program using non-constant offset of struct bpf_wq is rejected * BPF program using map with no BTF for storing struct bpf_wq is rejected Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com> Tested-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/r/20251010164606.147298-2-mykyta.yatsenko5@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/wq_failures.c')
-rw-r--r--tools/testing/selftests/bpf/progs/wq_failures.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/wq_failures.c b/tools/testing/selftests/bpf/progs/wq_failures.c
index 4240211a1900..d06f6d40594a 100644
--- a/tools/testing/selftests/bpf/progs/wq_failures.c
+++ b/tools/testing/selftests/bpf/progs/wq_failures.c
@@ -142,3 +142,26 @@ long test_wrong_wq_pointer_offset(void *ctx)
return -22;
}
+
+SEC("tc")
+__log_level(2)
+__failure
+__msg(": (85) call bpf_wq_init#")
+__msg("R1 doesn't have constant offset. bpf_wq has to be at the constant offset")
+long test_bad_wq_off(void *ctx)
+{
+ struct elem *val;
+ struct bpf_wq *wq;
+ int key = 42;
+ u64 unknown;
+
+ val = bpf_map_lookup_elem(&array, &key);
+ if (!val)
+ return -2;
+
+ unknown = bpf_get_prandom_u32();
+ wq = &val->w + unknown;
+ if (bpf_wq_init(wq, &array, 0) != 0)
+ return -3;
+ return 0;
+}