This service will be undergoing maintenance at 00:00 UTC, 2016-09-28. It is expected to last about 1 hours
Bug 376061 - file labeling for /media(/[^/]*)? incorrect
file labeling for /media(/[^/]*)? incorrect
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: hal (Show other bugs)
10
All Linux
low Severity high
: ---
: ---
Assigned To: Richard Hughes
Fedora Extras Quality Assurance
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-11-11 10:37 EST by Philip Ashmore
Modified: 2009-12-18 01:00 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-12-18 01:00:26 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Philip Ashmore 2007-11-11 10:37:05 EST
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):
selinux-policy-3.0.8-44.fc8

How reproducible:
Always

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 11:37:32 EST
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 14:00:22 EST
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 16:33:00 EST
(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 08:45:17 EDT
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 09:56:09 EDT
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
device.  

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 11:01:30 EDT
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 17:20:23 EDT
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
contexts?
I use rewritable media to back up and restore data.
Comment 8 Daniel Walsh 2008-03-19 17:57:58 EDT
Steve and Eric your thoughts?
Comment 9 Stephen Smalley 2008-03-21 09:52:37 EDT
(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 19:10:43 EDT
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 08:41:07 EDT
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 04:56:54 EDT
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 12:15:15 EDT
So, is the outcome that hal should call mount with -o context=removable_t, always ?
Comment 14 Daniel Walsh 2008-10-01 14:15:45 EDT
Yes well it should really use the contents of 

 /etc/selinux/POLICY/contexts/removable_context

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
       media
Comment 15 Bug Zapper 2008-11-25 21:02:55 EST
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:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 16 Bug Zapper 2009-11-18 04:32:54 EST
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: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 17 Bug Zapper 2009-12-18 01:00:26 EST
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.