Bug 376061 - file labeling for /media(/[^/]*)? incorrect
Summary: file labeling for /media(/[^/]*)? incorrect
Alias: None
Product: Fedora
Classification: Fedora
Component: hal   
(Show other bugs)
Version: 10
Hardware: All Linux
Target Milestone: ---
Assignee: Richard Hughes
QA Contact: Fedora Extras Quality Assurance
Keywords: Triaged
Depends On:
TreeView+ depends on / blocked
Reported: 2007-11-11 15:37 UTC by Philip Ashmore
Modified: 2009-12-18 06:00 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2009-12-18 06:00:26 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Philip Ashmore 2007-11-11 15:37:05 UTC
Description of problem:
system-config-selinux shows file labeling for /media(/[^/]*)? file type
directory as system_u:object_r:mnt_t, not system_u:object_r:removable_t.
This prevents modifications to removable ext3 media 
Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. In KDE, plug in an external ext3 media
2. Click the primary mouse button on the storage media applet, drive/partition
icon and select 'Mount'.
3. The partition is mounted as a directory under the '/media/ directory.
4. chdir to a folder under the mount directory.
5. try to create a file, e.g. 'touch test.txt'
Actual results:
The setroubleshoot applet appears on the KDE panel indicating 'AVC denial'.
Clicking on the icon displays the setroubleshoot browser.
    Entry details:
    Category: File Label
    Summary: SELinux is preventing touch from creating a file with a context of
unlabeled_t on a filesystem

Expected results:
The file should be created

Additional info:
1. There isn't a bug section for system-config-selinux. I tried to change the
selinux type from mnt_t to removable_t and got cryptic errors.
2. It's unclear how to prevent Fedora from using security contexts on removable
media in general or for a specific media.

Comment 1 Daniel Walsh 2007-11-26 16:37:32 UTC
This is really a hal bug.  Hal needs to either always mount these file systems
as removable_t.  Which would be a problem for file system like dosfs_t.  And
file systems with actual labels.  

I guess in the ideal situation, hal would somehow figure out if the file system
is a file system that supports labels.  If yes then check to see if it has
labels on the root /?  If not then mount it removable_t if yes then just mount it.

Comment 2 David Zeuthen 2007-11-26 19:00:22 UTC
Surely it would be nicer to make mount(8) do this... right? (hal just invokes
mount(8) as uid 0). Alternatively we can teach hal to do this...

Comment 3 Karel Zak 2007-11-26 21:33:00 UTC
(In reply to comment #1)
> I guess in the ideal situation, hal would somehow figure out if the file system
> is a file system that supports labels.  If yes then check to see if it has
> labels on the root /?  If not then mount it removable_t if yes then just mount it.

I don't know about any generic way how read xattr from non-mounted FS. It's
unsupported by libvolume_id or libblkid. It means we need to mount it without
any context, call getfilecon() and possibly *remount* it with context=removable_t.

Does it make sense?

Comment 4 Karel Zak 2008-03-19 12:45:17 UTC
I'm not sure if I good understand a relation between this request and bug
#390691 where you ask for a warning message when a mounted FS is unlabeled. Or
do you expect a different behaviour for the /media directory?

Shouldn't be better to mount all unlabeled / non-xattr filesystems with
context=removable_t ?

Comment 5 Daniel Walsh 2008-03-19 13:56:09 UTC
We could simply always make hal mount file systems with xattr support as
removable_t, but this would eliminate me being able to use labels on a removable

Another option would be for hal or mount to check as you described above.  Check
the file context on mount, if it returns file_t, remount as removable_t.

The mount command can give a warning that is described in the other bug, but hal
can not.

Comment 6 Karel Zak 2008-03-19 15:01:30 UTC
What about a kernel based solution? I mean a new mount(2) option -- something
like a conditional context= for unlabeled / non-xattr filesystems. 

    # mount /dev/flashdisk /media/foo -o condcontext=removable_t

if the /dev/flashdisk is labeled the option is ignored otherwise it's mounted
with context=removable_t.

Comment 7 Philip Ashmore 2008-03-19 21:20:23 UTC
It looks like these are implementation questions, so it's not something I can
contribute to.
My two cents worth is that removable media shouldn't be labeled at all, it's the
mount point that needs a label.
Would it be useful to mount a device in different places to provide different
I use rewritable media to back up and restore data.

Comment 8 Daniel Walsh 2008-03-19 21:57:58 UTC
Steve and Eric your thoughts?

Comment 9 Stephen Smalley 2008-03-21 13:52:37 UTC
(this kind of question likely belongs on selinux list)
I would say that the default should be to mount removable media with a fixed
label via a context mount, i.e. don't trust the attributes on the media even if
present.  Think of it being analogous to nosuid nodev.
With suitable privileges, user may be able to mount removable media and use
xattrs on it (if supported by the filesystem type).
There is already a removable_context config file that contains the default
context for such media, and libselinux exports its path via a function.  Not
sure who calls it at present - hal or mount?

Comment 10 Daniel Walsh 2008-03-21 23:10:43 UTC
Ok since hal is the one mounting the removable media, it should probably just
call the mount command with the correct mount option.  And if you want to
support removable media with file context you will need to override this behaviour.

Comment 11 Stephen Smalley 2008-03-24 12:41:07 UTC
It looks like hal did this at one time in the past - I see mention of selinux
removable context in the ChangeLog.  But not in the current code?

Comment 12 Karel Zak 2008-06-23 08:56:54 UTC
Reassigning to HAL.

(for more details see comments #9, #10 --  most especially:  "i.e. don't trust
the attributes on the media even if present. Think of it being analogous to
nosuid nodev.")

Comment 13 Matthias Clasen 2008-10-01 16:15:15 UTC
So, is the outcome that hal should call mount with -o context=removable_t, always ?

Comment 14 Daniel Walsh 2008-10-01 18:15:45 UTC
Yes well it should really use the contents of 


Function call selinux_removable_context_path      

man selinux_removable_context_path
 extern const char *selinux_removable_context_path(void);
       selinux_removable_context_path() -  filesystem  context  for  removable

Comment 15 Bug Zapper 2008-11-26 02:02:55 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 10 development cycle.
Changing version to '10'.

More information and reason for this action is here:

Comment 16 Bug Zapper 2009-11-18 09:32:54 UTC
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 

Comment 17 Bug Zapper 2009-12-18 06:00:26 UTC
Fedora 10 changed to end-of-life (EOL) status on 2009-12-17. Fedora 10 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

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