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.
Bug 2221251 - Redundant line in mozilla.if causes problems compiling non-standard modules
Summary: Redundant line in mozilla.if causes problems compiling non-standard modules
Keywords:
Status: CLOSED ERRATA
Alias: None
Deadline: 2023-08-08
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: selinux-policy
Version: 9.2
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Nobody
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-07-07 16:30 UTC by Roger Sewell
Modified: 2023-11-07 11:23 UTC (History)
3 users (show)

Fixed In Version: selinux-policy-38.1.20-1.el9
Doc Type: Bug Fix
Doc Text:
Cause: Nsplugin module was removed from SELinux policy, but interface nsplugin_role was still included in mozilla_role interface, which caused syntax error, when using this interface. Consequence: Redundant line in mozilla.if causes problems when compiling additional selinux modules Fix: Remove nsplugin_role from mozilla.if Result: No more syntax errors when compiling selinux modules
Clone Of:
Environment:
Last Closed: 2023-11-07 08:52:30 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-161799 0 None None None 2023-07-07 16:32:54 UTC
Red Hat Product Errata RHBA-2023:6617 0 None None None 2023-11-07 08:52:45 UTC

Description Roger Sewell 2023-07-07 16:30:51 UTC
Description of problem: Redundant line in mozilla.if causes problems when compiling additional selinux modules


Version-Release number of selected component (if applicable): 38.1.11-2.el9_2.3

How reproducible: Always


Steps to Reproduce:
1. Install the above version of selinux-policy, selinux-policy-targeted, selinux-policy-doc, and selinux-policy-devel .

2. Write a simple module additional module called say mymodule.te .

3. From the directory containing mymodule.te, which should not contain any wanted subdirectory called tmp, issue the commands
 
\rm -rf tmp
make mymodule.pp


Actual results: Syntax error at line nnnn of tmp/.... at token nsplugin_role


Expected results: Successful compilation


Additional info: I assume that this is because there is no longer a module nsplugin in this current version of selinux. I note also that the line containing nsplugin_role in mozilla.if is optional_policy, and that it compiles fine when the source package is built - but it doesn't when additional modules are compiled using the selinux-devel make system - perhaps this is an additional issue (I'm not sure).

Comment 1 Nikola Knazekova 2023-07-14 13:28:56 UTC
Hi Roger, 

I tried to reproduce the issue but everything works properly:

# rpm -qa selinux-policy*
selinux-policy-38.1.11-2.el9_2.3.noarch
selinux-policy-targeted-38.1.11-2.el9_2.3.noarch
selinux-policy-devel-38.1.11-2.el9_2.3.noarch
selinux-policy-doc-38.1.11-2.el9_2.3.noarch

# sepolicy generate --init /usr/bin/wget
Created the following files:
/root/wget-selinux/wget.te # Type Enforcement file
/root/wget-selinux/wget.if # Interface file
/root/wget-selinux/wget.fc # File Contexts file
/root/wget-selinux/wget_selinux.spec # Spec file
/root/wget-selinux/wget.sh # Setup Script

# rm -rf tmp

# make -f /usr/share/selinux/devel/Makefile wget.pp
Compiling targeted wget module
Creating targeted wget.pp policy package
rm tmp/wget.mod tmp/wget.mod.fc

# semodule -i wget.pp

# semodule -lfull | grep wget
400 wget                  pp

Comment 2 Roger Sewell 2023-07-14 19:10:10 UTC
Nikola,

I'm very sorry - on further investigation I now realise I needed to give you another piece of information, namely the contents of the .te file being compiled. After paring it down to the minimum possible that still shows the problem, the following file (whose contents is now of course pointless) demonstrates the bug:

<unconfmoz.te contains:>

policy_module(unconfmoz, 1.1)

gen_require(`
        role unconfined_r;
        type unconfined_t;
')


mozilla_role(unconfined_r, unconfined_t)

<end of file>

then on doing 

make -f /usr/share/selinux/devel/Makefile unconfmoz.pp

I get

Compiling targeted unconfmoz module
unconfmoz.te:9:ERROR 'syntax error' at token 'nsplugin_role' on line 4246:
	       nsplugin_role(unconfined_r, mozilla_t)
#line 9
/usr/bin/checkmodule:  error(s) encountered while parsing configuration
make: *** [/usr/share/selinux/devel/include/Makefile:157: tmp/unconfmoz.mod] Error 1

If, however, I replace the mozilla module with one with the line containing nsplugin_role removed from mozilla.if then it compiles correctly.

(If it's any consolation, your time has not been totally wasted - I had not realised before how useful the sepolicy generate --init command was - so thank you for the education.)

Thanks, Roger.

Comment 3 Nikola Knazekova 2023-07-18 13:46:42 UTC
Hi Roger, 

you are right with the nsplugin, we will investigate it.  

For the loadable modules is good to use optional policy block:

optional_policy(`
       mozilla_role(unconfined_r, unconfined_t)
')

https://selinuxproject.org/page/PolicyStatements

Comment 4 Roger Sewell 2023-07-18 18:43:38 UTC
Nikola,
Thank you for the further education - appreciated.
Roger.

Comment 5 Nikola Knazekova 2023-08-08 08:54:57 UTC
PR: https://github.com/fedora-selinux/selinux-policy/pull/1821

Comment 16 errata-xmlrpc 2023-11-07 08:52:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (selinux-policy bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:6617


Note You need to log in before you can comment on or make changes to this bug.