Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
The FDP team is no longer accepting new bugs in Bugzilla. Please report your issues under FDP project in Jira. Thanks.

Bug 1915531

Summary: [OVS IPsec] Permission denied: '/etc/ipsec.conf' with SELinux is Enforcing - RHEL7
Product: Red Hat Enterprise Linux Fast Datapath Reporter: Aaron Conole <aconole>
Component: openvswitch-selinux-extra-policyAssignee: Aaron Conole <aconole>
Status: CLOSED WONTFIX QA Contact: Jean-Tsung Hsiao <jhsiao>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: FDP 20.ICC: aconole, ctrautma, jhsiao, jishi, pvauter, qding, ralongi, tredaelli, yinxu
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1906278 Environment:
Last Closed: 2022-10-24 15:10:06 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1906278    
Bug Blocks:    
Attachments:
Description Flags
audit log for self-signed certificate mode
none
audit log for CA-signed certificate mode
none
audit log for CA-signed mode with openvswitch-selinux-extra-policy-1.0-18 none

Description Aaron Conole 2021-01-12 20:15:29 UTC
+++ This bug was initially created as a clone of Bug #1906278 +++

Description of problem:

[root@dell-per730-04 ~]# systemctl restart openvswitch-ipsec
Job for openvswitch-ipsec.service failed because the control process exited with error code.
See "systemctl status openvswitch-ipsec.service" and "journalctl -xe" for details.
[root@dell-per730-04 ~]# journalctl -xe
-- 
-- The unit openvswitch-ipsec.service has entered the 'failed' state with result 'exit-code'.
Dec 10 01:03:08 dell-per730-04.rhts.eng.pek2.redhat.com systemd[1]: Failed to start OVS IPsec daemon.
-- Subject: Unit openvswitch-ipsec.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- Unit openvswitch-ipsec.service has failed.
-- 
-- The result is failed.
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com systemd[1]: Starting OVS IPsec daemon...
-- Subject: Unit openvswitch-ipsec.service has begun start-up
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- Unit openvswitch-ipsec.service has begun starting up.
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]: 2020-12-10T06:03:12Z |  0  | ovs-monitor-ipsec | ERR | IKE daemon is not installed in the system.
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-monitor-ips[28626]: ovs|  0  | ovs-monitor-ipsec | ERR | IKE daemon is not installed in the system.
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]: 2020-12-10T06:03:12Z |  1  | ovs-monitor-ipsec | ERR | traceback
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]: Traceback (most recent call last):
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]:   File "/usr/share/openvswitch/scripts/ovs-monitor-ipsec", line 1237, in <module>
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]:     main()
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]:   File "/usr/share/openvswitch/scripts/ovs-monitor-ipsec", line 1184, in main
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]:     monitor = IPsecMonitor(root_prefix, args.ike_daemon)
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]:   File "/usr/share/openvswitch/scripts/ovs-monitor-ipsec", line 952, in __init__
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]:     self.ike_helper.restart_ike_daemon()
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]:   File "/usr/share/openvswitch/scripts/ovs-monitor-ipsec", line 454, in restart_ike_daemon
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]:     f = open(self.IPSEC_CONF, "w")
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-ctl[28610]: PermissionError: [Errno 13] Permission denied: '/etc/ipsec.conf'
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com ovs-monitor-ips[28626]: ovs|  1  | ovs-monitor-ipsec | ERR | traceback
                                                                                Traceback (most recent call last):
                                                                                  File "/usr/share/openvswitch/scripts/ovs-monitor-ipsec", line 1237, in <module>
                                                                                    main()
                                                                                  File "/usr/share/openvswitch/scripts/ovs-monitor-ipsec", line 1184, in main
                                                                                    monitor = IPsecMonitor(root_prefix, args.ike_daemon)
                                                                                  File "/usr/share/openvswitch/scripts/ovs-monitor-ipsec", line 952, in __init__
                                                                                    self.ike_helper.restart_ike_daemon()
                                                                                  File "/usr/share/openvswitch/scripts/ovs-monitor-ipsec", line 454, in restart_ike_daemon
                                                                                    f = open(self.IPSEC_CONF, "w")
                                                                                PermissionError: [Errno 13] Permission denied: '/etc/ipsec.conf'
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com systemd[1]: openvswitch-ipsec.service: Control process exited, code=exited status=1
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com systemd[1]: openvswitch-ipsec.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- The unit openvswitch-ipsec.service has entered the 'failed' state with result 'exit-code'.
Dec 10 01:03:12 dell-per730-04.rhts.eng.pek2.redhat.com systemd[1]: Failed to start OVS IPsec daemon.
-- Subject: Unit openvswitch-ipsec.service has failed
-- Defined-By: systemd
-- Support: https://access.redhat.com/support
-- 
-- Unit openvswitch-ipsec.service has failed.
-- 
-- The result is failed.
[root@dell-per730-04 ~]# 
[root@dell-per730-04 ~]# getenforce 
Enforcing
[root@dell-per730-04 ~]# setenforce 0
[root@dell-per730-04 ~]# systemctl restart openvswitch-ipsec
[root@dell-per730-04 ~]# 





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

