Bug 2166283

Summary: httpd fails to start with opencryptoki SW token
Product: Red Hat Enterprise Linux 9 Reporter: Karel Srot <ksrot>
Component: selinux-policyAssignee: Nikola Knazekova <nknazeko>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: high Docs Contact:
Priority: medium    
Version: 9.2CC: lvrabec, mmalik, szidek, zpytela
Target Milestone: rcKeywords: AutoVerified, Regression, Triaged
Target Release: 9.2Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-38.1.8-1.el9_2 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 08:17:16 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 Karel Srot 2023-02-01 12:25:51 UTC
Description of problem:

httpd won't start due to not having access to /dev/shm/var.lib.opencryptoki_stats_0

Test scenario is implemented in the test p11-kit/Integration/httpd-pkcs11-uri

On RHEL-9.2 (tested RHEL-9.2.0-20230201.12) this test is failing.
The test is passing in permissive mode.


Version-Release number of selected component (if applicable):
httpd-2.4.53-10.el9
p11-kit-0.24.1-2.el9
opencryptoki-libs-3.19.0-2.el9
selinux-policy-38.1.5-1.el9

How reproducible:
always

Steps to Reproduce:
1. run previously mentioned test

Actual results:

In permissive
# ausearch -m avc -ts recent
----
time->Wed Feb  1 07:12:41 2023
type=PROCTITLE msg=audit(1675253561.071:1059): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44
type=PATH msg=audit(1675253561.071:1059): item=0 name="/dev/shm/var.lib.opencryptoki_stats_0" inode=4 dev=00:15 mode=0100600 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
type=CWD msg=audit(1675253561.071:1059): cwd="/"
type=SYSCALL msg=audit(1675253561.071:1059): arch=80000016 syscall=288 success=yes exit=15 a0=ffffffffffffff9c a1=3fffed78983 a2=a0002 a3=0 items=1 ppid=1 pid=62852 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1675253561.071:1059): avc:  denied  { open } for  pid=62852 comm="httpd" path="/dev/shm/var.lib.opencryptoki_stats_0" dev="tmpfs" ino=4 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_tmp_t:s0 tclass=file permissive=1
----
time->Wed Feb  1 07:12:41 2023
type=PROCTITLE msg=audit(1675253561.081:1060): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44
type=PATH msg=audit(1675253561.081:1060): item=0 name="/dev/shm/var.lib.opencryptoki.swtok" inode=3 dev=00:15 mode=0100660 ouid=48 ogid=990 rdev=00:00 obj=unconfined_u:object_r:pkcs_slotd_tmpfs_t:s0 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
type=CWD msg=audit(1675253561.081:1060): cwd="/"
type=SYSCALL msg=audit(1675253561.081:1060): arch=80000016 syscall=288 success=yes exit=17 a0=ffffffffffffff9c a1=3fffed7485b a2=a0002 a3=0 items=1 ppid=1 pid=62852 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1675253561.081:1060): avc:  denied  { open } for  pid=62852 comm="httpd" path="/dev/shm/var.lib.opencryptoki.swtok" dev="tmpfs" ino=3 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:pkcs_slotd_tmpfs_t:s0 tclass=file permissive=1
type=AVC msg=audit(1675253561.081:1060): avc:  denied  { read write } for  pid=62852 comm="httpd" name="var.lib.opencryptoki.swtok" dev="tmpfs" ino=3 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:pkcs_slotd_tmpfs_t:s0 tclass=file permissive=1
----
time->Wed Feb  1 07:12:41 2023
type=PROCTITLE msg=audit(1675253561.081:1061): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44
type=PATH msg=audit(1675253561.081:1061): item=0 name="" inode=3 dev=00:15 mode=0100660 ouid=48 ogid=990 rdev=00:00 obj=unconfined_u:object_r:pkcs_slotd_tmpfs_t:s0 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
type=CWD msg=audit(1675253561.081:1061): cwd="/"
type=SYSCALL msg=audit(1675253561.081:1061): arch=80000016 syscall=293 success=yes exit=0 a0=11 a1=3ff9028c316 a2=3fffed75a60 a3=1000 items=1 ppid=1 pid=62852 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1675253561.081:1061): avc:  denied  { getattr } for  pid=62852 comm="httpd" path="/dev/shm/var.lib.opencryptoki.swtok" dev="tmpfs" ino=3 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:pkcs_slotd_tmpfs_t:s0 tclass=file permissive=1
----
time->Wed Feb  1 07:12:41 2023
type=PROCTITLE msg=audit(1675253561.081:1062): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44
type=MMAP msg=audit(1675253561.081:1062): fd=17 flags=0x1
type=SYSCALL msg=audit(1675253561.081:1062): arch=80000016 syscall=90 success=yes exit=4396093538304 a0=3fffed74938 a1=14368 a2=3 a3=1 items=0 ppid=1 pid=62852 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1675253561.081:1062): avc:  denied  { map } for  pid=62852 comm="httpd" path="/dev/shm/var.lib.opencryptoki.swtok" dev="tmpfs" ino=3 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:pkcs_slotd_tmpfs_t:s0 tclass=file permissive=1
----
time->Wed Feb  1 07:12:41 2023
type=PROCTITLE msg=audit(1675253561.081:1063): proctitle=2F7573722F7362696E2F6874747064002D44464F524547524F554E44
type=PATH msg=audit(1675253561.081:1063): item=0 name=(null) inode=250767 dev=fd:00 mode=0100660 ouid=48 ogid=990 rdev=00:00 obj=unconfined_u:object_r:pkcs_slotd_var_lib_t:s0 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
type=CWD msg=audit(1675253561.081:1063): cwd="/"
type=SYSCALL msg=audit(1675253561.081:1063): arch=80000016 syscall=94 success=yes exit=0 a0=11 a1=1b0 a2=0 a3=0 items=1 ppid=1 pid=62852 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="httpd" exe="/usr/sbin/httpd" subj=system_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(1675253561.081:1063): avc:  denied  { fowner } for  pid=62852 comm="httpd" capability=3  scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=capability permissive=1

# ausearch -m avc -ts recent | audit2allow 


#============= httpd_t ==============
allow httpd_t pkcs_slotd_tmpfs_t:file { getattr open read write };

#!!!! This avc can be allowed using the boolean 'domain_can_mmap_files'
allow httpd_t pkcs_slotd_tmpfs_t:file map;

#!!!! This avc can be allowed using the boolean 'httpd_run_stickshift'
allow httpd_t self:capability fowner;

#!!!! This avc can be allowed using the boolean 'httpd_read_user_content'
allow httpd_t user_tmp_t:file open;


Expected results:
test is passing, httpd starts properly

Additional info:
This is a regression compared to RHEL-9.1
Also, please note that opencryptoki was rebased in RHEL-9.2, however it seems that this is not the only culprit.

Comment 1 Karel Srot 2023-02-01 12:27:09 UTC
Also, while there seems to be some similarity with bug 2028637 in terms of the impact the actual problem seems to be a bit different.

Comment 16 errata-xmlrpc 2023-05-09 08:17:16 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 (selinux-policy bug fix and enhancement update), 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-2023:2483