Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
While trying to implement BZ #2181514, I tried creating a CIL module with "neverallow" rules. Once module got loaded (without error), I would have expected to have the "neverallow" rules be listed in the policy and to have some effect (since module is at highest priority) but none of those was observed:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# yum -y install fapolicyd
# systemctl start fapolicyd
# sesearch --neverallow
--> no Neverallow rules listed
# echo "(neverallow domain fapolicyd_t (process (sigstop ptrace)))" > protect_fapolicyd.cil
# semodule -i protect_fapolicyd.cil
--> no error / no warning
# bunzip2 -c /var/lib/selinux/targeted/active/modules/400/protect_fapolicyd/cil
(neverallow domain fapolicyd_t (process (sigstop ptrace)))
--> module loaded and present in policy
# sesearch --neverallow
--> Still no Neverallow rules listed
# pkill -STOP fapolicyd
--> Still possible, system hangs as one would expect
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
Questions:
1. Is that expected to no have any "neverallow" rule and not be able to use this?
2. If so, how can we achieve the functionality we want, i.e. override the policy to disable specific operations on specific domains?
Version-Release number of selected component (if applicable):
Tested up to 8.8 beta:
selinux-policy-3.14.3-117.el8.noarch
libselinux-2.9-6.el8.x86_64
How reproducible:
Always, see above.
(In reply to Renaud Métrich from comment #0)
> Questions:
>
> 1. Is that expected to no have any "neverallow" rule and not be able to use
> this?
This is expected. From https://github.com/SELinuxProject/selinux-notebook/blob/main/src/avc_rules.md#neverallow :
The neverallow statement is a compiler enforced action, where the checkpolicy(8), checkmodule(8)1 or secilc(8)2 compiler checks if any allow rules have been generated in the policy source, if so it will issue a warning and stop.
and
neverallow statements are allowed in modules, however to detect these the semanage.conf file must have the 'expand-check=1' entry present.
So neverallow rules are checked only during policy build and only if semanage.conf contains 'expand-check=1'
>
> 2. If so, how can we achieve the functionality we want, i.e. override the
> policy to disable specific operations on specific domains?
The current version doesn't support deny or drop rules but it's already proposed upstream - https://lore.kernel.org/selinux/20230309215114.357831-2-jwcart2@gmail.com/
If you need to disable a specific rule you need to drop the rule from the module where it's defined, e.g.:
$ sudo semodule -c -E fapolicyd
# edit fapolicy.cil
$ sudo semodule -X 400 -i fapolicyd
OK, thanks for the explanation.
Unfortunately the *sigstop* operation we want to disallow here is embedded in the main policy and applies to all domains:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
interface(`domain_sigstop_all_domains',`
gen_require(`
attribute domain;
')
allow $1 domain:process sigstop;
')
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
Such default rule prevents restricting for a specific target domain (here fapolicyd_t)