<div dir="ltr"><div>Thanks for pointing this out (I didn&#39;t know about that), but it seems that our problem is not affected by this.<br>Our /tmp directory resides on the root filesystem, for which the nosuid mount option is not specified.<br><br>[root@centos-test ~]# mount<br>/dev/mapper/vg_centostest-lv_root on / type ext4 (rw)<br>proc on /proc type proc (rw)<br>sysfs on /sys type sysfs (rw)<br>devpts on /dev/pts type devpts (rw,gid=5,mode=620)<br>tmpfs on /dev/shm type tmpfs (rw,rootcontext=&quot;system_u:object_r:tmpfs_t:s0&quot;)<br>/dev/sda1 on /boot type ext4 (rw)<br>none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)<br><br></div>Janos<br><div><div class="gmail_extra"><br><div class="gmail_quote">2015-05-14 15:10 GMT+02:00 Stephen Smalley <span dir="ltr">&lt;<a href="mailto:sds@tycho.nsa.gov" target="_blank">sds@tycho.nsa.gov</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 05/14/2015 09:07 AM, SZIGETVÁRI János wrote:<br>
&gt; Hello Everyone,<br>
&gt;<br>
&gt; I work for a company which develops an rsyslog alternative logging<br>
&gt; service, and we recently have encountered an interesting problem around<br>
&gt; the SELinux process transitions of our product.<br>
&gt;<br>
&gt; I and most of my colleagues have little to marginal experience with<br>
&gt; SELinux, and we have done most of the investigation we could do on our own.<br>
&gt;<br>
&gt; The problem that one of our customers experienced is that our product<br>
&gt; (when started by it&#39;s init script, or through the service ... utility)<br>
&gt; will be stuck in the initrc_t context, and not transition into the<br>
&gt; syslogd_t context. This causes the /dev/log socket not to have the<br>
&gt; proper selinux context, which leads to even further problems.<br>
&gt; The system they are working on is running CentOS 6.6.<br>
&gt;<br>
&gt; To describe the problem in a bit more detail:<br>
&gt; - we have an init script with the selinux context of<br>
&gt; system_u:object_r:syslogd_initrc_exec_t:s0<br>
&gt; - this init script calls the binary, which has the context of:<br>
&gt; system_u:object_r:syslogd_exec_t:s0<br>
&gt;<br>
&gt; - the necessary process transtition definitions are in place:<br>
&gt; [root@centos-test ~]# sesearch -T -s initrc_t -t syslogd_initrc_exec_t<br>
&gt; -c process -p transition -A<br>
&gt; Found 1 semantic te rules:<br>
&gt;    type_transition initrc_t syslogd_initrc_exec_t : process initrc_t;<br>
&gt; [root@centos-test ~]# sesearch -T -s initrc_t -t syslogd_exec_t -c<br>
&gt; process -p transition -A<br>
&gt; Found 1 semantic te rules:<br>
&gt;    type_transition initrc_t syslogd_exec_t : process syslogd_t;<br>
&gt;<br>
&gt; - the necessary execution permissions are present<br>
&gt; [root@centos-test ~]# sesearch -s initrc_t -t syslogd_exec_t -c file -p<br>
&gt; execute -A<br>
&gt; Found 3 semantic av rules:<br>
&gt;    allow initrc_t exec_type : file { ioctl read getattr lock execute<br>
&gt; execute_no_trans open } ;<br>
&gt;    allow initrc_t syslogd_exec_t : file { read getattr execute open } ;<br>
&gt;    allow files_unconfined_type file_type : file { ioctl read write<br>
&gt; create getattr setattr lock relabelfrom relabelto append unlink link<br>
&gt; rename execute swapon quotaon mounton execute_no_trans entrypoint open } ;<br>
&gt;<br>
&gt; - the necessary types are defined as the domain entry points<br>
&gt; [root@centos-test ~]# sesearch -s syslogd_t -t syslogd_exec_t -c file -p<br>
&gt; entrypoint -A<br>
&gt; Found 1 semantic av rules:<br>
&gt;    allow syslogd_t syslogd_exec_t : file { ioctl read getattr lock<br>
&gt; execute entrypoint open } ;<br>
&gt;<br>
&gt; - the target domain is allowed for the proper role:<br>
&gt; [root@centos-test ~]# seinfo -rsystem_r -x | fgrep syslogd_t<br>
&gt;          syslogd_t<br>
&gt;<br>
&gt;<br>
&gt; But despite all the above, the transition doesn&#39;t occur to syslogd_t,<br>
&gt; the process remains in initrc_t.<br>
&gt;<br>
&gt; I even have created a script to reproduce the issue (find it attached).<br>
&gt; The script simply<br>
&gt; - puts down two shell scripts and sets their rights and selinux contexts<br>
&gt; (system_u:object_r:syslogd_initrc_exec_t:s0 and<br>
&gt; system_u:object_r:syslogd_exec_t:s0) ,<br>
&gt; - creates a copy of bash, sets it&#39;s context (to<br>
&gt; system_u:object_r:syslogd_initrc_exec_t:s0),<br>
&gt; - tries to run the script with the syslogd_initrc_exec_t context,<br>
&gt; - which in turn will run the other script with context syslogd_exec_t<br>
&gt;<br>
&gt; The resulting output shows that the script with the syslogd_exec_t<br>
&gt; context will run as initrc_t even though it&#39;s parent was initrc_t as<br>
&gt; well, and the type transition should have occurred.<br>
&gt;<br>
&gt;<br>
&gt; Some sample output:<br>
&gt;<br>
&gt; [root@centos-test ~]# bash selinux_test.sh<br>
&gt; -rwxr-xr-x. root root system_u:object_r:syslogd_initrc_exec_t:s0<br>
&gt; /tmp/tmp.efz1wH7wpL/bash_initrc_exec_t<br>
&gt; -rwxr-xr-x. root root system_u:object_r:syslogd_exec_t:s0<br>
&gt; /tmp/tmp.efz1wH7wpL/syslogd_exec_t_runner.sh<br>
&gt; -rwxr-xr-x. root root system_u:object_r:syslogd_initrc_exec_t:s0<br>
&gt; /tmp/tmp.efz1wH7wpL/syslogd_initrc_exec_t_starter.sh<br>
&gt; ======================== STARTING<br>
&gt; ===============================================<br>
&gt; Authenticating root.<br>
&gt; Jelszó:<br>
&gt; system_u:system_r:initrc_t:s0   root      3352  0.0  0.0 106056  1296<br>
&gt; pts/0    S+   14:50   0:00              \_<br>
&gt; /tmp/tmp.efz1wH7wpL/bash_initrc_exec_t<br>
&gt; /tmp/tmp.efz1wH7wpL/syslogd_initrc_exec_t_starter.sh<br>
&gt; ======================== STARTED<br>
&gt; ===============================================<br>
&gt; system_u:system_r:initrc_t:s0   root      3359  0.0  0.0 106056  1340<br>
&gt; pts/0    S+   14:50   0:00 /tmp/tmp.efz1wH7wpL/bash_initrc_exec_t<br>
&gt; /tmp/tmp.efz1wH7wpL/syslogd_exec_t_runner.sh<br>
&gt; system_u:system_r:initrc_t:s0   root      3362  0.0  0.0 106056  1336<br>
&gt; pts/0    S+   14:50   0:00 /tmp/tmp.efz1wH7wpL/bash_initrc_exec_t<br>
&gt; /tmp/tmp.efz1wH7wpL/syslogd_exec_t_runner.sh end<br>
&gt; ============================= first<br>
&gt; ==========================================<br>
&gt; system_u:system_r:initrc_t:s0   root      3359  0.0  0.0 106056  1340<br>
&gt; pts/0    S+   14:50   0:00 /tmp/tmp.efz1wH7wpL/bash_initrc_exec_t<br>
&gt; /tmp/tmp.efz1wH7wpL/syslogd_exec_t_runner.sh<br>
&gt; system_u:system_r:initrc_t:s0   root      3362  0.0  0.0 106056  1336<br>
&gt; pts/0    S+   14:50   0:00 /tmp/tmp.efz1wH7wpL/bash_initrc_exec_t<br>
&gt; /tmp/tmp.efz1wH7wpL/syslogd_exec_t_runner.sh end<br>
&gt; ============================= end ==========================================<br>
&gt; system_u:system_r:initrc_t:s0   root      3359  0.0  0.0 106060  1360<br>
&gt; pts/0    S+   14:50   0:00 /tmp/tmp.efz1wH7wpL/bash_initrc_exec_t<br>
&gt; /tmp/tmp.efz1wH7wpL/syslogd_exec_t_runner.sh<br>
&gt; system_u:system_r:initrc_t:s0   root      3362  0.0  0.0 106060  1352<br>
&gt; pts/0    S+   14:50   0:00 /tmp/tmp.efz1wH7wpL/bash_initrc_exec_t<br>
&gt; /tmp/tmp.efz1wH7wpL/syslogd_exec_t_runner.sh end<br>
&gt; [root@centos-test ~]#<br>
&gt;<br>
&gt;<br>
&gt; We would appreciate if we could get some guidance on what we should<br>
&gt; check, in order to get to the end of this problem.<br>
&gt; We have tried running setroubleshootd, disabling noaudit rules (semodule<br>
&gt; -DB), but we saw no error messages about failed transitions, or<br>
&gt; whatsoever. The only logs we saw related to the scripts were the<br>
&gt; authentication and accounting messages about the run_init command.<br>
<br>
</div></div>SELinux domain transitions are suppressed on nosuid mounts for the same<br>
reasons that setuid/setgid is suppressed.<br>
<br>
<br>
<br>
</blockquote></div><br><br></div></div></div>