blob: 106ea447965aa43e475b539af93a7febbfb2f9af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
#include <test_progs.h>
#include <testing_helpers.h>
static void load_bpf_test_no_cfi(void)
{
int fd;
int err;
fd = open("bpf_test_no_cfi.ko", O_RDONLY);
if (!ASSERT_GE(fd, 0, "open"))
return;
/* The module will try to register a struct_ops type without
* cfi_stubs and with cfi_stubs.
*
* The one without cfi_stub should fail. The module will be loaded
* successfully only if the result of the registration is as
* expected, or it fails.
*/
err = finit_module(fd, "", 0);
close(fd);
if (!ASSERT_OK(err, "finit_module"))
return;
err = delete_module("bpf_test_no_cfi", 0);
ASSERT_OK(err, "delete_module");
}
void test_struct_ops_no_cfi(void)
{
if (test__start_subtest("load_bpf_test_no_cfi"))
load_bpf_test_no_cfi();
}
|