Bug 1401550 - SELinux denial for rng-tools
Summary: SELinux denial for rng-tools
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: rng-tools
Version: 26
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jeff Garzik
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-12-05 14:42 UTC by Peter Gervase
Modified: 2018-05-29 11:22 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-05-29 11:22:11 UTC
Type: Bug


Attachments (Terms of Use)

Description Peter Gervase 2016-12-05 14:42:35 UTC
Description of problem:
I was doing a dnf update this morning and I got an SELinux error:
SELinux is preventing systemd from create access on the unix_stream_socket Unknown.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that systemd should be allowed create access on the Unknown unix_stream_socket by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'systemd' --raw | audit2allow -M my-systemd
# semodule -X 300 -i my-systemd.pp

Additional Information:
Source Context                system_u:system_r:init_t:s0
Target Context                system_u:system_r:unconfined_service_t:s0
Target Objects                Unknown [ unix_stream_socket ]
Source                        systemd
Source Path                   systemd
Port                          <Unknown>
Host                          pmg-w541.usersys.redhat.com
Source RPM Packages          
Target RPM Packages          
Policy RPM                    selinux-policy-3.13.1-227.fc26.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     pmg-w541.usersys.redhat.com
Platform                      Linux pmg-w541.usersys.redhat.com
                              4.9.0-0.rc6.git2.1.fc26.x86_64 #1 SMP Wed Nov 23
                              16:51:44 UTC 2016 x86_64 x86_64
Alert Count                   3
First Seen                    2016-12-05 08:03:27 EST
Last Seen                     2016-12-05 08:03:27 EST
Local ID                      ce150114-f43f-48c9-83c4-3ba656c85431

Raw Audit Messages
type=AVC msg=audit(1480943007.761:19327): avc:  denied  { create } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:unconfined_service_t:s0 tclass=unix_stream_socket permissive=0


Hash: systemd,init_t,unconfined_service_t,unix_stream_socket,create



I did the ausearch and just lots of output like:
[pgervase@pmg-w541 sat6]$ sudo ausearch -c 'systemd' --raw| tail -n 20
type=SERVICE_STOP msg=audit(1480942801.532:19285): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=sysstat-collect comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1480942801.672:19290): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=user@0 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_STOP msg=audit(1480942802.070:19304): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=user@0 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1480942819.730:19305): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=crond comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_STOP msg=audit(1480942819.730:19306): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=crond comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1480942819.742:19307): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=crond comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=AVC msg=audit(1480943007.446:19325): avc:  denied  { create } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:unconfined_service_t:s0 tclass=unix_stream_socket permissive=0
type=AVC msg=audit(1480943007.608:19326): avc:  denied  { create } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:unconfined_service_t:s0 tclass=unix_stream_socket permissive=0
type=AVC msg=audit(1480943007.761:19327): avc:  denied  { create } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:unconfined_service_t:s0 tclass=unix_stream_socket permissive=0
type=SERVICE_START msg=audit(1480943025.902:19328): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=crond comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_STOP msg=audit(1480943025.902:19329): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=crond comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1480943025.912:19330): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=crond comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1480943080.067:19331): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=lvm2-lvmetad comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1480943101.356:19345): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=user@0 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_STOP msg=audit(1480943101.945:19359): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=user@0 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1480943108.951:19360): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=fprintd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1480943138.780:19373): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=fprintd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_STOP msg=audit(1480943138.780:19374): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=fprintd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_START msg=audit(1480943160.773:19380): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dnf-makecache comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
type=SERVICE_STOP msg=audit(1480943160.773:19381): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dnf-makecache comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
[pgervase@pmg-w541 sat6]$ sudo ausearch -c 'systemd' --raw| wc -l
16032


and piping it to audit2allow, my te file is
$ cat my-systemd.te

module my-systemd 1.0;

require {
        type unconfined_service_t;
        type init_t;
        type httpd_tmp_t;
        class file unlink;
        class unix_stream_socket create;
}

#============= init_t ==============
allow init_t httpd_tmp_t:file unlink;
allow init_t unconfined_service_t:unix_stream_socket create;



# ps -efZ | grep unconfined_service_t
system_u:system_r:unconfined_service_t:s0 root 1701 1  0 Nov28 ?       00:00:03 /sbin/rngd -f

Looking at the systemd files,
# grep rngd /etc/systemd/* /usr/lib/systemd/* -R
/etc/systemd/system/multi-user.target.wants/rngd.service:ExecStart=/sbin/rngd -f
grep: /usr/lib/systemd/system/basic.target.wants/fedora-autorelabel-mark.service: No such file or directory
grep: /usr/lib/systemd/system/basic.target.wants/fedora-autorelabel.service: No such file or directory
/usr/lib/systemd/system/rngd.service:ExecStart=/sbin/rngd -f
/usr/lib/systemd/system-preset/90-default.preset:enable rngd.service

