Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 396249 - mounted loop devices cause a lot of messages (failures) in selinux enforcing mode.
Summary: mounted loop devices cause a lot of messages (failures) in selinux enforcing ...
Status: VERIFIED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: SE Linux Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-28 00:47 UTC by Nico Baggus
Modified: 2012-01-29 09:25 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nico Baggus 2011-12-28 00:47:19 UTC
All messages are along:

type=AVC msg=audit(1325005143.419:189341): avc:  denied  { use } for  pid=5946 comm="loop0" path="/data/var_amavis.ext4" dev=md7 ino=49156 scontext=system_u:system_r:kernel_t tcontext=system_u:system_r:mount_t tclass=fd

in enforcing mode these are there a LOT, in non-enforcing mode there might be one.
These were caused during restart of fail2ban in enforcing mode in which case 75K of these message were generated in a few seconds.

Any loop mounted device seems to generate this kind of errors on use.

Reproducible: Always
Comment 1 Nico Baggus 2011-12-28 00:49:05 UTC
The rationale for having this on a loop container is that the system has a mirror pair for most data, but spam isn't considered important enough to be stored on a mirror disk. 

Also the /var filesystem has not enough storage to be able to store it there.
Comment 2 Nico Baggus 2011-12-28 00:54:42 UTC
Also i use this for /usr/portage, /usr/src & /usr/share/doc/.
Comment 3 Sven Vermeulen (RETIRED) gentoo-dev 2011-12-28 19:50:03 UTC
How are the loop filesystems mounted? Do you use mount's "-o loop" or losetup or something equivalent?
Comment 4 Nico Baggus 2011-12-29 00:18:48 UTC
They are mounted from fstab, during bootup.

---8<---
/data/var_amavis.ext4   /var/amavis/quarantine-cur              ext4    loop,acl,user_xattr,noatime     2 0
/data/usr_portage.ext4  /usr/portage            ext4    loop,acl,user_xattr,noatime     2 0
/data/usr_src.ext4      /usr/src                ext4    loop,acl,user_xattr,noatime     2 0
/data/usr_share_doc.ext4 /usr/share/doc         ext4    loop,acl,user_xattr,noatime     2 0
---8<---

( four lines ofcourse, ==> mount -o loop variant is used.)
Comment 5 Sven Vermeulen (RETIRED) gentoo-dev 2011-12-29 18:42:38 UTC
Ok, you'll need to first mark the image files as something appropriate. You could use var_t but I use virt_image_t. Next either give mount_t (if you use mount directly) or fsadm_t (if you use losetup) the following rights on the image:

allow mount_t virt_image_t:file { read write open getattr };
allow kernel_t mount_t:fd { use };
allow kernel_t virt_image_t:file { read write open getattr };

That should suffice to get loop-mounted images done correctly. However, you'll still need to make sure that the mountpoints themselves hold the correct context.

I don't mind documenting it, but it's not something that can be added to the policy generically. This is one of the cases where you, as security admin, will need to take the lead imo.
Comment 6 Nico Baggus 2011-12-29 23:04:22 UTC
Ok, i'll try that later,

I do have another question though,
The current setup isn't very update friendly, if someone has private extensions 
(not too uncommon i hope), it would be nice if they could be added in a guaranteed non-clashing way.

/etc/selinux/strict/contexts/files/file_context.manual-update

or something like that. So the manual changes survive a reinstall by adding a new profile.
Or did I miss something, I tried adding a file there and it's just ignored...
And is there a naming rule that prevents colision of private modules with current & possibly future modules.
Comment 7 Sven Vermeulen (RETIRED) gentoo-dev 2011-12-30 18:00:43 UTC
Don't add files manually, but instead of "semanage fcontext" as per http://www.gentoo.org/proj/en/hardened/selinux/selinux-handbook.xml?part=2&chap=2#doc_chap3_sect4

This will keep the changes across updates.
Comment 8 Sven Vermeulen (RETIRED) gentoo-dev 2012-01-29 09:25:19 UTC
Documentation for adding local changes to the policy is at http://www.gentoo.org/proj/en/hardened/selinux-faq.xml#localpolicy