Bug 1343685

Summary: [PATCH] AVCS with systemd creating sockets for socket units
Product: [Fedora] Fedora Reporter: Tom Hughes <tom>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 24CC: antoine, dominick.grift, dwalsh, esm, j, lvrabec, mgrepl, mi, plautrba, tomek, yamato
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-08 14:47:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tom Hughes 2016-06-07 16:50:04 UTC
Description of problem:

Happens with both rsyncd.socket and auth.socket and errors both on initial creation and when accepting connections:

time->Tue Jun  7 16:24:30 2016
type=AVC msg=audit(1465313070.346:341): avc:  denied  { create } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:inetd_child_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 16:24:30 2016
type=AVC msg=audit(1465313070.346:342): avc:  denied  { setopt } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:inetd_child_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 16:24:30 2016
type=AVC msg=audit(1465313070.347:343): avc:  denied  { bind } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:inetd_child_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 16:24:30 2016
type=AVC msg=audit(1465313070.347:344): avc:  denied  { listen } for  pid=1 comm="systemd" lport=113 scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:inetd_child_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 16:24:30 2016
type=AVC msg=audit(1465313070.358:345): avc:  denied  { create } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:rsync_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 16:24:30 2016
type=AVC msg=audit(1465313070.358:346): avc:  denied  { setopt } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:rsync_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 16:24:30 2016
type=AVC msg=audit(1465313070.358:347): avc:  denied  { bind } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:rsync_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 16:24:30 2016
type=AVC msg=audit(1465313070.359:348): avc:  denied  { listen } for  pid=1 comm="systemd" lport=873 scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:rsync_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 17:32:21 2016
type=AVC msg=audit(1465317141.585:738): avc:  denied  { accept } for  pid=1 comm="systemd" lport=873 scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:rsync_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 17:32:21 2016
type=AVC msg=audit(1465317141.585:739): avc:  denied  { getattr } for  pid=1 comm="systemd" laddr=2001:8b0:bd:1:204:e2ff:fe22:eba9 lport=873 faddr=2001:8b0:bd:1:1881:14ff:fe46:3cc7 fport=59134 scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:rsync_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 17:47:30 2016
type=AVC msg=audit(1465318050.300:960): avc:  denied  { create } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:rsync_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 17:47:30 2016
type=AVC msg=audit(1465318050.301:961): avc:  denied  { setopt } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:rsync_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 17:47:30 2016
type=AVC msg=audit(1465318050.301:962): avc:  denied  { bind } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:rsync_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 17:47:30 2016
type=AVC msg=audit(1465318050.301:963): avc:  denied  { listen } for  pid=1 comm="systemd" lport=873 scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:rsync_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 17:47:30 2016
type=AVC msg=audit(1465318050.310:964): avc:  denied  { create } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:inetd_child_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 17:47:30 2016
type=AVC msg=audit(1465318050.310:965): avc:  denied  { setopt } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:inetd_child_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 17:47:30 2016
type=AVC msg=audit(1465318050.311:966): avc:  denied  { bind } for  pid=1 comm="systemd" scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:inetd_child_t:s0 tclass=tcp_socket permissive=1
----
time->Tue Jun  7 17:47:30 2016
type=AVC msg=audit(1465318050.311:967): avc:  denied  { listen } for  pid=1 comm="systemd" lport=113 scontext=system_u:system_r:init_t:s0 tcontext=system_u:system_r:inetd_child_t:s0 tclass=tcp_socket permissive=1

Version-Release number of selected component (if applicable):

selinux-policy-3.13.1-190.fc24.noarch

Comment 1 Jason Tibbitts 2016-08-17 13:41:24 UTC
I'm seeing the same thing here.  I run a small local socket activated service, which worked fine but can't be started at all under F24:

time->Wed Aug 17 08:40:44 2016
type=AVC msg=audit(1471441244.257:39423): 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=tcp_socket permissive=0

Comment 2 Jason Tibbitts 2016-08-17 14:05:29 UTC
I should add that this happens with selinux-policy-3.13.1-191.10.fc24.noarch, -191.11 and -191.12 (downloaded from Koji this morning).

Comment 3 Daniel Walsh 2016-08-18 13:34:51 UTC
policy_module(myinit, 1.0) 
gen_require(`
attribute domain
type init_t;
')
allow init_t domain:tcp_socket create_stream_socket_perms;

Lukas we should have a rule like this or maybe

allow init_t daemon:tcp_socket create_stream_socket_perms;

Comment 4 Daniel Walsh 2016-08-18 13:39:37 UTC
I guess we already have 
allow init_t daemon:tcp_socket create_stream_socket_perms;


So we need to make these other domains daemons.

Comment 5 Daniel Walsh 2016-08-18 13:54:43 UTC
I have created 

https://github.com/fedora-selinux/selinux-policy/pull/146

To fix these issues.

Comment 6 Jason Tibbitts 2016-08-19 15:22:15 UTC
Just so you know, that PR didn't seem to fix the issue for me.  I'm using the following, which fixes my local unconfined daemon but needs to be extended to cover rsync and probably a number of other daemons.

From cfb4d87f5a7c09b11c09d87a63008b7f1c5cf8ec Mon Sep 17 00:00:00 2001
From: Gary Tierney <gary.tierney>
Date: Thu, 18 Aug 2016 16:53:07 +0100
Subject: [PATCH] unconfined: associate unconfined services with the daemon
 attribute

---
 policy/modules/system/unconfined.te | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/policy/modules/system/unconfined.te b/policy/modules/system/unconfined.te
index a349d18..d899d07 100644
--- a/policy/modules/system/unconfined.te
+++ b/policy/modules/system/unconfined.te
@@ -1,12 +1,16 @@
 policy_module(unconfined, 3.5.0)

+gen_require(`
+    attribute daemon;
+')
+
 ########################################
 #
 # Declarations
 #
 attribute unconfined_services;

-type unconfined_service_t;
+type unconfined_service_t, daemon;
 domain_type(unconfined_service_t)
 role system_r types unconfined_service_t;

--
2.4.11

Comment 7 Fedora End Of Life 2017-07-25 21:02:23 UTC
This message is a reminder that Fedora 24 is nearing its end of life.
Approximately 2 (two) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 24. 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 '24'.

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 24 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 8 Fedora End Of Life 2017-08-08 14:47:21 UTC
Fedora 24 changed to end-of-life (EOL) status on 2017-08-08. Fedora 24 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.