SELinuxProject / selinux-testsuite

This is the upstream SELinux testsuite which is designed as a basic set of regression tests for the SELinux kernel functionality.
GNU General Public License v2.0
54 stars 43 forks source link

Failed to 'make test' on bpf_create_map() and bpf_load_program() #86

Closed xiagao closed 9 months ago

xiagao commented 9 months ago

Hi, I tired to use this test suit to test virtiofs , but failed on 'make test', the detailed info is below.

# yum install -y perl-Test perl-Test-Harness perl-Test-Simple perl-lib selinux-policy-devel gcc libselinux-devel net-tools netlabel_tools iptables lksctp-tools-devel attr libbpf-devel keyutils-libs-devel quota xfsprogs-devel libuuid-devel e2fsprogs dosfstools nftables kernel-devel-$(uname -r) kernel-modules-$(uname -r) # git clone https://github.com/rhvgoyal/selinux-testsuite.git

# cd selinux-testsuite/ && git checkout virtiofs-support && make test
....
2023-12-15 06:05:05: 10.72.142.112make[2]: Leaving directory '/home/selinux-testsuite/tests/execute_no_trans'
2023-12-15 06:05:05: 10.72.142.112make[2]: Entering directory '/home/selinux-testsuite/tests/fdreceive'
2023-12-15 06:05:05: 10.72.142.112cc -g -O0 -Wall -D_GNU_SOURCE -DHAVE_BPF -DHAVE_FS_WATCH_PERM    client.c ../bpf/bpf_common.c ../bpf/bpf_common.h  -lbpf -o client
2023-12-15 06:05:05: 10.72.142.112../bpf/bpf_common.c: In function create_bpf_map:
2023-12-15 06:05:05: 10.72.142.112../bpf/bpf_common.c:8:18: warning: implicit declaration of function bpf_create_map [-Wimplicit-function-declaration]
2023-12-15 06:05:05: 10.72.142.112    8 |         map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key),
2023-12-15 06:05:05: 10.72.142.112      |                  ^~~~~~~~~~~~~~
2023-12-15 06:05:05: 10.72.142.112../bpf/bpf_common.c: In function create_bpf_prog:
2023-12-15 06:05:05: 10.72.142.112../bpf/bpf_common.c:30:19: warning: implicit declaration of function bpf_load_program [-Wimplicit-function-declaration]
2023-12-15 06:05:05: 10.72.142.112   30 |         prog_fd = bpf_load_program(BPF_PROG_TYPE_SOCKET_FILTER, prog,
2023-12-15 06:05:05: 10.72.142.112      |                   ^~~~~~~~~~~~~~~~
2023-12-15 06:05:06: 10.72.142.112/usr/bin/ld: /tmp/ccDpiaE0.o: in function `create_bpf_map':
2023-12-15 06:05:06: 10.72.142.112/home/selinux-testsuite/tests/fdreceive/../bpf/bpf_common.c:8: undefined reference to `bpf_create_map'
2023-12-15 06:05:06: 10.72.142.112/usr/bin/ld: /tmp/ccDpiaE0.o: in function `create_bpf_prog':
2023-12-15 06:05:06: 10.72.142.112/home/selinux-testsuite/tests/fdreceive/../bpf/bpf_common.c:30: undefined reference to `bpf_load_program'
2023-12-15 06:05:06: 10.72.142.112collect2: error: ld returned 1 exit status
2023-12-15 06:05:06: 10.72.142.112make[2]: *** [<builtin>: client] Error 1
2023-12-15 06:05:06: 10.72.142.112make[2]: Leaving directory '/home/selinux-testsuite/tests/fdreceive'
2023-12-15 06:05:06: 10.72.142.112make[1]: *** [Makefile:165: all] Error 1
2023-12-15 06:05:06: 10.72.142.112make[1]: Leaving directory '/home/selinux-testsuite/tests'
2023-12-15 06:05:06: 10.72.142.112make: *** [Makefile:8: test] Error 2
# uname -a
Linux localhost.localdomain 5.14.0-392.el9.x86_64
xiagao commented 9 months ago

[root@localhost /]# cd /usr/include/bpf/ [root@localhost bpf]# [root@localhost bpf]# [root@localhost bpf]# grep -nr pf_create_map [root@localhost bpf]# [root@localhost bpf]# [root@localhost bpf]# grep -nr bpf_map_create bpf.h:40:struct bpf_map_create_opts { bpf.h:55:#define bpf_map_create_opts__last_field map_ifindex bpf.h:57:LIBBPF_API int bpf_map_create(enum bpf_map_type map_type, bpf.h:62: const struct bpf_map_create_opts opts); libbpf_legacy.h:81: the very first bpf_prog_load(), bpf_map_create() or bpf_object__load()

Seems the function name was changed in recently kernel.

WOnder93 commented 9 months ago

# git clone https://github.com/rhvgoyal/selinux-testsuite.git


# cd selinux-testsuite/ && git checkout virtiofs-support && make test
....

That's an old branch in someone else's fork. In this repo the issue has been addressed by commit 92c29366dffad9e8b1ef621d4fc07816ed121efe.