Skip to contentSkip to conversation

policy: do not modify the allow_domain_fd_use boolean

PATCH Superseded Stephen Smalley 2 participants 2 messages Nov 10, 2025 SELinux security module

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Stephen Smalley

author maintainer
#0 lore raw

PATCH 1/1 policy: do not modify the allow_domain_fd_use boolean

Modifying the allow_domain_fd_use boolean value during testsuite execution is increasingly triggering breakage on Fedora since its policy defaults to 1/true, to the point that you can't ssh or even console login to a VM while the testsuite is running or even afterward if the testsuite encounters any failures. Instead of modifying this boolean, just update the relevant test domains to use the _minimal interface so they do not inherit this rule by default and add any required allowed rules to them.

---
 policy/Makefile          | 6 ------
 policy/test_binder.te    | 3 ++-
 policy/test_fdreceive.te | 4 +++-
 policy/test_global.te    | 2 ++
 policy/test_inherit.te   | 3 ++-
 5 files changed, 9 insertions(+), 9 deletions(-)
policy/Makefile +0 -6
index 520f891..0446f87 100644
@@ -219,16 +219,10 @@ build: $(TARGETS)
 
 load: expand_check all
 	# General policy load
-	@if /usr/sbin/getsebool allow_domain_fd_use 2> /dev/null; then \
-		/usr/sbin/setsebool allow_domain_fd_use=0; \
-	fi
 	$(SEMODULE) -i test_policy/test_policy.pp $(CIL_TARGETS)
 
 unload:
 	# General policy unload
-	@if /usr/sbin/getsebool allow_domain_fd_use 2> /dev/null; then \
-		/usr/sbin/setsebool allow_domain_fd_use=1; \
-	fi
 	$(SEMODULE) -r test_policy $(subst .cil,,$(CIL_TARGETS))
 
 clean:
policy/test_binder.te +2 -1
index 4c7974a..a267a85 100644
@@ -42,7 +42,8 @@ allow test_binder_provider_no_fd_t test_file_t:fifo_file rw_file_perms;
 ################################# Client ####################################
 #
 type test_binder_client_t;
-testsuite_domain_type(test_binder_client_t)
+# Must use _minimal interface to avoid granting domain fd use permission
+testsuite_domain_type_minimal(test_binder_client_t)
 typeattribute test_binder_client_t binderdomain;
 allow test_binder_client_t test_binder_provider_t:binder { call impersonate };
 allow test_binder_client_t test_binder_mgr_t:binder { call };
policy/test_fdreceive.te +3 -1
index df9e974..805e04e 100644
@@ -27,7 +27,9 @@ typeattribute test_fdreceive_client2_t fdreceivedomain;
 # Can receive fds from client, not from client2.
 # Can access test file, not second test file.
 type test_fdreceive_server_t;
-testsuite_domain_type(test_fdreceive_server_t);
+# Use the _minimal interface to avoid allowing fd use by default
+testsuite_domain_type_minimal(test_fdreceive_server_t)
+allow test_fdreceive_server_t self:unix_stream_socket create_stream_socket_perms;
 typeattribute test_fdreceive_server_t fdreceivedomain;
 
 # Grant the necessary permissions for the server domain.
