Bug 2097681

Summary: selinux-policy prevents service that uses LoadCredentials= from starting
Product: [Fedora] Fedora Reporter: henri
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 36CC: dwalsh, grepl.miroslav, lvrabec, mmalik, omosnace, pkoncity, vmojzis, zpytela
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-06-16 11:53:02 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 henri 2022-06-16 09:53:07 UTC
Description of problem:
SELinux prevents a systemd service from starting if it uses LoadCredentials=. The service fails with status 243

Version-Release number of selected component (if applicable):
Version      : 36.10
Release      : 1.fc36

How reproducible:
Easy

Steps to Reproduce:
Using the example command from the systemd documentation (https://systemd.io/CREDENTIALS/). 
1. systemd-run -P --wait -p LoadCredential=abc:/etc/hosts systemd-creds cat abc

Actual results:
Running as unit: run-u71.service
Finished with result: exit-code
Main processes terminated with: code=exited/status=243
Service runtime: 12ms
CPU time consumed: 12ms

Expected results:
After executing 'setenforce 0', the service is allowed to start.
Running as unit: run-u75.service
# Loopback entries; do not change.
# For historical reasons, localhost precedes localhost.localdomain:
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
# See hosts(5) for proper format and other examples:
# 192.168.1.10 foo.mydomain.org foo
# 192.168.1.13 bar.mydomain.org bar
Finished with result: success
Main processes terminated with: code=exited/status=0
Service runtime: 33ms
CPU time consumed: 26ms

Additional info:

`ausearch -c creds` shows

time->Thu Jun 16 11:45:19 2022
type=AVC msg=audit(1655372719.715:508): avc:  denied  { read write open } for  pid=2049 comm="(sd-mkdcreds)" path="/dev/shm/.#cred22355fda375e1b92" dev="ramfs" ino=31825 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:ramfs_t:s0 tclass=file permissive=1
----
time->Thu Jun 16 11:45:19 2022
type=AVC msg=audit(1655372719.715:509): avc:  denied  { setattr } for  pid=2049 comm="(sd-mkdcreds)" name=".#cred22355fda375e1b92" dev="ramfs" ino=31825 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:ramfs_t:s0 tclass=file permissive=1
----
time->Thu Jun 16 11:45:19 2022
type=AVC msg=audit(1655372719.715:510): avc:  denied  { rename } for  pid=2049 comm="(sd-mkdcreds)" name=".#cred22355fda375e1b92" dev="ramfs" ino=31825 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:ramfs_t:s0 tclass=file permissive=1

The policy is missing rules to allow this.

Comment 1 Milos Malik 2022-06-16 11:39:45 UTC
I believe this BZ is a duplicate of BZ#2096857.

Comment 2 Zdenek Pytela 2022-06-16 11:53:02 UTC

*** This bug has been marked as a duplicate of bug 2096857 ***