[root@dell-per730-04 ~]# rpm -qa | grep openvswitch
python3-openvswitch2.13-2.13.0-74.el8fdp.x86_64
openvswitch2.13-2.13.0-74.el8fdp.x86_64
openvswitch2.13-ipsec-2.13.0-74.el8fdp.x86_64
openvswitch-selinux-extra-policy-1.0-23.el8fdp.noarch
[root@dell-per730-04 ~]# 



How reproducible: always


Steps to Reproduce:
1. systemctl start openvswitch-ipsec
2.
3.

Actual results:

openvswitch-ipsec service fails

Expected results:
openvswitch-ipsec service starts successfully

Additional info:
The package is not for FDP20.I, but I cannot find more suitable one.

--- Additional comment from Aaron Conole on 2020-12-15 21:32:54 UTC ---

Please include:

1. ls -laZ /etc/ipsec.conf
2. ps aux | grep ovs
3. /var/log/audit/audit.log

--- Additional comment from Timothy Redaelli on 2020-12-15 22:00:51 UTC ---

Reassigning to openvswitch-selinux-extra-policy

--- Additional comment from  on 2020-12-16 12:45:32 UTC ---

(In reply to Aaron Conole from comment #1)
> Please include:
> 
> 1. ls -laZ /etc/ipsec.conf

[root@dell-per730-05 ~]# ls -laZ /etc/ipsec.conf
-rw-r--r--. 1 root root system_u:object_r:ipsec_conf_file_t:s0 1557 Nov  3 09:54 /etc/ipsec.conf

> 2. ps aux | grep ovs

[root@dell-per730-05 ~]# ps aux | grep ovs
openvsw+   20078  0.0  0.0  77044  7728 ?        S<s  07:40   0:00 ovsdb-server /etc/openvswitch/conf.db -vconsole:emer -vsyslog:err -vfile:info --remote=punix:/var/run/openvswitch/db.sock --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --user openvswitch:hugetlbfs --no-chdir --log-file=/var/log/openvswitch/ovsdb-server.log --pidfile=/var/run/openvswitch/ovsdb-server.pid --detach
openvsw+   20137  0.0  0.1  92644 51504 ?        S<Ls 07:40   0:00 ovs-vswitchd unix:/var/run/openvswitch/db.sock -vconsole:emer -vsyslog:err -vfile:info --mlockall --user openvswitch:hugetlbfs --no-chdir --log-file=/var/log/openvswitch/ovs-vswitchd.log --pidfile=/var/run/openvswitch/ovs-vswitchd.pid --detach
root       20173  0.0  0.0  12108  1068 pts/0    S+   07:42   0:00 grep --color=auto ovs
[root@dell-per730-05 ~]# 

> 3. /var/log/audit/audit.log
Please see the attachment audit.log

--- Additional comment from  on 2020-12-18 03:56:08 UTC ---

Package for RHEL7 has the same issue when SELinux is Enforcing. 

[root@dell-per730-04 ~]# uname -r
3.10.0-1160.11.1.el7.x86_64
[root@dell-per730-04 ~]# rpm -qa | grep openvswitch
python3-openvswitch2.13-2.13.0-68.el7fdp.x86_64
openvswitch2.13-2.13.0-68.el7fdp.x86_64
openvswitch2.13-ipsec-2.13.0-68.el7fdp.x86_64
openvswitch-selinux-extra-policy-1.0-15.el7fdp.noarch
[root@dell-per730-04 ~]# 
[root@dell-per730-04 ~]# 
[root@dell-per730-04 ~]# ls -laZ /etc/ipsec.conf
-rw-r--r--. root root system_u:object_r:ipsec_conf_file_t:s0 /etc/ipsec.conf
[root@dell-per730-04 ~]# 
[root@dell-per730-04 ~]#  ps aux | grep ovs
openvsw+ 10534  0.0  0.0  60064  2780 ?        S<s  22:46   0:00 ovsdb-server /etc/openvswitch/conf.db -vconsole:emer -vsyslog:err -vfile:info --remote=punix:/var/run/openvswitch/db.sock --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --user openvswitch:openvswitch --no-chdir --log-file=/var/log/openvswitch/ovsdb-server.log --pidfile=/var/run/openvswitch/ovsdb-server.pid --detach
openvsw+ 10591  0.0  0.0  62572 15384 ?        S<Ls 22:46   0:00 ovs-vswitchd unix:/var/run/openvswitch/db.sock -vconsole:emer -vsyslog:err -vfile:info --mlockall --user openvswitch:openvswitch --no-chdir --log-file=/var/log/openvswitch/ovs-vswitchd.log --pidfile=/var/run/openvswitch/ovs-vswitchd.pid --detach
root     11278  0.0  0.0 132120 11048 ?        Ss   22:47   0:00 /usr/bin/python3 /usr/share/openvswitch/scripts/ovs-monitor-ipsec --pidfile=/var/run/openvswitch/ovs-monitor-ipsec.pid --ike-daemon=libreswan --log-file --detach --monitor unix:/var/run/openvswitch/db.sock
root     11279  0.0  0.0 132120 12264 ?        S    22:47   0:00 /usr/bin/python3 /usr/share/openvswitch/scripts/ovs-monitor-ipsec --pidfile=/var/run/openvswitch/ovs-monitor-ipsec.pid --ike-daemon=libreswan --log-file --detach --monitor unix:/var/run/openvswitch/db.sock
root     11303  0.0  0.0 112812   964 pts/0    S+   22:54   0:00 grep --color=auto ovs
[root@dell-per730-04 ~]# 
[root@dell-per730-04 ~]# 
[root@dell-per730-04 ~]#

Comment 5 qding 2021-01-25 13:22:06 UTC
Created attachment 1750510 [details]
audit log for self-signed certificate mode

Comment 6 qding 2021-01-25 13:23:02 UTC
Created attachment 1750511 [details]
audit log for CA-signed certificate mode

Comment 7 qding 2021-01-25 13:25:31 UTC
openvswitch-selinux-extra-policy-1.0-17.el7fdp.noarch has problem. Please see the attachments in comment#5 and #c6.

[root@dell-per730-04 ~]# rpm -qa | grep selinux
libselinux-utils-2.5-15.el7.x86_64
selinux-policy-3.13.1-268.el7_9.2.noarch
libselinux-2.5-15.el7.x86_64
openvswitch-selinux-extra-policy-1.0-17.el7fdp.noarch
selinux-policy-targeted-3.13.1-268.el7_9.2.noarch
libselinux-python-2.5-15.el7.x86_64
[root@dell-per730-04 ~]#

Comment 10 qding 2021-01-26 07:07:33 UTC
Created attachment 1750776 [details]
audit log for CA-signed mode with openvswitch-selinux-extra-policy-1.0-18

With openvswitch-selinux-extra-policy-1.0-18.el7fdp.noarch and selinux is Permissive, it works well, but when selinux is Enforcing it doesn't. Please check the log audit_ca_18.log. Thanks.

Comment 11 Aaron Conole 2021-01-26 14:36:34 UTC
09:34:04 aconole@dhcp-25 /tmp/mozilla_aconole0$ grep openvswitch_t audit_ca_18.log | grep AVC
09:34:13 aconole@dhcp-25 /tmp/mozilla_aconole0$ grep type=AVC audit_ca_18.log 
type=AVC msg=audit(1611644458.555:240): avc:  denied  { create } for  pid=12055 comm="certutil" name="dbTemp.M7HhrG" scontext=system_u:system_r:ipsec_mgmt_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1611644458.577:241): avc:  denied  { rmdir } for  pid=12055 comm="certutil" name="dbTemp.M7HhrG" dev="dm-0" ino=67875735 scontext=system_u:system_r:ipsec_mgmt_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1611644458.701:242): avc:  denied  { execute } for  pid=12049 comm="ipsec" name="setfiles" dev="dm-0" ino=34064518 scontext=system_u:system_r:ipsec_mgmt_t:s0 tcontext=system_u:object_r:setfiles_exec_t:s0 tclass=file permissive=1
type=AVC msg=audit(1611644458.701:243): avc:  denied  { read } for  pid=12049 comm="ipsec" name="setfiles" dev="dm-0" ino=34064518 scontext=system_u:system_r:ipsec_mgmt_t:s0 tcontext=system_u:object_r:setfiles_exec_t:s0 tclass=file permissive=1
type=AVC msg=audit(1611644458.701:244): avc:  denied  { open } for  pid=12057 comm="ipsec" path="/usr/sbin/setfiles" dev="dm-0" ino=34064518 scontext=system_u:system_r:ipsec_mgmt_t:s0 tcontext=system_u:object_r:setfiles_exec_t:s0 tclass=file permissive=1
type=AVC msg=audit(1611644458.701:244): avc:  denied  { execute_no_trans } for  pid=12057 comm="ipsec" path="/usr/sbin/setfiles" dev="dm-0" ino=34064518 scontext=system_u:system_r:ipsec_mgmt_t:s0 tcontext=system_u:object_r:setfiles_exec_t:s0 tclass=file permissive=1
type=AVC msg=audit(1611644458.702:245): avc:  denied  { getattr } for  pid=12057 comm="restorecon" name="/" dev="sysfs" ino=1 scontext=system_u:system_r:ipsec_mgmt_t:s0 tcontext=system_u:object_r:sysfs_t:s0 tclass=filesystem permissive=1
type=AVC msg=audit(1611644458.702:246): avc:  denied  { getattr } for  pid=12057 comm="restorecon" name="/" dev="devtmpfs" ino=2049 scontext=system_u:system_r:ipsec_mgmt_t:s0 tcontext=system_u:object_r:device_t:s0 tclass=filesystem permissive=1
type=AVC msg=audit(1611644458.703:247): avc:  denied  { getattr } for  pid=12057 comm="restorecon" name="/" dev="tmpfs" ino=14343 scontext=system_u:system_r:ipsec_mgmt_t:s0 tcontext=system_u:object_r:tmpfs_t:s0 tclass=filesystem permissive=1
type=AVC msg=audit(1611644458.703:248): avc:  denied  { getattr } for  pid=12057 comm="restorecon" name="/" dev="cgroup" ino=14348 scontext=system_u:system_r:ipsec_mgmt_t:s0 tcontext=system_u:object_r:cgroup_t:s0 tclass=filesystem permissive=1
type=AVC msg=audit(1611644458.703:249): avc:  denied  { getattr } for  pid=12057 comm="restorecon" name="/" dev="hugetlbfs" ino=29717 scontext=system_u:system_r:ipsec_mgmt_t:s0 tcontext=system_u:object_r:hugetlbfs_t:s0 tclass=filesystem permissive=1
type=AVC msg=audit(1611644458.764:250): avc:  denied  { create } for  pid=12072 comm="pluto" name="dbTemp.kfNgLU" scontext=system_u:system_r:ipsec_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1611644458.785:251): avc:  denied  { rmdir } for  pid=12072 comm="pluto" name="dbTemp.kfNgLU" dev="dm-0" ino=34317304 scontext=system_u:system_r:ipsec_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1611644464.410:269): avc:  denied  { create } for  pid=12586 comm="pluto" name="dbTemp.SbC3nI" scontext=system_u:system_r:ipsec_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1611644464.431:270): avc:  denied  { rmdir } for  pid=12586 comm="pluto" name="dbTemp.SbC3nI" dev="dm-0" ino=126526 scontext=system_u:system_r:ipsec_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1611644535.264:317): avc:  denied  { create } for  pid=24983 comm="pluto" name="dbTemp.BOvQbs" scontext=system_u:system_r:ipsec_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1611644535.285:318): avc:  denied  { rmdir } for  pid=24983 comm="pluto" name="dbTemp.BOvQbs" dev="dm-0" ino=101163476 scontext=system_u:system_r:ipsec_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1611644535.818:329): avc:  denied  { create } for  pid=25364 comm="pluto" name="dbTemp.OAvDc7" scontext=system_u:system_r:ipsec_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1611644535.840:330): avc:  denied  { rmdir } for  pid=25364 comm="pluto" name="dbTemp.OAvDc7" dev="dm-0" ino=67875735 scontext=system_u:system_r:ipsec_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=1


