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 1133894

Summary: Mount of "/" within a new mount namespace as sysadm_r with SELinux policy MLS returns EACCES
Product: Red Hat Enterprise Linux 7 Reporter: Matus Marhefka <mmarhefk>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Matus Marhefka <mmarhefk>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: mmalik, mmarhefk
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.13.1-13.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 10:44:43 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:
Attachments:
Description Flags
se_test.c none

Description Matus Marhefka 2014-08-26 12:03:03 UTC
Description of problem:
When mounting "/" as user root (with sysadm_r role) in SELinux policy MLS
within a new mount namespace by:
mount("none", "/", "none", MS_REC|MS_PRIVATE, NULL);
error is returned:
errno=EACCES(13): Permission denied


# sestatus 
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             mls
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     denied
Max kernel policy version:      28

# ausearch -m avc -ts recent | audit2why
type=AVC msg=audit(1409051210.963:1380): avc:  denied  { mounton } for  pid=32494 comm="mountns01" path="/" dev="dm-1" ino=128 scontext=staff_u:sysadm_r:sysadm_t:s0-s15:c0.c1023 tcontext=system_u:object_r:root_t:s0 tclass=dir

        Was caused by:
                Missing type enforcement (TE) allow rule.

# ausearch -m avc -ts recent | grep mount | audit2allow 
#============= sysadm_t ==============
allow sysadm_t root_t:dir mounton;


Version-Release number of selected component (if applicable):
selinux-policy-3.12.1-153.el7.noarch
selinux-policy-mls-3.12.1-153.el7.noarch
kernel-3.10.0-123.el7.x86_64


How reproducible:
100%


Steps to Reproduce:
1. newrole -r sysadm_r
2. /bin/su -
3. Download se_test.c from attachments
4. gcc se_test.c -o se_test; ./se_test
5. Permission denied


Actual results:
Mounting "/" as private within a new mount namespace as root
(with sysadm_r role) in SELinux policy MLS doesn't work,
it returns error (errno=EACCES(13): Permission denied).

Expected results:
Mounting "/" as private within a new mount namespace as root
(with sysadm_r role) in SELinux policy MLS does work.

Additional info:

Comment 1 Matus Marhefka 2014-08-26 12:04:15 UTC
Created attachment 930857 [details]
se_test.c

Comment 2 Miroslav Grepl 2014-09-03 12:21:53 UTC
If you add a local policy, does it work then?

Comment 3 Matus Marhefka 2014-09-26 14:17:29 UTC
Yes, it works after adding a local policy.

Comment 4 Miroslav Grepl 2014-12-02 13:40:35 UTC
commit c2657a8bf1c76fda2b2cab764cf94ea51d6f6930
Author: Miroslav Grepl <mgrepl>
Date:   Tue Dec 2 14:40:18 2014 +0100

    Allow admin SELinux users mounting / as private within a new mount namespace as root in MLS.

Comment 6 Matus Marhefka 2014-12-19 15:17:48 UTC
VERIFIED for selinux-policy-3.13.1-14.el7.noarch and selinux-policy-mls-3.13.1-14.el7.noarch.

# strace ./se_test
...
mount("none", "/", "none", MS_REC|MS_PRIVATE, NULL) = 0
...

Comment 8 errata-xmlrpc 2015-03-05 10:44:43 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, 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://rhn.redhat.com/errata/RHBA-2015-0458.html