Bug 737527

Summary: SELinux is preventing /usr/sbin/tgtd "unlink" access on .TGT_IPC_ABSTRACT_NAMESPACE.0.
Product: Red Hat Enterprise Linux 6 Reporter: Omkar <omkarlagu>
Component: scsi-target-utilsAssignee: Andy Grover <agrover>
Status: CLOSED NOTABUG QA Contact: Red Hat Kernel QE team <kernel-qe>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0CC: dwalsh, mmalik, omkarlagu
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-09-13 14:15:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Omkar 2011-09-12 12:43:48 UTC
--------------------------------------------------------------------------------


Summary:

SELinux is preventing /usr/sbin/tgtd "unlink" access on
.TGT_IPC_ABSTRACT_NAMESPACE.0.

Detailed Description:

SELinux denied access requested by tgtd. It is not expected that this access is
required by tgtd and this access may signal an intrusion attempt. It is also
possible that the specific version or configuration of the application is
causing it to require additional access.

Allowing Access:

You can generate a local policy module to allow this access - see FAQ
(http://docs.fedoraproject.org/selinux-faq-fc5/#id2961385) Please file a bug
report.

Additional Information:

Source Context                system_u:system_r:tgtd_t:s0
Target Context                system_u:object_r:tmp_t:s0
Target Objects                .TGT_IPC_ABSTRACT_NAMESPACE.0 [ sock_file ]
Source                        tgtd
Source Path                   /usr/sbin/tgtd
Port                          <Unknown>
Host                          <Unknown>
Source RPM Packages           scsi-target-utils-1.0.4-3.el6
Target RPM Packages           
Policy RPM                    selinux-policy-3.7.19-54.el6
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Plugin Name                   catchall
Host Name                     punb200m2labs04vm5
Platform                      Linux punb200m2labs04vm5 2.6.32-71.el6.x86_64 #1
                              SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64
Alert Count                   1
First Seen                    Tue Sep 13 03:34:03 2011
Last Seen                     Tue Sep 13 03:34:03 2011
Local ID                      7fb1f4c2-fd37-4e52-80e3-d693ef89fc67
Line Numbers                  8424, 8425

Raw Audit Messages            

type=AVC msg=audit(1315865043.545:81309): avc:  denied  { unlink } for  pid=8212 comm="tgtd" name=".TGT_IPC_ABSTRACT_NAMESPACE.0" dev=sda1 ino=781927 scontext=system_u:system_r:tgtd_t:s0 tcontext=system_u:object_r:tmp_t:s0 tclass=sock_file

type=SYSCALL msg=audit(1315865043.545:81309): arch=c000003e syscall=87 success=no exit=-13 a0=7ffffc79a460 a1=42667a a2=22 a3=4543415053454d41 items=0 ppid=8211 pid=8212 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="tgtd" exe="/usr/sbin/tgtd" subj=system_u:system_r:tgtd_t:s0 key=(null)

Additional info:


[root@punb200m2labs02vm6 conf]# cat /etc/issue
Red Hat Enterprise Linux Server release 6.0 (Santiago)
Kernel \r on an \m

[root@punb200m2labs02vm6 conf]# uname -a
Linux punb200m2labs02vm6 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

[root@punb200m2labs02vm6 conf]# rpm -qa | grep selinux
selinux-policy-3.7.19-54.el6.noarch
selinux-policy-targeted-3.7.19-54.el6.noarch
libselinux-2.0.94-2.el6.i686
libselinux-utils-2.0.94-2.el6.x86_64
libselinux-2.0.94-2.el6.x86_64
libselinux-devel-2.0.94-2.el6.x86_64
libselinux-python-2.0.94-2.el6.x86_64

Comment 2 Daniel Walsh 2011-09-12 19:12:49 UTC
Do you know what created .TGT_IPC_ABSTRACT_NAMESPACE.0 and where it is located?

Comment 3 Milos Malik 2011-09-13 06:34:02 UTC
I believe the sock_file is mislabelled and should be located somewhere under /var/run. Here is a similar bug:

https://bugzilla.redhat.com/show_bug.cgi?id=698144

Comment 4 Omkar 2011-09-13 06:46:38 UTC
Looks like tgtd is creating the file in "/tmp/.TGT_IPC_ABSTRACT_NAMESPACE.0"

</snip>
[root@punb200m2labs04vm5 bin]# /etc/init.d/tgtd status
tgtd is stopped

[root@punb200m2labs04vm5 bin]# ls -l /tmp/.TGT_IPC_ABSTRACT_NAMESPACE.0
ls: cannot access /tmp/.TGT_IPC_ABSTRACT_NAMESPACE.0: No such file or directory

[root@punb200m2labs04vm5 bin]# date
Tue Sep 13 22:57:57 IST 2011

[root@punb200m2labs04vm5 bin]# /etc/init.d/tgtd start
Starting SCSI target daemon:                               [  OK  ]

[root@punb200m2labs04vm5 bin]# ls -l /tmp/.TGT_IPC_ABSTRACT_NAMESPACE.0
srwxr-xr-x. 1 root root 0 Sep 13 22:58 /tmp/.TGT_IPC_ABSTRACT_NAMESPACE.0
</snip>

But interestingly I am not hitting the issue. After removing the file and
rebooting the server and again starting /etc/init.d/tgtd start.
I tried one more reboot and start of tgtd, Still cannot hit the issue.

Comment 5 Miroslav Grepl 2011-09-13 11:59:06 UTC
Yes, if the sock file is created by tgtd it should work because of

manage_sock_files_pattern(tgtd_t, tgtd_tmp_t, tgtd_tmp_t)
files_tmp_filetrans(tgtd_t, tgtd_tmp_t, sock_file)

rules.

Comment 6 Omkar 2011-09-13 12:07:47 UTC
Hi miroslav,

What was reason I hit that before. Wasn`t "/tmp/.TGT_IPC_ABSTRACT_NAMESPACE.0" created with tgtd earlier when I hit the issue.

thanks and regards,
Omkar Lagu

Comment 7 Daniel Walsh 2011-09-13 14:15:49 UTC
Examining the policy I see

sesearch -T -s initrc_t -t tmp_t 
Found 2 semantic te rules:
   type_transition initrc_t tmp_t : file initrc_tmp_t; 
   type_transition initrc_t tmp_t : dir initrc_tmp_t; 



Which means if  a process labeled initrc_t created a sock_file in /tmp it would get the default label of tmp_t.

Miroslav please add 

	files_tmp_filetrans(initrc_t, initrc_tmp_t, { dir_file_class_set })


To the same block of code in init.te that contains unconfined_domain(initrc_t) so that we would at least get a clue on what process created the tmp_t socket.

I just checked this into F16.

Omkar It looks like at least once the transition to tgtd_t did not happen and the sock_file was created when the tgtd was running as initrc_t, please delete the socket and if it happens again, please reopen this bug.