Bug 1038302

Summary: unlabeled_t can't associate with tmpfs_t filesystem type
Product: [Fedora] Fedora Reporter: Cristian Ciupitu <cristian.ciupitu>
Component: selinux-policy-targetedAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED EOL QA Contact: Ben Levenson <benl>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 19CC: dominick.grift, dwalsh, mluscon
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-17 19:31:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Cristian Ciupitu 2013-12-04 20:58:55 UTC
Description of problem:
I got some denials while trying to copy the root filesystem of Fedora 20
machine on a Fedora 19 system using rsync.

This is how one of the files looks on Fedora 20 system:

	[root@f20 ~]# ls -alZ /usr/lib/systemd/system/sshd-keygen.service
	-rw-r--r--. root root system_u:object_r:sshd_keygen_unit_file_t:s0 /usr/lib/systemd/system/sshd-keygen.service

and this is how it looks on the Fedora 19 system:

	[root@f19 backup]# ls -alZ /tmp/F20-root/usr/lib/systemd/system/sshd-keygen.service
	-rw-r--r--. root root system_u:object_r:unlabeled_t:s0 /tmp/F20-root/usr/lib/systemd/system/sshd-keygen.service

Version-Release number of selected component (if applicable):
selinux-policy-targeted-3.12.1-74.14.fc19.noarch

How reproducible:
Every time

Steps to Reproduce:
1. mount /dev/disk/by-id/xxxxxxx /tmp/F20-root
2. rsync -v -aAX /tmp/F20-root/usr/lib/systemd/system/sshd-keygen.service /tmp/backup/

Actual results:
rsync: rsync_xal_set: lsetxattr(""/tmp/backup/.sshd-keygen.service.vU5fPh"","security.selinux") failed: Permission denied (13)

sent 363 bytes  received 33 bytes  792.00 bytes/sec
total size is 201  speedup is 0.51
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.9]

Expected results:
No errors

Additional info:
grift (Dominick Grift) from #fedora-selinux helped me with this issue.

ausearch returns the following denial:

	time->Wed Dec  4 22:51:51 2013
	type=SYSCALL msg=audit(1386190311.139:1045): arch=c000003e syscall=189 success=no exit=-13 a0=7fff66f6cc30 a1=194bfd1 a2=194bfb0 a3=21 items=0 ppid=8257 pid=8258 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 ses=1 tty=pts1 comm="rsync" exe="/usr/bin/rsync" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)
	type=AVC msg=audit(1386190311.139:1045): avc:  denied  { associate } for  pid=8258 comm="rsync" name=".sshd-keygen.service.vU5fPh" dev="tmpfs" ino=243919 scontext=system_u:object_r:unlabeled_t:s0 tcontext=system_u:object_r:tmpfs_t:s0 tclass=filesystem

Comment 1 Cristian Ciupitu 2013-12-04 21:04:41 UTC
In case it matters this is how the fileystems are mounted:
  tmpfs on /tmp type tmpfs (rw,seclabel)
  /dev/xxx on /tmp/F20-root type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

Comment 2 Cristian Ciupitu 2013-12-04 21:19:23 UTC
I've also done an experiment with tar:

    [root@f19 backup]# tar -c -f - --acls --selinux \
            --xattrs --xattrs-include='*' \
            -C /tmp/F20-root \
            /usr/lib/systemd/system/sshd-keygen.service | \
        tar -x -f - --acls --selinux \
            --xattrs --xattrs-include='*' \
            -C /tmp/backup/dst
    tar: Removing leading `/' from member names
    [root@f19 backup]# ls -lZ /tmp/backup/dst/usr/lib/systemd/system/sshd-keygen.service
    -rw-r--r--. root root system_u:object_r:sshd_unit_file_t:s0 /tmp/backup/dst/usr/lib/systemd/system/sshd-keygen.service

The programs that I'm using are:
rsync-3.0.9-12.fc19.x86_64
tar-1.26-27.fc19.x86_64

Comment 3 Cristian Ciupitu 2013-12-04 22:00:56 UTC
Adding the maintainer of rsync in case this is an issue with rsync.

Comment 4 Daniel Walsh 2013-12-05 17:08:53 UTC
unlabeled_t is a misnamed type, it should be unknown_label_t, or something like that.  Basically it means that a file has a label that the kernel does not understand and you are bing blocked from putting that label on the file system.

Comment 5 Cristian Ciupitu 2013-12-06 10:25:19 UTC
Now I understand better what's going on, but there are still a SELinux
denial and a rsync error.

Comment 6 Dominick Grift 2013-12-06 11:00:48 UTC
Lets change this existing rule:

allow unlabeled_t fs_t:filesystem associate;

to

allow unlabeled_t xattrfs:filesystem associate;

and associate the xattrfs type attribute with all filesystem types that support extended attributes

SELinux must be able to failover on any filesystem that supports xattrs.

Its perfectly conceivable that for example a file on /run (which is on a tmpfs_t filesystem) becomes invalid at runtime. SELinux must be able to failover, and be able to associate unlabeled_t with that file

There are some more less likely scenarios i suspect like for example sysfs, securityfs, i guess any file system that supports extended attributes.

Point i am trying to make here: SELinux must be able to failover.

Comment 7 Daniel Walsh 2013-12-16 15:59:30 UTC
I agree.

Comment 8 Fedora End Of Life 2015-01-09 20:46:47 UTC
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

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.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 19 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  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

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.

Comment 9 Fedora End Of Life 2015-02-17 19:31:42 UTC
Fedora 19 changed to end-of-life (EOL) status on 2015-01-06. Fedora 19 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. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

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