[root@pmg-w541 ~]# cat /usr/lib/systemd/system/rngd.service
[Unit]
Description=Hardware RNG Entropy Gatherer Daemon

[Service]
ExecStart=/sbin/rngd -f
SuccessExitStatus=66

[Install]
WantedBy=multi-user.target
[root@pmg-w541 ~]#

[root@pmg-w541 ~]# cat /usr/lib/systemd/system/rngd.service
[Unit]
Description=Hardware RNG Entropy Gatherer Daemon

[Service]
ExecStart=/sbin/rngd -f
SuccessExitStatus=66

[Install]
WantedBy=multi-user.target
[root@pmg-w541 ~]# systemctl status rngd
● rngd.service - Hardware RNG Entropy Gatherer Daemon
   Loaded: loaded (/usr/lib/systemd/system/rngd.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2016-11-28 20:31:38 EST; 6 days ago
 Main PID: 1701 (rngd)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/rngd.service
           └─1701 /sbin/rngd -f

Nov 28 20:31:38 pmg-w541.usersys.redhat.com systemd[1]: Started Hardware RNG Entropy Gatherer Daemon.
Nov 28 20:31:38 pmg-w541.usersys.redhat.com rngd[1701]: /dev/hwrng: No such device
[root@pmg-w541 ~]# 

[root@pmg-w541 sat6]# rpm -qf /sbin/rngd /usr/sbin/rngd
rng-tools-5-8.fc26.x86_64
rng-tools-5-8.fc26.x86_64
[root@pmg-w541 sat6]# ls -lZ /sbin/rngd /usr/sbin/rngd
-rwxr-xr-x. 1 root root system_u:object_r:bin_t:s0 24928 Oct 18 11:11 /sbin/rngd
-rwxr-xr-x. 1 root root system_u:object_r:bin_t:s0 24928 Oct 18 11:11 /usr/sbin/rngd
[root@pmg-w541 sat6]# md5sum /sbin/rngd /usr/sbin/rngd
1d8a14b08ca05477692a781f9b94e57e  /sbin/rngd
1d8a14b08ca05477692a781f9b94e57e  /usr/sbin/rngd
[root@pmg-w541 sat6]# 

# ls -lZ /usr/sbin/rngd ; restorecon -Rv /usr/sbin/rngd ; ls -lZ /usr/sbin/rngd
-rwxr-xr-x. 1 root root system_u:object_r:bin_t:s0 24928 Oct 18 11:11 /usr/sbin/rngd
restorecon reset /usr/sbin/rngd context system_u:object_r:bin_t:s0->system_u:object_r:rngd_exec_t:s0
-rwxr-xr-x. 1 root root system_u:object_r:rngd_exec_t:s0 24928 Oct 18 11:11 /usr/sbin/rngd

but systemd is calling /sbin/rngd, not /usr/sbin/rngd. I tried restorecon there and it stayed the same
[root@pmg-w541 sat6]# ls -lZ /sbin/rngd ; restorecon -Rv /sbin/rngd ; ls -lZ /sbin/rngd
-rwxr-xr-x. 1 root root system_u:object_r:rngd_exec_t:s0 24928 Oct 18 11:11 /sbin/rngd
-rwxr-xr-x. 1 root root system_u:object_r:rngd_exec_t:s0 24928 Oct 18 11:11 /sbin/rngd


Version-Release number of selected component (if applicable):
rng-tools-5-8.fc26.x86_64
selinux-policy-targeted-3.13.1-227.fc26.noarch
selinux-policy-3.13.1-227.fc26.noarch

How reproducible:
Not sure

Steps to Reproduce:
1. Not sure... this is the only time I've noticed this, but it's possibly happened other times and I missed the notice.
2.
3.

Actual results:
SELinux messages as shown above

Expected results:
No SELinux messages

Additional info:
Why aren't /sbin/rngd and /usr/sbin/rngd symlink or if no need to symlink, why have two of the same files /sbin/rngd and /usr/sbin/rngd?

Comment 1 Simon Sekidde 2016-12-05 14:58:06 UTC
If /sbin/rngd is rngd_exec_t then this should work

 init_t @ rngd_exec_t --> rngd_t

and 

  allow init_t daemon : unix_stream_socket { ioctl read write create getattr setattr lock append bind connect listen accept getopt setopt shutdown } ;

Comment 2 Fedora End Of Life 2017-02-28 10:43:59 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 26 development cycle.
Changing version to '26'.

Comment 3 Fedora End Of Life 2018-05-03 08:46:31 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 4 Fedora End Of Life 2018-05-29 11:22:11 UTC
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
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.