]> Git Repo - J-linux.git/blob - tools/testing/selftests/bpf/prog_tests/test_struct_ops_no_cfi.c
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / tools / testing / selftests / bpf / prog_tests / test_struct_ops_no_cfi.c
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
3 #include <test_progs.h>
4 #include <testing_helpers.h>
5
6 static void load_bpf_test_no_cfi(void)
7 {
8         int fd;
9         int err;
10
11         fd = open("bpf_test_no_cfi.ko", O_RDONLY);
12         if (!ASSERT_GE(fd, 0, "open"))
13                 return;
14
15         /* The module will try to register a struct_ops type without
16          * cfi_stubs and with cfi_stubs.
17          *
18          * The one without cfi_stub should fail. The module will be loaded
19          * successfully only if the result of the registration is as
20          * expected, or it fails.
21          */
22         err = finit_module(fd, "", 0);
23         close(fd);
24         if (!ASSERT_OK(err, "finit_module"))
25                 return;
26
27         err = delete_module("bpf_test_no_cfi", 0);
28         ASSERT_OK(err, "delete_module");
29 }
30
31 void test_struct_ops_no_cfi(void)
32 {
33         if (test__start_subtest("load_bpf_test_no_cfi"))
34                 load_bpf_test_no_cfi();
35 }
This page took 0.029071 seconds and 4 git commands to generate.