Bug 1664983

Summary: SELinux prevents kadmind from searching in /var/lib/softhsm directory
Product: Red Hat Enterprise Linux 8 Reporter: Kaleem <ksiddiqu>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: abokovoy, lslebodn, lvrabec, mmalik, ndehadra, nmavrogi, plautrba, ssekidde, zpytela
Target Milestone: rcKeywords: AutoVerified
Target Release: 8.1   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.14.3-6.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-05 22:09:45 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:
Bug Depends On: 1673107, 1682526    
Bug Blocks:    

Description Kaleem 2019-01-10 08:16:11 UTC
Description of problem:

Following avc denial seen during execution of one of regression test suite.


Version-Release number of selected component (if applicable):
[root@vm-idm-012 ~]# rpm -q selinux-policy ipa-server krb5-server 
selinux-policy-3.14.1-49.el8.noarch
ipa-server-4.7.1-7.module+el8+2555+b334d87b.x86_64
krb5-server-1.16.1-20.el8.x86_64
[root@vm-idm-012 ~]# 

How reproducible:
Always

Steps to Reproduce:
1.
During following test step execution, avc denial seen

:: [ 19:36:42 ] :: [   LOG    ] :: [stage 3] build up password history pool by changing password, the password will pick up from password pool. If password change success, the password will save to history pool for future use, current history pool []
:: [ 19:36:42 ] :: [  BEGIN   ] :: Running 'rlDistroDiff keyctl'
:: [ 19:36:42 ] :: [   PASS   ] :: Command 'rlDistroDiff keyctl' (Expected 0, got 0)
:: [ 19:36:42 ] :: [   LOG    ] :: Running: temp_fix_ccache_through_pam_stack test_user test_user Password_123
:: [ 19:36:43 ] :: [   LOG    ] :: Running: echo Password_123 | sudo -u test_user kinit test_user
Password for test_user: 
:: [ 19:36:44 ] :: [  BEGIN   ] :: verify password [Password_123] for user [test_user] :: actually running 'echo Password_123 | sudo -u test_user kinit test_user 2>&1 >/dev/null'

