Bug 1514880

Summary: selinux preventing systemd-mount creating directory in /run/media/system/ folder
Product: [Fedora] Fedora Reporter: matthew.shunshin
Component: selinux-policy-targetedAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 27CC: dwalsh, lnykryn, msekleta, ssahani, s, systemd-maint, zbyszek
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: 2017-11-28 23:55:05 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 matthew.shunshin 2017-11-19 08:00:38 UTC
Description of problem:

As root, unable to mount devices by using:

systemd-mount /dev/sd#

 - prevented by SELinux.

It works if you have created a directory and run:

systemd-mount /dev/sd# /mnt/temp-mount

 but should make a temporary one in /run/media/system



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


How reproducible:




Steps to Reproduce:
1. Plug in usb hard disk
2. systemd-mount /dev/sd#
3. Fails

Actual results:
Nov 18 16:22:46 tank audit[1]: AVC avc:  denied  { create } for  pid=1 comm="systemd" name="media" scontext=system_u:system_r:i
Nov 18 16:22:46 tank systemd[1]: Started File System Check on /dev/sdd.
Nov 18 16:22:46 tank systemd[1]: run-media-system-Backup\x2dMedia.mount: Failed to check directory /run/media/system/Backup-Med
Nov 18 16:22:46 tank systemd[1]: Mounting Elements_10A8 Backup-Media...
Nov 18 16:22:46 tank systemd[1]: run-media-system-Backup\x2dMedia.mount: Mount process exited, code=exited status=32
Nov 18 16:22:46 tank systemd[1]: Failed to mount Elements_10A8 Backup-Media.
Nov 18 16:22:46 tank systemd[1]: run-media-system-Backup\x2dMedia.mount: Unit entered failed state.

Expected results:

Mounted drive in /run/media/system


Additional info:

ausearch + audit2allow works to fix.

Comment 1 Zbigniew Jędrzejewski-Szmek 2017-11-19 09:55:50 UTC
Yeah, systemd needs to be able to create directories.
I think the AVC is truncated in what is pasted here, but it's easy to recreate:

AVC avc:  denied  { create } for  pid=1 comm="systemd" name="media" scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:mnt_t:s0 tclass=dir permissive=1

Comment 2 Fedora Update System 2017-11-22 08:56:55 UTC
selinux-policy-3.13.1-283.17.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2017-d05b1a2ab9

Comment 3 Fedora Update System 2017-11-22 21:42:14 UTC
selinux-policy-3.13.1-283.17.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-d05b1a2ab9

Comment 4 Fedora Update System 2017-11-28 23:55:05 UTC
selinux-policy-3.13.1-283.17.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.