RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2160391 - SELinux is preventing systemd from using LoadCredentials
Summary: SELinux is preventing systemd from using LoadCredentials
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: selinux-policy
Version: CentOS Stream
Hardware: All
OS: Linux
medium
low
Target Milestone: rc
: ---
Assignee: Nikola Knazekova
QA Contact: Milos Malik
URL:
Whiteboard:
: 2160933 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-01-12 09:02 UTC by Nikita Uvarov
Modified: 2023-05-09 10:22 UTC (History)
6 users (show)

Fixed In Version: selinux-policy-38.1.5-1.el9
Doc Type: Bug Fix
Doc Text:
Cause: systemd-creds apparently runs in a chroot where /dev/shm is backed by ramfs (ramfs_t) instead of the usual tmpfs, which is not allowed in the policy Consequence: SELinux is preventing systemd from using LoadCredentials Fix: Reuse tmpfs_t also for the ramfs filesystem Result: No SELinux denials
Clone Of:
Environment:
Last Closed: 2023-05-09 08:17:16 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 2160933 0 unspecified CLOSED SELinux blocks systemd from using LoadCredentials 2023-05-12 04:52:13 UTC
Red Hat Issue Tracker RHELPLAN-144917 0 None None None 2023-01-12 09:04:45 UTC
Red Hat Product Errata RHBA-2023:2483 0 None None None 2023-05-09 08:17:47 UTC

Description Nikita Uvarov 2023-01-12 09:02:39 UTC
Description of problem:
Current SELinux policies doesn't allow new systemd credentials feature. E.g. running a command like this:

```
sudo systemd-run -P --wait -p LoadCredential=abc:/etc/hosts systemd-creds cat abc
```

Results in:

run-u11509.service: Failed to set up credentials: Protocol error
run-u11509.service: Failed at step CREDENTIALS spawning /bin/systemd-creds: Protocol error
run-u11509.service: Main process exited, code=exited, status=243/CREDENTIALS
run-u11509.service: Failed with result 'exit-code'.

And audit.log:
type=PROCTITLE msg=audit(12/06/2022 14:32:29.129:410) : proctitle=(sd-mkdcreds)
type=SYSCALL msg=audit(12/06/2022 14:32:29.129:410) : arch=x86_64 syscall=openat success=no exit=EACCES(Permission denied) a0=0x3 a1=0x55a11385ef90 a2=O_RDWR|O_CREAT|O_EXCL|O_NOCTTY|O_NOFOLLOW|O_CLOEXEC a3=0x180 items=0 ppid=3368570 pid=3368571 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=(sd-mkdcreds) exe=/usr/lib/systemd/systemd subj=system_u:system_r:init_t:s0 key=(null)
type=AVC msg=audit(12/06/2022 14:32:29.129:410) : avc:  denied  { read write open } for  pid=3368571 comm=(sd-mkdcreds) path=/dev/shm/.#cred8d2badcefa7a5141 dev="ramfs" ino=365308391 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:ramfs_t:s0 tclass=file permissive=0

This seems to be because selinux forbids systemd process to create ramfs files. Adding such permission with semodule containing the following permissions fixes the problem:

allow init_t ramfs_t:file { create open read rename setattr write };


Version-Release number of selected component (if applicable):
CentOS Stream 9
selinux-policy-targeted: 38.1.3


How reproducible:
Everytime

Steps to Reproduce:
1. Make sure selinux is enabled
2. sudo systemd-run -P --wait -p LoadCredential=abc:/etc/hosts systemd-creds cat abc

Actual results:
Main processes terminated with: code=exited/status=243

Expected results:
Contents of /etc/hosts file

Additional info:

Compiling and installing semodule with the following permissions fixes the issue:
allow init_t ramfs_t:file { create open read rename setattr write };

Comment 1 Milos Malik 2023-01-12 13:25:56 UTC
I believe this BZ is a RHEL-9 variant of BZ#2096857.

Comment 2 Zdenek Pytela 2023-01-16 11:13:51 UTC
I thinks these two commits are needed:
021025430 Allow systemd-resolved watch tmpfs directories
8e908b8d9 Reuse tmpfs_t also for the ramfs filesystem

and there is one pr pending for cases when sockets are used.

Comment 3 Nikola Knazekova 2023-01-20 13:08:10 UTC
*** Bug 2160933 has been marked as a duplicate of this bug. ***

Comment 15 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


Note You need to log in before you can comment on or make changes to this bug.