Actual results:
Following avc denial seen

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
Memory protection checking:     actual (secure)
Max kernel policy version:      31
selinux-policy-3.14.1-49.el8.noarch
----
time->Wed Jan  9 19:36:42 2019
type=PROCTITLE msg=audit(1547042802.339:3710): proctitle=2F7573722F7362696E2F6B61646D696E64002D50002F7661722F72756E2F6B61646D696E642E706964
type=PATH msg=audit(1547042802.339:3710): item=0 name="/root/.config/pkcs11/pkcs11.conf" nametype=UNKNOWN cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1547042802.339:3710): cwd="/"
type=SYSCALL msg=audit(1547042802.339:3710): arch=c000003e syscall=257 success=no exit=-13 a0=ffffff9c a1=55c205845250 a2=80000 a3=0 items=1 ppid=1 pid=25493 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="kadmind" exe="/usr/sbin/kadmind" subj=system_u:system_r:kadmind_t:s0 key=(null)
type=AVC msg=audit(1547042802.339:3710): avc:  denied  { search } for  pid=25493 comm="kadmind" name=".config" dev="dm-0" ino=67999078 scontext=system_u:system_r:kadmind_t:s0 tcontext=unconfined_u:object_r:config_home_t:s0 tclass=dir permissive=0
----
time->Wed Jan  9 19:36:42 2019
type=PROCTITLE msg=audit(1547042802.340:3711): proctitle=2F7573722F7362696E2F6B61646D696E64002D50002F7661722F72756E2F6B61646D696E642E706964
type=PATH msg=audit(1547042802.340:3711): item=0 name="/root/.config/pkcs11/modules" nametype=UNKNOWN cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1547042802.340:3711): cwd="/"
type=SYSCALL msg=audit(1547042802.340:3711): arch=c000003e syscall=257 success=no exit=-13 a0=ffffff9c a1=55c205845250 a2=90800 a3=0 items=1 ppid=1 pid=25493 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="kadmind" exe="/usr/sbin/kadmind" subj=system_u:system_r:kadmind_t:s0 key=(null)
type=AVC msg=audit(1547042802.340:3711): avc:  denied  { search } for  pid=25493 comm="kadmind" name=".config" dev="dm-0" ino=67999078 scontext=system_u:system_r:kadmind_t:s0 tcontext=unconfined_u:object_r:config_home_t:s0 tclass=dir permissive=0
----
time->Wed Jan  9 19:36:42 2019
type=PROCTITLE msg=audit(1547042802.347:3712): proctitle=2F7573722F7362696E2F6B61646D696E64002D50002F7661722F72756E2F6B61646D696E642E706964
type=PATH msg=audit(1547042802.347:3712): item=0 name="/root/.config/softhsm2/softhsm2.conf" nametype=UNKNOWN cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1547042802.347:3712): cwd="/"
type=SYSCALL msg=audit(1547042802.347:3712): arch=c000003e syscall=21 success=no exit=-13 a0=7ffc6d0e0500 a1=4 a2=0 a3=0 items=1 ppid=1 pid=25493 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="kadmind" exe="/usr/sbin/kadmind" subj=system_u:system_r:kadmind_t:s0 key=(null)
type=AVC msg=audit(1547042802.347:3712): avc:  denied  { search } for  pid=25493 comm="kadmind" name=".config" dev="dm-0" ino=67999078 scontext=system_u:system_r:kadmind_t:s0 tcontext=unconfined_u:object_r:config_home_t:s0 tclass=dir permissive=0
----
time->Wed Jan  9 19:36:42 2019
type=PROCTITLE msg=audit(1547042802.347:3713): proctitle=2F7573722F7362696E2F6B61646D696E64002D50002F7661722F72756E2F6B61646D696E642E706964
type=PATH msg=audit(1547042802.347:3713): item=0 name="/var/lib/softhsm/tokens/" nametype=UNKNOWN cap_fp=0000000000000000 cap_fi=0000000000000000 cap_fe=0 cap_fver=0
type=CWD msg=audit(1547042802.347:3713): cwd="/"
type=SYSCALL msg=audit(1547042802.347:3713): arch=c000003e syscall=257 success=no exit=-13 a0=ffffff9c a1=55c205793dc0 a2=90800 a3=0 items=1 ppid=1 pid=25493 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="kadmind" exe="/usr/sbin/kadmind" subj=system_u:system_r:kadmind_t:s0 key=(null)
type=AVC msg=audit(1547042802.347:3713): avc:  denied  { search } for  pid=25493 comm="kadmind" name="softhsm" dev="dm-0" ino=101255400 scontext=system_u:system_r:kadmind_t:s0 tcontext=system_u:object_r:named_cache_t:s0 tclass=dir permissive=0



Expected results:
No AVC denial.

Additional info:

Comment 2 Lukas Vrabec 2019-03-18 17:58:41 UTC
*** Bug 1689921 has been marked as a duplicate of this bug. ***

Comment 3 Alexander Bokovoy 2019-03-22 16:21:39 UTC
This is due to p11-kit pulling in softhsm2 module into any application that initializes openssl engines.

Kaleem, could you please try this workaround:

----------------------------------------
# cat /etc/pkcs11/modules/softhsm2.module

module: /usr/lib64/pkcs11/libsofthsm2.so
disable-in: kadmind
----------------------------------------

Nikos, this is another case of p11-kit creating issues with SELinux contexts. There is no way so far to contain pkcs11 accesses. May be we need to integrate p11-kit with SELinux so that module loads are done in a context that can be granted certain access rights?

Comment 6 Kaleem 2019-03-27 15:48:49 UTC
Please try workaround of https://bugzilla.redhat.com/show_bug.cgi?id=1664983#c3

Comment 34 errata-xmlrpc 2019-11-05 22:09:45 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2019:3547