policy/test_global.te +2 -0
index 0078485..4978993 100644
@@ -23,6 +23,8 @@ optional_policy(`
 
 	# Transition from the caller to the test domain.
 	allow unconfined_t testsuite_domain:process transition;
+	# Kill the test domain as needed.
+	allow unconfined_t testsuite_domain:process sigkill;
 	role unconfined_r types testsuite_domain;
 	# Report back from the test domain to the caller.
 	allow testsuite_domain unconfined_t:fd use;
policy/test_inherit.te +2 -1
index da26ea3..7e09534 100644
@@ -22,7 +22,8 @@ typeattribute test_inherit_child_t inheritdomain;
 # Domain for child process that cannot inherit from parent due to lack
 # of fd use permission.
 type test_inherit_nouse_t;
-testsuite_domain_type(test_inherit_nouse_t)
+# Use the _minimal interface to avoid allowing fd use by default
+testsuite_domain_type_minimal(test_inherit_nouse_t)
 typeattribute test_inherit_nouse_t inheritdomain;
 
 # Domain for child process that cannot inherit r/w fd to test file
Signature · 1 line
2.51.1
#1 lore raw
Quoted 10 lines · Stephen Smalley

Modifying the allow_domain_fd_use boolean value during testsuite execution is increasingly triggering breakage on Fedora since its policy defaults to 1/true, to the point that you can't ssh or even console login to a VM while the testsuite is running or even afterward if the testsuite encounters any failures. Instead of modifying this boolean, just update the relevant test domains to use the _minimal interface so they do not inherit this rule by default and add any required allowed rules to them.

Quoted 8 lines
---
 policy/Makefile          | 6 ------
 policy/test_binder.te    | 3 ++-
 policy/test_fdreceive.te | 4 +++-
 policy/test_global.te    | 2 ++
 policy/test_inherit.te   | 3 ++-
 5 files changed, 9 insertions(+), 9 deletions(-)

I like this idea! Needs one small tweak to not break running the suite from sysadm_t, though (see below).

Quoted 56 lines
policy/Makefile +0 -6
index 520f891..0446f87 100644
@@ -219,16 +219,10 @@ build: $(TARGETS)
 
 load: expand_check all
        # General policy load
-       @if /usr/sbin/getsebool allow_domain_fd_use 2> /dev/null; then \
-               /usr/sbin/setsebool allow_domain_fd_use=0; \
-       fi
        $(SEMODULE) -i test_policy/test_policy.pp $(CIL_TARGETS)
 
 unload:
        # General policy unload
-       @if /usr/sbin/getsebool allow_domain_fd_use 2> /dev/null; then \
-               /usr/sbin/setsebool allow_domain_fd_use=1; \
-       fi
        $(SEMODULE) -r test_policy $(subst .cil,,$(CIL_TARGETS))
 
 clean:
policy/test_binder.te +2 -1
index 4c7974a..a267a85 100644
@@ -42,7 +42,8 @@ allow test_binder_provider_no_fd_t test_file_t:fifo_file rw_file_perms;
 ################################# Client ####################################
 #
 type test_binder_client_t;
-testsuite_domain_type(test_binder_client_t)
+# Must use _minimal interface to avoid granting domain fd use permission
+testsuite_domain_type_minimal(test_binder_client_t)
 typeattribute test_binder_client_t binderdomain;
 allow test_binder_client_t test_binder_provider_t:binder { call impersonate };
 allow test_binder_client_t test_binder_mgr_t:binder { call };
policy/test_fdreceive.te +3 -1
index df9e974..805e04e 100644
@@ -27,7 +27,9 @@ typeattribute test_fdreceive_client2_t fdreceivedomain;
 # Can receive fds from client, not from client2.
 # Can access test file, not second test file.
 type test_fdreceive_server_t;
-testsuite_domain_type(test_fdreceive_server_t);
+# Use the _minimal interface to avoid allowing fd use by default
+testsuite_domain_type_minimal(test_fdreceive_server_t)
+allow test_fdreceive_server_t self:unix_stream_socket create_stream_socket_perms;
 typeattribute test_fdreceive_server_t fdreceivedomain;
 
 # Grant the necessary permissions for the server domain.
policy/test_global.te +0 -0
index 0078485..4978993 100644

policy/test_global.te optional_policy(` · line 27

Quoted 5 lines
policy/test_global.te +2 -0
@@ -23,6 +23,8 @@ optional_policy(`
 
        # Transition from the caller to the test domain.
        allow unconfined_t testsuite_domain:process transition;
+       # Kill the test domain as needed.
+       allow unconfined_t testsuite_domain:process sigkill;

This actually needs to be:

allow testsuite_caller_domain testsuite_domain:process sigkill;

...otherwise running the testsuite under sysadm_t becomes broken.

Quoted 20 lines
policy/test_global.te +0 -0
        role unconfined_r types testsuite_domain;
        # Report back from the test domain to the caller.
        allow testsuite_domain unconfined_t:fd use;
policy/test_inherit.te +2 -2
index da26ea3..7e09534 100644
@@ -22,7 +22,8 @@ typeattribute test_inherit_child_t inheritdomain;
 # Domain for child process that cannot inherit from parent due to lack
 # of fd use permission.
 type test_inherit_nouse_t;
-testsuite_domain_type(test_inherit_nouse_t)
+# Use the _minimal interface to avoid allowing fd use by default
+testsuite_domain_type_minimal(test_inherit_nouse_t)
 typeattribute test_inherit_nouse_t inheritdomain;
 
 # Domain for child process that cannot inherit r/w fd to test file
--

2.51.1

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