I see lots of problems for ipsec_t domain - but we don't control that.

Is it really intended to work on RHEL7?

Comment 13 Jean-Tsung Hsiao 2021-05-25 03:03:33 UTC
Both "systemctl start openvswitch-ipsec" and "systemctl restart openvswitch-ipsec" were executed successfully:

[root@netqe7 ipsec]# !25
systemctl start openvswitch-ipsec
[root@netqe7 ipsec]# !28
systemctl restart openvswitch-ipsec
[root@netqe7 ipsec]# rpm -qa | grep openvswitch
openvswitch2.13-2.13.0-95.el7fdp.x86_64
openvswitch2.13-ipsec-2.13.0-95.el7fdp.x86_64
python3-openvswitch2.13-2.13.0-95.el7fdp.x86_64
openvswitch-selinux-extra-policy-1.0-18.el7fdp.noarch
[root@netqe7 ipsec]# 

But, there were AVC encountered:

tail -f /var/log/audit/audit.log | grep AVC


type=AVC msg=audit(1621911533.663:266): avc:  denied  { create } for  pid=16084 comm="pluto" name="dbTemp.zX89oM" scontext=system_u:system_r:ipsec_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=0

type=AVC msg=audit(1621911547.116:278): avc:  denied  { create } for  pid=16481 comm="pluto" name="dbTemp.BluZvX" scontext=system_u:system_r:ipsec_t:s0 tcontext=system_u:object_r:ipsec_key_file_t:s0 tclass=dir permissive=0

Comment 15 Jean-Tsung Hsiao 2022-09-02 17:12:59 UTC
Hi Aaron,
Can we closed this one ?
Thanks!
Jean