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 2224251

Summary: User's temporary files are not labeled correctly
Product: Red Hat Enterprise Linux 8 Reporter: Renaud Métrich <rmetrich>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED MIGRATED QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: low Docs Contact:
Priority: low    
Version: 8.8CC: lvrabec, mmalik, nknazeko
Target Milestone: rcKeywords: MigratedToJIRA, Triaged
Target Release: ---Flags: pm-rhel: mirror+
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: 2023-08-09 12:59:51 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 2023-07-20 09:32:26 UTC
Description of problem:

There is the following context in the database:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
/home/[^/]+/tmp                                    directory          unconfined_u:object_r:user_tmp_t:s0 
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

This makes all files created under the user's "tmp/" directory be labeled appropriately with "user_tmp_t".
But executing restorecon wants to relabel the files back to "user_home_t", which is probably not appropriate:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
# restorecon -Frvn /home/admin/tmp
Would relabel /home/admin/tmp/foo from unconfined_u:object_r:user_tmp_t:s0 to unconfined_u:object_r:user_home_t:s0
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

Same issue happens for other similar locations:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
/home/[^/]+/\.tmp                                  directory          unconfined_u:object_r:user_tmp_t:s0 
/home/[^/]+/tmp                                    directory          unconfined_u:object_r:user_tmp_t:s0 
/home/staff/\.tmp                                  directory          staff_u:object_r:user_tmp_t:s0 
/home/staff/tmp                                    directory          staff_u:object_r:user_tmp_t:s0 
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------

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

selinux-policy-3.14.3-117.el8_8.2.noarch

How reproducible:

Always

Steps to Reproduce:
1. Create a user and create temporary files

  # useradd admin
  # sudo -u admin -i
  $ mkdir tmp
  $ touch tmp/foo

2. Check labels

  # ls -Zd1 /home/admin/tmp /home/admin/tmp/foo
  unconfined_u:object_r:user_tmp_t:s0 /home/admin/tmp
  unconfined_u:object_r:user_tmp_t:s0 /home/admin/tmp/foo

3. Execute restorecon

  # restorecon -Frnv /home/admin/tmp

Actual results:

Would relabel /home/admin/tmp/foo from unconfined_u:object_r:user_tmp_t:s0 to unconfined_u:object_r:user_home_t:s0

Expected results:

No relabeling

Comment 1 Zdenek Pytela 2023-08-01 16:50:45 UTC
I think it is correct the user_tmp_t type is not assigned to /home/login/tmp/file, but using <<none>> is an option.