Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 2121734

Summary: AVCs when runtime directory for the user is cleaned up on session exit
Product: Red Hat Enterprise Linux 9 Reporter: Renaud Métrich <rmetrich>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED MIGRATED QA Contact: Milos Malik <mmalik>
Severity: low Docs Contact:
Priority: low    
Version: 9.0CC: lvrabec, mmalik, nknazeko
Target Milestone: rcKeywords: MigratedToJIRA, Triaged
Target Release: 9.3Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-08-23 08:27:37 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 Renaud Métrich 2022-08-26 13:01:31 UTC
Description of problem:

When `systemd-logind` executes `/usr/lib/systemd/systemd-user-runtime-dir` to clean up the user's session on exit, AVCs can be seen when the latter cannot delete files due to their label, e.g.:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
type=PROCTITLE msg=audit(08/26/2022 14:54:01.976:473) : proctitle=/usr/lib/systemd/systemd-user-runtime-dir stop 1000 
type=SYSCALL msg=audit(08/26/2022 14:54:01.976:473) : arch=x86_64 syscall=unlinkat success=no exit=EACCES(Permission denied) a0=0x3 a1=0x558372fa6d03 a2=0x0 a3=0x9b items=0 ppid=1 pid=2633 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=systemd-user-ru exe=/usr/lib/systemd/systemd-user-runtime-dir subj=system_u:system_r:systemd_logind_t:s0 key=(null) 
type=AVC msg=audit(08/26/2022 14:54:01.976:473) : avc:  denied  { unlink } for  pid=2633 comm=systemd-user-ru name=foo dev="tmpfs" ino=18 scontext=system_u:system_r:systemd_logind_t:s0 tcontext=unconfined_u:object_r:container_file_t:s0 tclass=file permissive=0 
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This kind of AVCs should be hidden or a transition to some new context should be created to allow `/usr/lib/systemd/systemd-user-runtime-dir` to delete everything it wants in that directory.

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

selinux-policy-34.1.29-1.el9_0.2.noarch

How reproducible:

Always

Steps to Reproduce:
1. Create a user on the system

    # useradd user
    # echo "redhat" | passwd --stdin user

2. Login as the user and create a file in its runtime directory

    # ssh user@localhost
    ...
    $ touch /run/user/$(id -u)/foo
    $ chcon -t container_file_t /run/user/$(id -u)/foo

3. Exit and wait for session to be cleaned up (10 seconds by default)

    $ exit

4. Checks audit log for AVCs

    # ausearch -i -m avc -ts recent

Actual results:

type=PROCTITLE msg=audit(08/26/2022 14:54:01.976:473) : proctitle=/usr/lib/systemd/systemd-user-runtime-dir stop 1000 
type=SYSCALL msg=audit(08/26/2022 14:54:01.976:473) : arch=x86_64 syscall=unlinkat success=no exit=EACCES(Permission denied) a0=0x3 a1=0x558372fa6d03 a2=0x0 a3=0x9b items=0 ppid=1 pid=2633 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=systemd-user-ru exe=/usr/lib/systemd/systemd-user-runtime-dir subj=system_u:system_r:systemd_logind_t:s0 key=(null) 
type=AVC msg=audit(08/26/2022 14:54:01.976:473) : avc:  denied  { unlink } for  pid=2633 comm=systemd-user-ru name=foo dev="tmpfs" ino=18 scontext=system_u:system_r:systemd_logind_t:s0 tcontext=unconfined_u:object_r:container_file_t:s0 tclass=file permissive=0 

Expected results:

No AVC

Additional info:

Files disappear anyway because the runtime directory is tmpfs and gets unmounted, so it's harmless.

Comment 1 Zdenek Pytela 2023-01-05 17:11:36 UTC
We will consider this bz for RHEL 9.3 and assign a separate type for systemd-user-runtime-dir.

Comment 7 RHEL Program Management 2023-08-21 17:53:27 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 8 Nikola Knazekova 2023-08-23 08:27:37 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues.