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 1165734 - Disabling the 'unconfined' module broke setroubleshootd
Summary: Disabling the 'unconfined' module broke setroubleshootd
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy
Version: 7.1
Hardware: All
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: Miroslav Grepl
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On: 1162811 1165713
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-19 14:49 UTC by Miroslav Grepl
Modified: 2015-07-21 11:41 UTC (History)
9 users (show)

Fixed In Version: selinux-policy-3.13.1-11.el7
Doc Type: Bug Fix
Doc Text:
Clone Of: 1165713
Environment:
Last Closed: 2015-03-05 10:47:10 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:0458 0 normal SHIPPED_LIVE selinux-policy bug fix and enhancement update 2015-03-05 15:17:00 UTC

Description Miroslav Grepl 2014-11-19 14:49:35 UTC
+++ This bug was initially created as a clone of Bug #1165713 +++

+++ This bug was initially created as a clone of Bug #1162811 +++

Description of problem:
After disabling the 'unconfined' module, the rule 
    $ sesearch -A -C -s system_dbusd_t -p execute -t bin_t
    Found 1 semantic av rules:
        allow system_dbusd_t bin_t : file { read getattr execute open } ;
disappears.
Setroubleshootd failed to be activated after that, generating the AVC:
-----
type=AVC msg=audit(1415725718.861:15433): avc:  denied  { execute } for  pid=31406 comm="dbus-daemon-lau" name="python2.7" dev="vda" ino=803242 scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:bin_t:s0 tclass=file permissive=0
-----

The activation is retried again and again, locking the cpu and filling the audit log with the same denial message.

This did not occur in fedora 19, where the rule was present independantly of the 'unconfined' module.

selinux-policy version: 3.13.1-92

--- Additional comment from Alphonse Steiner on 2014-11-13 08:58:25 EST ---

I have found a solution: to build a binary version of setroubleshootd, using cython.
I wonder how to compare its performance with the python script. Does anybody have an idea?
I am attaching the patch & files. Note that the files are mainly a proof of concept: the binary built is currently working as a replacement of the daemon, but I have only implemented one option (-f). It was written 'in haste', so there is still work to do.

Version used: setroubleshoot-3.2.20-3

--- Additional comment from Alphonse Steiner on 2014-11-13 09:01:50 EST ---

Fix cython compilation errors:
 - replace tabs by spaces;
 - remove unreechable part;
 - remove never-defined functions & variables un uuid.py

--- Additional comment from Alphonse Steiner on 2014-11-13 09:03:07 EST ---

Hasty conversion of the scrypt into a cython module.

--- Additional comment from Alphonse Steiner on 2014-11-13 09:04:21 EST ---

Hasty written c code to launch the daemon.

--- Additional comment from Alphonse Steiner on 2014-11-13 09:09:41 EST ---

The makefile used to build the binary daemon.
To build:
 - apply the patch;
 - copy the .c, .pyx files & Makefile in the setroubleshoot directory;
 - run 'make setroubleshootd_c'

To test:
 - copy the binary setroubleshootd_c in /usr/sbin/
 - chcon -v --reference /usr/sbin/setroubleshootd{,_c} 
 - modify /usr/share/dbus-1/system-services/org.fedoraproject.Setroubleshootd.service to use the binary daemon;
 - reboot

--- Additional comment from Alphonse Steiner on 2014-11-13 12:59:45 EST ---

I finally found how to pass argv to the cython module.
Now, the binary daemon should be a perfect candidate as a replacement of the script daemon.
The makefile & cython module should be revised, though.

--- Additional comment from Alphonse Steiner on 2014-11-13 13:03:17 EST ---

The corresponding module.

--- Additional comment from Alphonse Steiner on 2014-11-13 16:00:40 EST ---

Actually, only the c code & cython module have to be compiled to build the binary: it loads the python modules at runtime.
I though that they could be compiled and embeded, but strace shows it is not the case. So, there are probably no gain in performance: it just fixes the current bug.

--- Additional comment from Alphonse Steiner on 2014-11-15 09:40:50 EST ---

In the end I cannot find a way to embed the python files.
So, this bug can be solved using only the attached .c file and .pyx cython module, to build a binary version of setroubleshootd using this Makefile.
The gain in performance is probably only at startup (around twice time faster).
Here some time comparison between the script and the stripped binary version:

$ time setroubleshootd -h
real: ~0.380s

$ time setroubleshootd_c -h
real: ~0.200s

--- Additional comment from Miroslav Grepl on 2014-11-19 09:23:47 EST ---

(In reply to Alphonse Steiner from comment #0)
> Description of problem:
> After disabling the 'unconfined' module, the rule 
>     $ sesearch -A -C -s system_dbusd_t -p execute -t bin_t
>     Found 1 semantic av rules:
>         allow system_dbusd_t bin_t : file { read getattr execute open } ;
> disappears.
> Setroubleshootd failed to be activated after that, generating the AVC:
> -----
> type=AVC msg=audit(1415725718.861:15433): avc:  denied  { execute } for 
> pid=31406 comm="dbus-daemon-lau" name="python2.7" dev="vda" ino=803242
> scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023
> tcontext=system_u:object_r:bin_t:s0 tclass=file permissive=0
> -----
> 
> The activation is retried again and again, locking the cpu and filling the
> audit log with the same denial message.
> 
> This did not occur in fedora 19, where the rule was present independantly of
> the 'unconfined' module.
> 
> selinux-policy version: 3.13.1-92

Nice catch. This is caused by


commit 13e05612c9d08eb4a7a791965b2f6733c27deb10
Author: Miroslav Grepl <mgrepl>
Date:   Thu Sep 18 16:06:07 2014 +0200

    We want to have also unconfined D-bus services running as unconfined_service_t instead of initrc_t.

--- Additional comment from Miroslav Grepl on 2014-11-19 09:47:52 EST ---

The point is we want to have


system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 8823 ? 00:00:00 unconfined_dbus_service

for unconfined dbus service if unconfined.pp is disabled and have

system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 10605 ? 00:00:00 unconfined_dbus_service

if unconfined.pp is enabled.

--- Additional comment from Miroslav Grepl on 2014-11-19 09:48:30 EST ---

commit c0c6b7d012b4dc271aee472632367e386644976a
Author: Miroslav Grepl <mgrepl>
Date:   Wed Nov 19 15:47:53 2014 +0100

    Allow systemd_dbus_t to execute bin_t in the caller domain if unconfined.pp is disabled to have unconfined dbus service running as system_dbusd_t.

Comment 5 errata-xmlrpc 2015-03-05 10:47:10 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, 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://rhn.redhat.com/errata/RHBA-2015-0458.html


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