Skip to contentSkip to conversation

policy: allow all test domains to search user/admin home directories

PATCH In review Ondrej Mosnacek 2 participants 3 messages Jul 17, 2023 – Jul 18, 2023 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 policy: allow all test domains to search user/admin home directories

The permissions are sometimes needed to resolve paths when running the testsuite from a user/admin home directory. To avoid cluttering individual policy files with macros that allow it, apply the macros to the whole testsuite_domain attribute. Thankfully this doesn't break the other tests.

This also fixes the inet_socket test, which started to require these permissions after a recent change.

While there, also remove userdom_read_user_tmp_files() from test_overlay_mounter_t, which doesn't seem to be needed.

Fixes 4dcea27ada77 ("tests/inet_socket: cover the MPTCP protocol")
---
 policy/test_filesystem.te        | 1 -
 policy/test_filesystem_notify.te | 1 -
 policy/test_global.te            | 7 +++++++
 policy/test_ipc.te               | 2 --
 policy/test_overlayfs.te         | 7 -------
 policy/test_policy.if            | 7 -------
 policy/test_ptrace.te            | 1 -
 7 files changed, 7 insertions(+), 19 deletions(-)
policy/test_filesystem.te +0 -1
index 59eac2b..efe1f4d 100644
@@ -366,7 +366,6 @@ allow test_filesystem_inode_setxattr_no_associate_t test_file_t:file { create re
 #
 ############### Rules for NFS mount ##################
 #
-userdom_search_user_home_content(filesystemdomain)
 allow test_filesystem_t test_filesystem_file_t:filesystem { getattr mount remount unmount relabelto relabelfrom };
 allow test_filesystem_t test_file_t:file { create write relabelfrom };
 allow test_file_t test_filesystem_file_t:filesystem { associate };
policy/test_filesystem_notify.te +0 -1
index 30056e4..77d46ae 100644
@@ -16,7 +16,6 @@ allow test_filesystem_t dosfs_t:filesystem { watch };
 #
 ############### Rules for NFS mount with rootcontext option #################
 #
-userdom_search_user_home_content(filesystemdomain)
 allow test_filesystem_no_watch_mount_t nfs_t:filesystem { unmount };
 allow test_filesystem_no_watch_mount_t test_filesystem_file_t:dir { search };
 allow test_filesystem_no_watch_sb_t nfs_t:filesystem { unmount watch };
policy/test_global.te +7 -0
index 052c7dd..0078485 100644
@@ -153,6 +153,13 @@ selinux_compute_create_context(testsuite_domain)
 selinux_compute_relabel_context(testsuite_domain)
 selinux_compute_user_contexts(testsuite_domain)
 
+userdom_search_user_home_content(testsuite_domain)
+# Refpolicy does not have admin_home_t - assume /root will be user_home_dir_t,
+# which is covered by the above call.
+ifdef(`userdom_search_admin_dir', `
+    userdom_search_admin_dir(testsuite_domain)
+')
+
 # Reference policy renamed files_list_pids() to files_list_runtime()
 ifdef(`files_list_pids', `
     files_list_pids(testsuite_domain)
policy/test_ipc.te +0 -2
index 678eca8..5e26384 100644
@@ -67,5 +67,3 @@ fs_rw_tmpfs_files(ipcdomain)
 
 allow test_ipc_base_t self:sem create_sem_perms;
 allow test_ipc_base_t self:shm create_shm_perms;
-# ipcrm needs this... 
-userdom_search_user_home_dirs(test_ipc_base_t)
policy/test_overlayfs.te +0 -7
index ab589bb..c09b577 100644
@@ -45,10 +45,6 @@ kernel_search_proc(test_overlay_mounter_t)
 fs_relabelfrom_xattr_fs(test_overlay_mounter_t)
 fs_mount_xattr_fs(test_overlay_mounter_t)
 
-userdom_search_admin_dir(test_overlay_mounter_t)
-userdom_search_user_home_content(test_overlay_mounter_t)
-userdom_read_user_tmp_files(test_overlay_mounter_t)
-
 mount_exec(test_overlay_mounter_t)
 mount_rw_pid_files(test_overlay_mounter_t)
 
@@ -113,9 +109,6 @@ mcs_constrained(test_overlay_client_t)
 kernel_read_system_state(test_overlay_client_t)
 kernel_read_proc_symlinks(test_overlay_client_t)
 
-userdom_search_admin_dir(test_overlay_client_t)
-userdom_search_user_home_content(test_overlay_client_t)
-
 fs_getattr_xattr_fs(test_overlay_client_t)
 
 selinux_getattr_fs(test_overlay_client_t)
policy/test_policy.if +0 -7
index 5458f6c..b20baad 100644
@@ -82,13 +82,6 @@ interface(`mount_rw_pid_files', `
 ')
 ')
 
-# Refpolicy does not have admin_home_t - assume /root will be user_home_dir_t.
-ifdef(`userdom_search_admin_dir', `', ` dnl
-interface(`userdom_search_admin_dir', `
-    userdom_search_user_home_content($1)
-')
-')
-
 # If the macro is not defined, then most probably module_request permission
 # is just not supported (and relevant operations should be just allowed).
 ifdef(`kernel_request_load_module', `', ` dnl
policy/test_ptrace.te +0 -1
index 352ead5..1a8a10d 100644
@@ -27,7 +27,6 @@ allow test_ptrace_traced_t test_file_t:fifo_file rw_file_perms;
 
 # Allow the tracer domain to trace the traced domain.
 allow test_ptrace_tracer_t test_ptrace_traced_t:process ptrace;
-userdom_search_user_home_dirs(test_ptrace_traced_t)
 
 # Let the tracer wait on the traced domain.
 allow test_ptrace_traced_t test_ptrace_tracer_t:process sigchld;
Signature · 1 line
2.41.0
maintainer Tested-by on v1 1/1
#1 lore raw
Quoted 10 lines · Ondrej Mosnacek

The permissions are sometimes needed to resolve paths when running the testsuite from a user/admin home directory. To avoid cluttering individual policy files with macros that allow it, apply the macros to the whole testsuite_domain attribute. Thankfully this doesn't break the other tests.

This also fixes the inet_socket test, which started to require these permissions after a recent change.

Quoted 6 lines

While there, also remove userdom_read_user_tmp_files() from test_overlay_mounter_t, which doesn't seem to be needed.

Fixes 4dcea27ada77 ("tests/inet_socket: cover the MPTCP protocol")

All tests pass with this applied, thanks.

Quoted 120 lines
---
 policy/test_filesystem.te        | 1 -
 policy/test_filesystem_notify.te | 1 -
 policy/test_global.te            | 7 +++++++
 policy/test_ipc.te               | 2 --
 policy/test_overlayfs.te         | 7 -------
 policy/test_policy.if            | 7 -------
 policy/test_ptrace.te            | 1 -
 7 files changed, 7 insertions(+), 19 deletions(-)
policy/test_filesystem.te +0 -1
index 59eac2b..efe1f4d 100644
@@ -366,7 +366,6 @@ allow test_filesystem_inode_setxattr_no_associate_t test_file_t:file { create re
 #
 ############### Rules for NFS mount ##################
 #
-userdom_search_user_home_content(filesystemdomain)
 allow test_filesystem_t test_filesystem_file_t:filesystem { getattr mount remount unmount relabelto relabelfrom };
 allow test_filesystem_t test_file_t:file { create write relabelfrom };
 allow test_file_t test_filesystem_file_t:filesystem { associate };
policy/test_filesystem_notify.te +0 -1
index 30056e4..77d46ae 100644
@@ -16,7 +16,6 @@ allow test_filesystem_t dosfs_t:filesystem { watch };
 #
 ############### Rules for NFS mount with rootcontext option #################
 #
-userdom_search_user_home_content(filesystemdomain)
 allow test_filesystem_no_watch_mount_t nfs_t:filesystem { unmount };
 allow test_filesystem_no_watch_mount_t test_filesystem_file_t:dir { search };
 allow test_filesystem_no_watch_sb_t nfs_t:filesystem { unmount watch };
policy/test_global.te +7 -0
index 052c7dd..0078485 100644
@@ -153,6 +153,13 @@ selinux_compute_create_context(testsuite_domain)
 selinux_compute_relabel_context(testsuite_domain)
 selinux_compute_user_contexts(testsuite_domain)
 
+userdom_search_user_home_content(testsuite_domain)
+# Refpolicy does not have admin_home_t - assume /root will be user_home_dir_t,
+# which is covered by the above call.
+ifdef(`userdom_search_admin_dir', `
+    userdom_search_admin_dir(testsuite_domain)
+')
+
 # Reference policy renamed files_list_pids() to files_list_runtime()
 ifdef(`files_list_pids', `
     files_list_pids(testsuite_domain)
policy/test_ipc.te +0 -2
index 678eca8..5e26384 100644
@@ -67,5 +67,3 @@ fs_rw_tmpfs_files(ipcdomain)
 
 allow test_ipc_base_t self:sem create_sem_perms;
 allow test_ipc_base_t self:shm create_shm_perms;
-# ipcrm needs this...
-userdom_search_user_home_dirs(test_ipc_base_t)
policy/test_overlayfs.te +0 -7
index ab589bb..c09b577 100644
@@ -45,10 +45,6 @@ kernel_search_proc(test_overlay_mounter_t)
 fs_relabelfrom_xattr_fs(test_overlay_mounter_t)
 fs_mount_xattr_fs(test_overlay_mounter_t)
 
-userdom_search_admin_dir(test_overlay_mounter_t)
-userdom_search_user_home_content(test_overlay_mounter_t)
-userdom_read_user_tmp_files(test_overlay_mounter_t)
-
 mount_exec(test_overlay_mounter_t)
 mount_rw_pid_files(test_overlay_mounter_t)
 
@@ -113,9 +109,6 @@ mcs_constrained(test_overlay_client_t)
 kernel_read_system_state(test_overlay_client_t)
 kernel_read_proc_symlinks(test_overlay_client_t)
 
-userdom_search_admin_dir(test_overlay_client_t)
-userdom_search_user_home_content(test_overlay_client_t)
-
 fs_getattr_xattr_fs(test_overlay_client_t)
 
 selinux_getattr_fs(test_overlay_client_t)
policy/test_policy.if +0 -7
index 5458f6c..b20baad 100644
@@ -82,13 +82,6 @@ interface(`mount_rw_pid_files', `
 ')
 ')
 
-# Refpolicy does not have admin_home_t - assume /root will be user_home_dir_t.
-ifdef(`userdom_search_admin_dir', `', ` dnl
-interface(`userdom_search_admin_dir', `
-    userdom_search_user_home_content($1)
-')
-')
-
 # If the macro is not defined, then most probably module_request permission
 # is just not supported (and relevant operations should be just allowed).
 ifdef(`kernel_request_load_module', `', ` dnl
policy/test_ptrace.te +0 -2
index 352ead5..1a8a10d 100644
@@ -27,7 +27,6 @@ allow test_ptrace_traced_t test_file_t:fifo_file rw_file_perms;
 
 # Allow the tracer domain to trace the traced domain.
 allow test_ptrace_tracer_t test_ptrace_traced_t:process ptrace;
-userdom_search_user_home_dirs(test_ptrace_traced_t)
 
 # Let the tracer wait on the traced domain.
 allow test_ptrace_traced_t test_ptrace_tracer_t:process sigchld;
--

2.41.0

author Applied
#2 lore raw
Quoted 15 lines · Stephen Smalley
Quoted 13 lines · Ondrej Mosnacek

The permissions are sometimes needed to resolve paths when running the testsuite from a user/admin home directory. To avoid cluttering individual policy files with macros that allow it, apply the macros to the whole testsuite_domain attribute. Thankfully this doesn't break the other tests.

This also fixes the inet_socket test, which started to require these permissions after a recent change.

While there, also remove userdom_read_user_tmp_files() from test_overlay_mounter_t, which doesn't seem to be needed.

Quoted 7 lines
Quoted 3 lines
Fixes 4dcea27ada77 ("tests/inet_socket: cover the MPTCP protocol")

All tests pass with this applied, thanks.

Thanks, applied:
https://github.com/SELinuxProject/selinux-testsuite/commit/ab02919a0f9db4b6f3d162073b93380d80478014

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