Bug 1162811 - Disabling the 'unconfined' module broke setroubleshootd
Summary: Disabling the 'unconfined' module broke setroubleshootd
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
URL:
Whiteboard:
Depends On:
Blocks: 1165713 1165734
TreeView+ depends on / blocked
 
Reported: 2014-11-11 18:18 UTC by Alphonse Steiner
Modified: 2016-07-19 12:23 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
: 1165713 (view as bug list)
Environment:
Last Closed: 2016-07-19 12:23:27 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Fix compilation errors (10.73 KB, patch)
2014-11-13 14:01 UTC, Alphonse Steiner
no flags Details | Diff
cython module (3.65 KB, text/plain)
2014-11-13 14:03 UTC, Alphonse Steiner
no flags Details
c code (669 bytes, text/x-csrc)
2014-11-13 14:04 UTC, Alphonse Steiner
no flags Details
Makefile (1.05 KB, text/plain)
2014-11-13 14:09 UTC, Alphonse Steiner
no flags Details
c code (279 bytes, text/x-csrc)
2014-11-13 17:59 UTC, Alphonse Steiner
no flags Details
cython module (3.56 KB, text/plain)
2014-11-13 18:03 UTC, Alphonse Steiner
no flags Details
Makefile (370 bytes, text/plain)
2014-11-15 14:40 UTC, Alphonse Steiner
no flags Details

Description Alphonse Steiner 2014-11-11 18:18:12 UTC
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

Comment 1 Alphonse Steiner 2014-11-13 13:58:25 UTC
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

Comment 2 Alphonse Steiner 2014-11-13 14:01:50 UTC
Created attachment 957174 [details]
Fix compilation errors

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

Comment 3 Alphonse Steiner 2014-11-13 14:03:07 UTC
Created attachment 957175 [details]
cython module

Hasty conversion of the scrypt into a cython module.

Comment 4 Alphonse Steiner 2014-11-13 14:04:21 UTC
Created attachment 957176 [details]
c code

Hasty written c code to launch the daemon.

Comment 5 Alphonse Steiner 2014-11-13 14:09:41 UTC
Created attachment 957179 [details]
Makefile

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

Comment 6 Alphonse Steiner 2014-11-13 17:59:45 UTC
Created attachment 957243 [details]
c code

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.

Comment 7 Alphonse Steiner 2014-11-13 18:03:17 UTC
Created attachment 957244 [details]
cython module

The corresponding module.

Comment 8 Alphonse Steiner 2014-11-13 21:00:40 UTC
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.

Comment 9 Alphonse Steiner 2014-11-15 14:40:50 UTC
Created attachment 957804 [details]
Makefile

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

Comment 10 Miroslav Grepl 2014-11-19 14:23:47 UTC
(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.

Comment 11 Jaroslav Reznik 2015-03-03 17:05:12 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22

Comment 12 Fedora End Of Life 2016-07-19 12:23:27 UTC
Fedora 22 changed to end-of-life (EOL) status on 2016-07-19. Fedora 22 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


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