Bug 756809 - Use fs_use_xattr for squashfs
Summary: Use fs_use_xattr for squashfs
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 16
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-24 16:37 UTC by Olivier Samyn
Modified: 2013-01-17 11:01 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-01-17 11:01:36 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Enable fs_use_xattr for squashfs (864 bytes, patch)
2011-11-24 16:37 UTC, Olivier Samyn
no flags Details | Diff

Description Olivier Samyn 2011-11-24 16:37:50 UTC
Created attachment 535982 [details]
Enable fs_use_xattr for squashfs

Description of problem:
As I lack some disc space on my old eeepc, I'm trying to move my /usr folder on a compressed file system.

A good candidate for this is squashfs.

So, I just issued the following command:
mksquashfs /usr /usr.sqsh
And modified my /etc/fstab to mount /usr.sqsh on /usr on boot.

The problem is that the current selinux policy for squashfs do not use the extended attributes stored in my compressed file, and of course, I get AVC alerts because all my /usr files get the default selinux context.

My solution to this problem is to modify the selinux policy to use the extended attributes stored in the squash filesystem (see attached patch).

I do not know if it can be used everywhere(like for livecd instead of a squash filesystem that contains and ext3 image), or if there is another option I can use at mount time.

Comment 1 Daniel Walsh 2011-11-29 02:19:01 UTC
So squashfs now supports extended attributes?

Comment 2 Stephen Smalley 2011-11-29 13:00:35 UTC
Looks like the kernel squashfs code supports listxattr/getxattr.
So the only issue would be whether or not mksquashfs provides a way to set the SELinux attributes when the fs is created.

Comment 3 Stephen Smalley 2011-11-29 13:16:57 UTC
FWIW, I modified mkyaffs2image and make_ext4fs to set SELinux attributes in those filesystems based on an optional file_contexts argument when creating yaffs2 and ext4 images for my Android work, so something similar would likely be needed/desired here.

Comment 4 Daniel Walsh 2011-11-29 16:52:17 UTC
Well if someone made them open source or available for download...

Comment 5 Olivier Samyn 2011-11-29 19:50:58 UTC
Squashfs supports xattr since kernel 2.6.39 and mksquashfs since squashfs tools 4.1.

In the current mksquashfs version (4.2) on fedora 16, mksquashfs adds extended attributes by default when your create a new image (see mksquashfs --help doc).

Comment 6 Daniel Walsh 2011-11-29 20:03:43 UTC
I made this change in Rawhide.  Stephen do you think this change would break anything in F16?  RHEL6?  

Should I typealias fs_t alias squashfs_t;

Comment 7 Stephen Smalley 2011-11-29 20:05:31 UTC
What if anything did you have for squashfs in policy prior to this?

Comment 8 Olivier Samyn 2011-11-29 20:33:06 UTC
Just for info:

I noticed when writing my patch that the kernel name for this filesystem is "squashfs" (defined in the file_system_type structure).

The current selinux policy uses:
genfscon squash / gen_context(system_u:object_r:squash_t,s0)

Notice "squash" is used instead of "squashfs".

When I first wrote my patch, I tried to replace this genfscon line (and the surrounding definitions of squash_t) with:
fs_use_xattr squash gen_context(system_u:object_r:fs_t,s0);

And it never worked; I had to replace "squash" with "squashfs".

So, maybe, the current selinux rule never worked...

Comment 9 Stephen Smalley 2011-11-29 20:44:51 UTC
Curious.  If so, then I can't see that this would pose any problems; previously squashfs files would have been unlabeled_t and now will be file_t if there are no xattrs or the xattr value if set.

Comment 10 Daniel Walsh 2011-11-29 20:47:50 UTC
Excellent, a bug makes this update easier.

Miroslav can you back port

8f21d75460655bed239a1e0039869f8d54298cfb

to F15, F16 and RHEL6.

Comment 11 Olivier Samyn 2011-12-01 11:28:45 UTC
I just tested your patch from: http://git.fedorahosted.org/git/?p=selinux-policy.git;a=patch;h=8f21d75460655bed239a1e0039869f8d54298cfb

Why using fs_use_task instead of fs_use_xattr ?

In fact with the fs_use_task, I only get something like unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.cxxx (I did not copied the exact value).

Comment 12 Miroslav Grepl 2011-12-01 11:37:22 UTC
Added to all.

Comment 13 Olivier Samyn 2011-12-05 09:12:56 UTC
Tested selinux-policy-3.10.0-64.fc16 on Fedora 16 from update-testing.

And work as expected.

Thanks.

Comment 15 Olivier Samyn 2011-12-05 10:29:22 UTC
Done.

Note that the spec file changelog says 
"Use fs_use_xattr for squashf"

It lacks a 's' at the end of squashfS

Comment 16 Fedora End Of Life 2013-01-17 02:08:03 UTC
This message is a reminder that Fedora 16 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 16. 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 '16'.

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 16'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 16 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, you are encouraged to click on 
"Clone This Bug" and open it against that version of Fedora.

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


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