Bug 1165065

Summary: [ipsec_t] SELinux is preventing charon from unlink access on the sock_file charon.vici.
Product: [Fedora] Fedora Reporter: Juan Orti Alcaine <jorti>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 21CC: dominick.grift, dwalsh, jorti, lvrabec, mgrepl, plautrba
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: selinux-policy-3.13.1-99.fc21 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-12-03 17:15:30 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 Juan Orti Alcaine 2014-11-18 09:19:32 UTC
strongswan-5.2.0-4.fc21.x86_64 creates a new socket in /run/charon.vici I don't know what it is for.


SELinux is preventing charon from unlink access on the sock_file charon.vici.

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

If you believe that charon should be allowed unlink access on the charon.vici sock_file 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:
# grep charon /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:ipsec_t:s0
Target Context                system_u:object_r:var_run_t:s0
Target Objects                charon.vici [ sock_file ]
Source                        charon
Source Path                   charon
Port                          <Unknown>
Host                          foo.example.com
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-92.fc21.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     foo.example.com
Platform                      Linux foo.example.com 3.17.3-300.fc21.x86_64 #1
                              SMP Fri Nov 14 23:36:19 UTC 2014 x86_64 x86_64
Alert Count                   1
First Seen                    2014-11-17 21:26:02 CET
Last Seen                     2014-11-17 21:26:02 CET
Local ID                      f684350a-0d4e-4247-914c-2c58f4323dd0

Raw Audit Messages
type=AVC msg=audit(1416255962.798:7027): avc:  denied  { unlink } for  pid=7804 comm="charon" name="charon.vici" dev="tmpfs" ino=15282 scontext=system_u:system_r:ipsec_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=sock_file permissive=0


Hash: charon,ipsec_t,var_run_t,sock_file,unlink

Comment 1 Lukas Vrabec 2014-11-19 09:48:50 UTC
How did you start stongswan? 

Please paste output:
$ ps -efZ 

Thank you

Comment 2 Juan Orti Alcaine 2014-11-19 09:57:09 UTC
LABEL                           UID        PID  PPID  C STIME TTY          TIME CMD
system_u:system_r:ipsec_t:s0    root     23781     1  0 nov18 ?        00:00:00 /usr/libexec/strongswan/starter --daemon charon --nofork
system_u:system_r:ipsec_t:s0    root     23790 23781  0 nov18 ?        00:03:22 /usr/libexec/strongswan/charon

Comment 3 Lukas Vrabec 2014-11-19 10:09:42 UTC
and 
# ls -Z /run | grep charon

Comment 4 Juan Orti Alcaine 2014-11-19 10:29:38 UTC
# ls -Z /run |grep charon
srwxrwx---. root   root       system_u:object_r:ipsec_var_run_t:s0 charon.ctl
-rw-rw----. root   root       system_u:object_r:ipsec_var_run_t:s0 charon.pid
srwxrwx---. root   root       system_u:object_r:var_run_t:s0   charon.vici
-rw-r--r--. root   root       system_u:object_r:ipsec_var_run_t:s0 starter.charon.pid

Comment 5 Lukas Vrabec 2014-11-19 10:35:44 UTC
I cannot reproduce it.

My ls:
$ ls -Z | grep charon
srwxrwx---. root    root    system_u:object_r:ipsec_var_run_t:s0 charon.ctl
srwxrwx---. root    root    system_u:object_r:ipsec_var_run_t:s0 charon.vici

please use:
#restorecon -v /var/run/charon.vici

This should fix your issue.

I close this bug. If this happen again please re-open this.

Comment 6 Juan Orti Alcaine 2014-11-19 10:52:41 UTC
Sorry, but restorecon doesn't fix the label, I have:

#  semanage fcontext -l |grep ipsec_var_run_t
/var/racoon(/.*)?                                  all files          system_u:object_r:ipsec_var_run_t:s0
/var/run/charon.*                                  regular file       system_u:object_r:ipsec_var_run_t:s0
/var/run/charon\.ctl                               socket             system_u:object_r:ipsec_var_run_t:s0
/var/run/pluto(/.*)?                               all files          system_u:object_r:ipsec_var_run_t:s0
/var/run/racoon\.pid                               regular file       system_u:object_r:ipsec_var_run_t:s0

# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      29

# rpm -q selinux-policy
selinux-policy-3.13.1-92.fc21.noarch

I have checked another machine and the fcontexts are the same.

Comment 7 Lukas Vrabec 2014-11-19 12:07:11 UTC
please run:
$ matchpathcon /run/charon.vici

Comment 8 Juan Orti Alcaine 2014-11-19 13:29:57 UTC
Well, something is weird here, I have relabelled this machine, a Fedora 21 Server, and now the socket is created with the right label, but matchpathcon shows var_run_t. I installed it from the Alpha F21 ISO, don't know if it's related.

Why doesn't matchpathcon show the right label?

# touch /.autorelabel; reboot
# matchpathcon /run/charon.vici
/run/charon.vici        system_u:object_r:var_run_t:s0
# ls -laZ /run/charon.vici
srwxrwx---. root root system_u:object_r:ipsec_var_run_t:s0 /run/charon.vici
# ps -efZ |grep charon
system_u:system_r:ipsec_t:s0    root      5653     1  0 14:09 ?        00:00:00 /usr/libexec/strongswan/starter --daemon charon --nofork
system_u:system_r:ipsec_t:s0    root      5663  5653  0 14:09 ?        00:00:03 /usr/libexec/strongswan/charon

Close the bug if you want, as it now works.
Thanks for your help.

Comment 9 Lukas Vrabec 2014-11-19 13:53:04 UTC
What is selinux-policy package version of this system?

Comment 12 Lukas Vrabec 2014-11-19 14:12:50 UTC
commit 8b73d37f5f4c450cd06eb2bb3d6fcf994b75a4b7
Author: Lukas Vrabec <lvrabec>
Date:   Wed Nov 19 15:09:51 2014 +0100

    Label sock file charon.vici as ipsec_var_run_t. BZ(1165065)

Comment 13 Fedora Update System 2014-11-21 12:24:09 UTC
selinux-policy-3.13.1-99.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/selinux-policy-3.13.1-99.fc21

Comment 14 Fedora Update System 2014-12-03 17:15:30 UTC
selinux-policy-3.13.1-99.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.