]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/hid: disable struct_ops auto-attach
authorBenjamin Tissoires <bentiss@kernel.org>
Tue, 23 Jul 2024 16:21:52 +0000 (18:21 +0200)
committerBenjamin Tissoires <bentiss@kernel.org>
Wed, 24 Jul 2024 16:27:21 +0000 (18:27 +0200)
Since commit 08ac454e258e ("libbpf: Auto-attach struct_ops BPF maps in
BPF skeleton"), libbpf automatically calls bpf_map__attach_struct_ops()
on every struct_ops it sees in the bpf object. The problem is that
our test bpf object has many of them but only one should be manually
loaded at a time, or we end up locking the syscall.

Link: https://patch.msgid.link/20240723-fix-6-11-bpf-v1-2-b9d770346784@kernel.org
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
tools/testing/selftests/hid/hid_bpf.c

index dc0408a831d07c7296ba9c0ff1ede75ff07c3481..9c935fd0dffc4cf69793be5e6b6267d71cd945c5 100644 (file)
@@ -532,6 +532,7 @@ static void load_programs(const struct test_program programs[],
                          FIXTURE_DATA(hid_bpf) * self,
                          const FIXTURE_VARIANT(hid_bpf) * variant)
 {
+       struct bpf_map *iter_map;
        int err = -EINVAL;
 
        ASSERT_LE(progs_count, ARRAY_SIZE(self->hid_links))
@@ -564,6 +565,13 @@ static void load_programs(const struct test_program programs[],
                *ops_hid_id = self->hid_id;
        }
 
+       /* we disable the auto-attach feature of all maps because we
+        * only want the tested one to be manually attached in the next
+        * call to bpf_map__attach_struct_ops()
+        */
+       bpf_object__for_each_map(iter_map, *self->skel->skeleton->obj)
+               bpf_map__set_autoattach(iter_map, false);
+
        err = hid__load(self->skel);
        ASSERT_OK(err) TH_LOG("hid_skel_load failed: %d", err);