Skip to contentSkip to conversation

Add tests for pidfds

PATCH New [email protected] 1 participant 1 message Feb 6 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add tests for pidfds

From: Daniel Durning <[email protected]>

Added two tests to exercise accesss controls on pidfd_getinfo(), as introduced in the corresponding kernel patch.

---
 policy/Makefile          |   2 +-
 policy/test_pidfd.te     |  30 +++++++++++
 tests/Makefile           |   2 +-
 tests/pidfd/.gitignore   |   1 +
 tests/pidfd/Makefile     |   5 ++
 tests/pidfd/pidfd_test.c | 112 +++++++++++++++++++++++++++++++++++++++
 tests/pidfd/test         |  49 +++++++++++++++++
 7 files changed, 199 insertions(+), 2 deletions(-)
 create mode 100644 policy/test_pidfd.te
 create mode 100644 tests/pidfd/.gitignore
 create mode 100644 tests/pidfd/Makefile
 create mode 100644 tests/pidfd/pidfd_test.c
 create mode 100755 tests/pidfd/test
policy/Makefile +1 -1
index a43883f..870b45b 100644
@@ -22,7 +22,7 @@ TARGETS = \
 	test_entrypoint.te test_execshare.te test_exectrace.te \
 	test_execute_no_trans.te test_fdreceive.te test_file.te \
 	test_inherit.te test_ioctl.te test_ipc.te test_link.te test_mkdir.te \
-	test_open.te test_ptrace.te test_readlink.te \
+	test_open.te test_ptrace.te test_pidfd.te test_readlink.te \
 	test_relabel.te test_rename.te test_rxdir.te test_setattr.te \
 	test_setnice.te test_sigkill.te test_stat.te test_sysctl.te \
 	test_task_create.te test_task_getpgid.te test_task_getsched.te \
policy/test_pidfd.te new file +30 -0
new file mode 100644
index 0000000..89b3c00
@@ -0,0 +1,30 @@
+#
+################# pidfd selinux-testsuite policy module ###################
+#
+
+attribute pidfddomain;
+
+################################### Main ##################################
+type test_pidfd_t;
+testsuite_domain_type(test_pidfd_t)
+typeattribute test_pidfd_t pidfddomain;
+
+allow test_pidfd_t self:file read;
+
+############################### Deny fd read ##############################
+type test_pidfd_deny_read_t;
+testsuite_domain_type(test_pidfd_deny_read_t)
+typeattribute test_pidfd_deny_read_t pidfddomain;
+
+allow test_pidfd_deny_read_t self:file read;
+
+############################### Process type ##############################
+type test_pidfd_process_t;
+testsuite_domain_type(test_pidfd_process_t)
+typeattribute test_pidfd_process_t pidfddomain;
+
+# For writing to flag file
+allow test_pidfd_process_t test_file_t:fifo_file rw_file_perms;
+
+# Allow the main domain to read the process info
+allow test_pidfd_t test_pidfd_process_t:file read;
\ No newline at end of file
tests/Makefile +1 -1
index 6df220c..7cd80f6 100644
@@ -22,7 +22,7 @@ POL_TYPE := $(shell ./pol_detect $(SELINUXFS))
 FILESYSTEMS := $(foreach fs,$(FILESYSTEMS),$(shell modprobe $(fs) > /dev/null 2>&1 && echo $(fs)))
 
 SUBDIRS:= domain_trans entrypoint execshare exectrace execute_no_trans \
-	fdreceive inherit link mkdir msg open ptrace readlink relabel rename \
+	fdreceive inherit link mkdir msg open ptrace pidfd readlink relabel rename \
 	rxdir sem setattr setnice shm sigkill stat sysctl task_create \
 	task_setnice task_setscheduler task_getscheduler task_getsid \
 	task_getpgid task_setpgid file ioctl capable_file capable_net \
tests/pidfd/.gitignore new file +1 -0
new file mode 100644
index 0000000..42604c5
@@ -0,0 +1 @@
+pidfd_test
\ No newline at end of file
tests/pidfd/Makefile new file +5 -0
new file mode 100644
index 0000000..d4d3d48
@@ -0,0 +1,5 @@
+TARGETS = pidfd_test
+
+all: $(TARGETS)
+clean:
+	rm -f $(TARGETS) flag
tests/pidfd/pidfd_test.c new file +112 -0

113 lines not on this page · raw message

tests/pidfd/test new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.52.0