Skip to contentSkip to conversation

tests: exclude vsock_socket test where it wouldn't build

PATCH In review Ondrej Mosnacek 1 participant 2 messages Sep 8, 2021 – Sep 11, 2021 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tests: exclude vsock_socket test where it wouldn't build

The test requires the <linux/vm_sockets.h> header to be available and contain th definition for VMADDR_CID_LOCAL, so wrap it in a check for these preconditions.

Likewise, the vsock_socket test policy requires the vsock_socket class to be defined in the base policy, so wrap the policy bit and test in a check for this, too.

Without this patch the testsuite wouldn't build on older distros such as RHEL-7.

---

v2: also check for vsock_socket class in policy

 policy/Makefile | 6 +++++-
 tests/Makefile  | 8 +++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
policy/Makefile +5 -1
index a4cc98f..5e5ccda 100644
@@ -27,7 +27,7 @@ TARGETS = \
 	test_setnice.te test_sigkill.te test_stat.te test_sysctl.te \
 	test_task_create.te test_task_getpgid.te test_task_getsched.te \
 	test_task_getsid.te test_task_setpgid.te test_task_setsched.te \
-	test_transition.te test_unix_socket.te test_vsock_socket.te \
+	test_transition.te test_unix_socket.te \
 	test_mmap.te test_overlayfs.te test_mqueue.te \
 	test_ibpkey.te test_atsecure.te test_cgroupfs.te
 
@@ -125,6 +125,10 @@ ifeq ($(shell grep -q key_socket $(POLDEV)/include/support/all_perms.spt && echo
 TARGETS += test_key_socket.te
 endif
 
+ifeq ($(shell grep -q vsock_socket $(POLDEV)/include/support/all_perms.spt && echo true),true)
+TARGETS += test_vsock_socket.te
+endif
+
 ifeq ($(shell grep -q module_load $(POLDEV)/include/support/all_perms.spt && echo true),true)
 TARGETS+=test_module_load.te
 endif
tests/Makefile +7 -1
index e59ddc0..cbff490 100644
@@ -27,7 +27,7 @@ SUBDIRS:= domain_trans entrypoint execshare exectrace execute_no_trans \
 	task_setnice task_setscheduler task_getscheduler task_getsid \
 	task_getpgid task_setpgid file ioctl capable_file capable_net \
 	capable_sys dyntrans dyntrace bounds nnp_nosuid mmap unix_socket \
-	inet_socket overlay checkreqprot mqueue mac_admin atsecure vsock_socket
+	inet_socket overlay checkreqprot mqueue mac_admin atsecure
 
 ifeq ($(shell grep -q cap_userns $(POLDEV)/include/support/all_perms.spt && echo true),true)
 ifneq ($(shell ./kvercmp $$(uname -r) 4.7),-1)
@@ -141,6 +141,12 @@ SUBDIRS += userfaultfd
 endif
 endif
 
+ifeq ($(shell grep -q vsock_socket $(POLDEV)/include/support/all_perms.spt && echo true),true)
+ifeq ($(shell grep -qs VMADDR_CID_LOCAL $(INCLUDEDIR)/linux/vm_sockets.h && echo true),true)
+SUBDIRS += vsock_socket
+endif
+endif
+
 ifeq ($(DISTRO),RHEL4)
     SUBDIRS:=$(filter-out bounds dyntrace dyntrans inet_socket mmap nnp_nosuid overlay unix_socket, $(SUBDIRS))
 endif
Signature · 1 line
2.31.1
#1 lore raw
Quoted 11 lines · Ondrej Mosnacek

The test requires the <linux/vm_sockets.h> header to be available and contain th definition for VMADDR_CID_LOCAL, so wrap it in a check for these preconditions.

Likewise, the vsock_socket test policy requires the vsock_socket class to be defined in the base policy, so wrap the policy bit and test in a check for this, too.

Without this patch the testsuite wouldn't build on older distros such as RHEL-7.

Quoted 8 lines

---

v2: also check for vsock_socket class in policy

 policy/Makefile | 6 +++++-
 tests/Makefile  | 8 +++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

This patch is also applied now.

Signature · 3 lines
Ondrej Mosnacek
Software Engineer, Linux Security - SELinux kernel
Red Hat, Inc.