Bug 572782 - SELinux is preventing /usr/sbin/libvirtd from creating a file with a context of svirt_image_t on a filesystem.
Summary: SELinux is preventing /usr/sbin/libvirtd from creating a file with a context ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 12
Hardware: x86_64
OS: Linux
low
medium
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: setroubleshoot_trace_hash:c9ecaceaaf7...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-03-12 00:39 UTC by Sean Bruno
Modified: 2010-03-20 03:32 UTC (History)
12 users (show)

Fixed In Version: selinux-policy-3.6.32-103.fc12
Clone Of:
Environment:
Last Closed: 2010-03-20 03:32:17 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Miroslav add this patch to allow this access. (11.31 KB, application/octet-stream)
2010-03-12 17:25 UTC, Daniel Walsh
no flags Details

Description Sean Bruno 2010-03-12 00:39:11 UTC
Summary:

SELinux is preventing /usr/sbin/libvirtd from creating a file with a context of
svirt_image_t on a filesystem.

Detailed Description:

SELinux is preventing libvirtd from creating a file with a context of
svirt_image_t on a filesystem. Usually this happens when you ask the cp command
to maintain the context of a file when copying between file systems, "cp -a" for
example. Not all file contexts should be maintained between the file systems.
For example, a read-only file type like iso9660_t should not be placed on a r/w
system. "cp -P" might be a better solution, as this will adopt the default file
context for the destination.

Allowing Access:

Use a command like "cp -P" to preserve all permissions except SELinux context.

Additional Information:

Source Context                system_u:object_r:svirt_image_t:s0:c825,c887
Target Context                system_u:object_r:sysfs_t:s0
Target Objects                resource [ filesystem ]
Source                        libvirtd
Source Path                   /usr/sbin/libvirtd
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           libvirt-0.7.1-15.fc12
Target RPM Packages           
Policy RPM                    selinux-policy-3.6.32-92.fc12
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Plugin Name                   filesystem_associate
Host Name                     (removed)
Platform                      Linux (removed) 2.6.32.9-70.fc12.x86_64 #1 SMP
                              Wed Mar 3 04:40:41 UTC 2010 x86_64 x86_64
Alert Count                   1
First Seen                    Thu 11 Mar 2010 04:38:17 PM PST
Last Seen                     Thu 11 Mar 2010 04:38:17 PM PST
Local ID                      26d8aacd-208c-46ad-8895-9cc33a9d38e8
Line Numbers                  

Raw Audit Messages            

node=(removed) type=AVC msg=audit(1268354297.607:28584): avc:  denied  { associate } for  pid=9574 comm="libvirtd" name="resource" dev=sysfs ino=2367 scontext=system_u:object_r:svirt_image_t:s0:c825,c887 tcontext=system_u:object_r:sysfs_t:s0 tclass=filesystem

node=(removed) type=SYSCALL msg=audit(1268354297.607:28584): arch=c000003e syscall=188 success=no exit=-13 a0=7fb2e8dc4830 a1=3cb1815669 a2=7fb2e8d616a0 a3=2d items=0 ppid=1 pid=9574 auid=500 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=1 comm="libvirtd" exe="/usr/sbin/libvirtd" subj=unconfined_u:system_r:virtd_t:s0-s0:c0.c1023 key=(null)



Hash String generated from  filesystem_associate,libvirtd,svirt_image_t,sysfs_t,filesystem,associate
audit2allow suggests:

#============= svirt_image_t ==============
allow svirt_image_t sysfs_t:filesystem associate;

Comment 1 Daniel Walsh 2010-03-12 13:31:45 UTC
Does this mean sysfs now supports labeling?

Comment 2 Eric Paris 2010-03-12 14:24:45 UTC
With a new enough kernel, yes, sysfs does support labeling

Comment 3 Stephen Smalley 2010-03-12 14:48:20 UTC
Specifically 2.6.32 and later.
The sysfs labeling support was added for this purpose, to allow libvirt to label the nodes.
The policy should still use genfscon for it though to provide a default label for the sysfs nodes, but userspace can relabel as long as it is allowed by policy.

Comment 4 Daniel Walsh 2010-03-12 17:25:32 UTC
Created attachment 399702 [details]
Miroslav add this patch to allow this access.

Add this patch to allow libvirt to set svirt_image_t label on sysfs.

Comment 5 Stephen Smalley 2010-03-12 17:48:38 UTC
Dan - we do NOT want fs_use_xattr for sysfs.  That tells SELinux to use ->getxattr() to fetch the initial value for sysfs inodes.  Instead, we want to keep genfscon, but the kernel has changed (as of 2.6.32 and later) to allow userspace to override the genfscon default via setxattr/setfilecon.

Comment 6 Daniel Walsh 2010-03-12 18:21:41 UTC
So just removing
fs_use_xattr sysfs gen_context(system_u:object_r:sysfs_t,s0);

is fine. and add the associate functions.

Comment 7 Miroslav Grepl 2010-03-15 09:21:29 UTC
Fixed in selinux-policy-3.6.32-102.fc12

Comment 8 Fedora Update System 2010-03-15 22:18:27 UTC
selinux-policy-3.6.32-103.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/selinux-policy-3.6.32-103.fc12

Comment 9 Fedora Update System 2010-03-16 23:24:39 UTC
selinux-policy-3.6.32-103.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update selinux-policy'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/selinux-policy-3.6.32-103.fc12

Comment 10 Fedora Update System 2010-03-20 03:30:37 UTC
selinux-policy-3.6.32-103.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.


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