From 7b92b9503497cc41f7ac061ea4c6e8ee8dec8bbb Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Wed, 14 Oct 2026 17:28:02 -0300 Subject: [PATCH] test(xcat-core): capture the client exec that SELinux refuses A client command run from unconfined_t fails under enforcing: /opt/xcat/bin/lsxcatd: /usr/bin/perl: bad interpreter: Permission denied Measured on xcat162-mn-tmp-286, AlmaLinux 10.2, with the module loaded and the entrypoints labelled. The same command returns 0 under setenforce 0. The transition computes unconfined_u:unconfined_r:xcat_t, and the module does not authorize unconfined_r for xcat_t, so the context is invalid and the kernel refuses the exec. The permissive declaration does not help, because an invalid context is not a permission check. The record is SELINUX_ERR, op=security_compute_sid, which no AVC query finds. xcat_selinux_package.t asserts the role statement, and check 49 of 60 fails on this commit. selinux_client_domain asserts that lsxcatd returns 0 and prints its version under enforcing, that seinfo reports xcat_t for unconfined_r, and that the run leaves no invalid_context record. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/autotest/testcase/selinux/cases0 | 10 ++++++++++ xCAT-test/unit/xcat_selinux_package.t | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/xCAT-test/autotest/testcase/selinux/cases0 b/xCAT-test/autotest/testcase/selinux/cases0 index 649f542986..8a7961d35e 100644 --- a/xCAT-test/autotest/testcase/selinux/cases0 +++ b/xCAT-test/autotest/testcase/selinux/cases0 @@ -20,6 +20,8 @@ label:mn_only,selinux cmd:getenforce check:rc==0 check:output=~^Enforcing$ +cmd:sh -c 'date "+%x %T" > /tmp/selinux_client_domain.start' +check:rc==0 cmd:ls -Z /opt/xcat/bin/xcatclient check:rc==0 check:output=~:xcat_client_exec_t: @@ -36,8 +38,16 @@ check:rc==0 check:output=~xcat_t cmd:sesearch -T -s unconfined_t -t bin_t -c process check:output!~xcat_t +cmd:sh -c 'seinfo -runconfined_r -x | grep -w xcat_t' +check:rc==0 cmd:lsxcatd -v check:rc==0 +check:output=~^Version +cmd:sh -c 'ausearch --input-logs -m SELINUX_ERR -ts "$(cat /tmp/selinux_client_domain.start)" 2>&1 | grep -F invalid_context | wc -l' +check:rc==0 +check:output=~^0$ +cmd:rm -f /tmp/selinux_client_domain.start +check:rc==0 end start:selinux_mn_labels diff --git a/xCAT-test/unit/xcat_selinux_package.t b/xCAT-test/unit/xcat_selinux_package.t index 478d426592..e59621d7bd 100644 --- a/xCAT-test/unit/xcat_selinux_package.t +++ b/xCAT-test/unit/xcat_selinux_package.t @@ -211,6 +211,14 @@ my @domtrans = $te =~ /^\s*domtrans_pattern\((\w+), xcat_client_exec_t, xcat_t\) is_deeply(\@domtrans, ['unconfined_t'], 'only the unconfined domain transitions into xcat_t'); +# The transition computes unconfined_u:unconfined_r:xcat_t. Without this +# statement that context is invalid, and the kernel refuses the exec with +# EACCES whether or not xcat_t is permissive. A permissive domain does not +# help: an invalid context is not a permission check, and the record is +# SELINUX_ERR, which no AVC query finds. +like($te, qr/^\s*role unconfined_r types xcat_t;$/m, + 'unconfined_r is authorized for xcat_t'); + # A confined user domain that entered a permissive xcat_t would leave its own # confinement, so the module gives it no transition. foreach my $domain (qw(user_t staff_t sysadm_t guest_t xguest_t)) {