<?xml version='1.0' encoding='utf-8' ?>
<!--  If you are running a bot please visit this policy page outlining rules you must respect. http://www.livejournal.com/bots/  -->
<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:media='http://search.yahoo.com/mrss/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Dan Walsh&apos;s Blog</title>
  <link>http://danwalsh.livejournal.com/</link>
  <description>Dan Walsh&apos;s Blog - LiveJournal.com</description>
  <managingEditor>dwalsh@redhat.com</managingEditor>
  <lastBuildDate>Wed, 25 Apr 2012 12:37:48 GMT</lastBuildDate>
  <generator>LiveJournal / LiveJournal.com</generator>
  <lj:journal>danwalsh</lj:journal>
  <lj:journalid>9465280</lj:journalid>
  <lj:journaltype>personal</lj:journaltype>
  <atom10:link rel='hub' href='http://pubsubhubbub.appspot.com/' />
  <image>
    <url>http://l-userpic.livejournal.com/61868732/9465280</url>
    <title>Dan Walsh&apos;s Blog</title>
    <link>http://danwalsh.livejournal.com/</link>
    <width>73</width>
    <height>100</height>
  </image>

<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/56179.html</guid>
  <pubDate>Wed, 25 Apr 2012 12:37:48 GMT</pubDate>
  <title>Fedora 17 New Security Feature part X - Firewalld</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/56179.html</link>
  <description>&lt;p&gt;&lt;a href=&quot;https://fedoraproject.org/wiki/FirewallD&quot; rel=&quot;nofollow&quot;&gt;FirewallD is a service daemon with a D-BUS interface that provides a dynamic managed firewall.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It will be the default firewall in Fedora 18, but will be available to run in Fedora 17.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;NOTE:&amp;nbsp; I was informed that this feature was supposed to be default in Fedora 17, but has been decided to wait until Fedora 18.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The problem with the previous firewall model was that it was static, you would need to basically reload the firewall rules any time you made a change, and this would break established connections.&amp;nbsp; This is a real problem for virtualization (libvirt), since you might be changing your firewall often bringing up and down virtual machines.&amp;nbsp; FirewallD provides a daemon that applications can talk to over DBUS, to request modifications to firewall rules.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Another nice feature would be to allow a user to have rules that control firewall rules depending on the wireless network to which they connect.&amp;nbsp; For example NetworkManager could come up with a question of whether this is the Home Network, Work Network or Public Network.&amp;nbsp;&amp;nbsp; Firewall rules might allow Avahi to connect if you are on a Home or Work network but not a Public Network.&lt;br /&gt;&lt;br /&gt;In the future I would like to add make FirewallD a SELinux Userpace Manager.&amp;nbsp; This would allow a policy writer could to control which applications are able to manipulate firewall rules pertaining to which ports.&amp;nbsp; Something like&lt;br /&gt;&lt;br /&gt;allow cupsd_t cups_port_t:tcp_firewall { open close };&lt;/p&gt;</description>
  <comments>http://danwalsh.livejournal.com/56179.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>4</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/55837.html</guid>
  <pubDate>Tue, 24 Apr 2012 14:12:18 GMT</pubDate>
  <title>Fedora 17 New Security Feature part IX - File Name Transitions</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/55837.html</link>
  <description>&lt;a href=&quot;http://danwalsh.livejournal.com/46018.html&quot;&gt;File Name Transitions were introduced to the kernel in Fedora 16 by Eric Paris.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Eric actually expected policy writers to only add a few dozen file name transition rules, well in Fedora 17 we now have nearly 100,000 rules:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;sesearch -T /etc/selinux/targeted/policy/policy.27 | grep \&amp;quot; | wc -l&lt;br /&gt;94736&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Most of these rules are to make devices created in /dev and files/directories created by the unconfined/admin processes be labelled correctly.&amp;nbsp; A common problem users of SELinux have seen was when an unconfined_t user creating /root/.ssh or $HOME/.ssh.&amp;nbsp; Then they would place authorization content in the directory.&amp;nbsp; When they tried to use the content to gain access to the system via sshd, sshd would be blocked from the directory by SELinux because the directory and its contents had the wrong label.&amp;nbsp; The user needs to run &lt;span style=&quot;color:#0000ff;&quot;&gt;restorecon -R -v /root/.ssh&lt;/span&gt; to fix the labels.&lt;br /&gt;&lt;br /&gt;Before File Name Transitions the directory would be created with the label based on the label of /root, admin_home_t.&amp;nbsp;&amp;nbsp; But as of Fedora 16 Policy Writers write rules that say:&amp;nbsp; &amp;quot;If the &lt;span style=&quot;color:#0000ff;&quot;&gt;unconfined_t&lt;/span&gt; user creates a &lt;span style=&quot;color:#0000ff;&quot;&gt;directory&lt;/span&gt; named &lt;span style=&quot;color:#0000ff;&quot;&gt;.ssh&lt;/span&gt; in a directory labelled &lt;span style=&quot;color:#0000ff;&quot;&gt;admin_home_&lt;/span&gt;t, it will get created as &lt;span style=&quot;color:#0000ff;&quot;&gt;ssh_home_t&lt;/span&gt;.&amp;quot;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &lt;span style=&quot;color:#0000ff;&quot;&gt;type_transition unconfined_t admin_home_t : dir ssh_home_t &amp;quot;.ssh&amp;quot;;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;How is this a security feature?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://danwalsh.livejournal.com/43170.html&quot;&gt;I explained in a previous blog, there are three ways content gets labeled within a directory.&lt;/a&gt;&amp;nbsp; The File Transition rule is a mechanism the policy writer has used since SELinux was first developed to create content within a directory with a different label then the directories label.&amp;nbsp; Policy writers wrote rules that said if a process running as &lt;span style=&quot;color:#0000ff;&quot;&gt;NetworkManager_t&lt;/span&gt; created a &lt;span style=&quot;color:#0000ff;&quot;&gt;file&lt;/span&gt; in a directory labeled &lt;span style=&quot;color:#0000ff;&quot;&gt;etc_t&lt;/span&gt; it would be labeled &lt;span style=&quot;color:#0000ff;&quot;&gt;net_conf_t.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &lt;span style=&quot;color:#0000ff;&quot;&gt;type_transition NetworkManager_t etc_t : file net_conf_t; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Or if a process running as &lt;span style=&quot;color:#0000ff;&quot;&gt;mozilla_t &lt;/span&gt;created a &lt;span style=&quot;color:#0000ff;&quot;&gt;directory&lt;/span&gt; in a directory labeled &lt;span style=&quot;color:#0000ff;&quot;&gt;user_home_dir_t&lt;/span&gt;, it would get created as &lt;span style=&quot;color:#0000ff;&quot;&gt;mozilla_home_t&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;&amp;nbsp; type_transition mozilla_t user_home_dir_t : dir mozilla_home_t;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But this is not very fine grained control.&amp;nbsp; A hacked NetworkManager could create any file in a any directory labeled etc_t, if it did not exist.&amp;nbsp; If /etc/passwd did not exist for some reason SELinux would not block a confined NetworkManager from creating its own /etc/passwd.&amp;nbsp; A hacked firefox running as mozilla_t would not be blocked from creating a missing $HOME/.ssh directory.&lt;br /&gt;&lt;br /&gt;With File Name Transition rules, policy writers can now specify the file name.&amp;nbsp; Meaning we can writer finer grained control.&amp;nbsp; We can say NetworkManager can only create the &amp;quot;resolv.conf&amp;quot; file in a directory labeled etc_t or a &amp;nbsp; confined firefox can only create the .mozilla directory in a users home directory&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://danwalsh.livejournal.com/54092.html&quot;&gt;As an example of this the Thumbnail confinement added in Fedora 17 has:&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;type_transition thumb_t user_home_dir_t : file thumb_home_t &amp;quot;missfont.log&amp;quot;;&lt;br /&gt;type_transition thumb_t user_home_dir_t : dir thumb_home_t &amp;quot;.thumbnails&amp;quot;;&lt;br /&gt;type_transition thumb_t user_home_dir_t : dir gstreamer_home_t &amp;quot;.gstreamer-12&amp;quot;;&lt;br /&gt;type_transition thumb_t user_home_dir_t : dir gstreamer_home_t &amp;quot;.gstreamer-10&amp;quot;;&lt;br /&gt;type_transition thumb_t user_home_dir_t : dir gstreamer_home_t &amp;quot;.gstreamer-0.10&amp;quot;;&lt;br /&gt;type_transition thumb_t user_home_dir_t : dir gstreamer_home_t &amp;quot;.gstreamer-0.12&amp;quot;; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which means thumbnailers running as thumb_t can only create a file labelled missfont.log or directories labeled .thumbnails or .gstreamer-* in the home directory.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:larger;&quot;&gt;Nice job Eric, you increased the Security of SELinux and made it easier to use at the same time!&lt;/span&gt;</description>
  <comments>http://danwalsh.livejournal.com/55837.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/55588.html</guid>
  <pubDate>Wed, 28 Mar 2012 12:40:09 GMT</pubDate>
  <title>runuser versus su</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/55588.html</link>
  <description>&lt;p&gt;Many years ago, we noticed SELinux having problems with the su command.&amp;nbsp; Many confined domains were using su to switch user from root to some non privileged user.&amp;nbsp; But this would generate lots of bogus SELinux errors such as:&lt;br /&gt;&lt;br /&gt;Domain X_t wants to getattr on the fingerprint device or look at the pid file of the Smart Card reader.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;su using the pam_stack was the cause of these errors.&amp;nbsp; Depending on which pam_modules you had in the /etc/pam.d/su configuration, certain access would be checked.&amp;nbsp; Services using su do not want/need these side effects of using the pam stack.&amp;nbsp; SELinux policy writers do not want to allow the access or add dontaudit rules all over the place.&lt;br /&gt;&lt;br /&gt;In order to fix this, we built a new application called runuser.&amp;nbsp; runuser is actually built from the su.c source code.&amp;nbsp; You just define the RUNUSER constant when compiling su.c.&amp;nbsp; Basically runuser is just the su command with the pam stack removed as well as verifying the command is running as root, not setuid.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Whenever an service is running as root and wants to change UID using the shell it should use &lt;span style=&quot;font-size:larger;&quot;&gt;runuser&lt;/span&gt;.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;When you are logged in to a shell as a user and want to become root, you should use su.&amp;nbsp; (Or better yet sudo)&lt;/p&gt;</description>
  <comments>http://danwalsh.livejournal.com/55588.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>3</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/55324.html</guid>
  <pubDate>Thu, 22 Mar 2012 14:19:45 GMT</pubDate>
  <title>Eating my own dogfood.</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/55324.html</link>
  <description>I am going on a trip tomorrow, I went to the Jet Blue web site to print my boarding pass.&amp;nbsp; The Jet Blue site has what I believe is a java application&amp;nbsp; running in the browser that displays your boarding pass.&amp;nbsp; I pressed the &amp;quot;Print&amp;quot; button on the screen and a print dialog came up, without any printers, and the &amp;quot;Print&amp;quot; button grayed out.&amp;nbsp;&amp;nbsp; I did not notice the, setroubleshoot warning in gnome 3.&amp;nbsp; Figuring the print application was just broken, I decided to select print from the browser.&amp;nbsp; Sadly the browser printed a blank page.&amp;nbsp; I then bad mouthed Firefox/Linux printing.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Mia Culpa&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I noticed that I had AVC&amp;#39;s that looked like mozilla_plugin_t was trying to getattr on lpr_exec_t.&amp;nbsp;&amp;nbsp;&amp;nbsp; I put mozilla_plugin_t into permissive mode, to find out all the access required.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# semanage permissive -a mozilla_plugin_t&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I went back to Jet Blue and tried to print the boarding pass again.&amp;nbsp; This time the printers showed up and I was able to print my boarding pass.&lt;br /&gt;&lt;br /&gt;Now I had AVC&amp;#39;s that indicated&amp;nbsp; mozilla_plugin_t was executing lpr_exec_t.&amp;nbsp; Also lpr was connecting to the cups and gnome-keyring daemon.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Should I transition or add allow rules for mozilla_plugin_t?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;As a policy writer I had to choice whether to allow mozilla_plugin_t all of these accesses or have mozilla_plugin_t transition to the lpr_t domain when it executes&amp;nbsp; /usr/bin/lpr.&amp;nbsp;&amp;nbsp; These decisions are key to writing good security policy.&amp;nbsp; My rule of thumb is if the domain i would transition to is very powerful, I hesitate to transition. &amp;nbsp; Especially if the parent application requires limited access when executing the child. For example a user can run rpm in their current domain (staff_T) to list all rpm packages, while if I allowed them to transition to the rpm_t domain, they would be allowed install rpm packages.&amp;nbsp; In the mozilla_plugin_t case the advantage of transitioning to lpr_t allows me to continue to prevent mozilla plugins from talking directly to the cups server and&amp;nbsp; the gnome-keyring and lpr_t is a very limited domain, so I chose to transition.&lt;br /&gt;&lt;br /&gt;My initial policy looked like this:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;policy_module(mypol, 1.0)&lt;br /&gt;&lt;br /&gt;require {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; type mozilla_plugin_t;&lt;br /&gt;}&lt;br /&gt;lpd_domtrans_lpr(mozilla_plugin_t)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now I tried to print the boarding pass again, and now I had AVC&amp;#39;s that stated lpr_t was trying to connect to keyring.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;audit2allow -R&lt;/span&gt; indicated that I should use:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;gnome_stream_connect_gkeyringd(lpr_t)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;audit2allow also showed that I was failing on Roles Based Access Control (RBAC).&amp;nbsp;&amp;nbsp; Users seldom see these types of errors. They show up in the log file as SELINUX_ERR rather then AVC.&lt;br /&gt;&lt;br /&gt;type=&lt;b&gt;SELINUX_ERR&lt;/b&gt; msg=audit(1332420617.119:909): security_compute_sid:&amp;nbsp; invalid context &lt;span style=&quot;color:#0000ff;&quot;&gt;staff_u:staff_r:lpr_t:s0-s0:c0.c1023&lt;/span&gt; for scontext=staff_u:staff_r:lpr_t:s0-s0:c0.c1023 tcontext=staff_u:staff_r:lpr_t:s0-s0:c0.c1023 tclass=unix_stream_socket&lt;br /&gt;&lt;br /&gt;This AVC is basically saying the &lt;span style=&quot;color:#0000ff;&quot;&gt;staff_u:staff_r:lpr_t:&lt;/span&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;s0-s0:c0.c1023&lt;/span&gt; is an invalid label.&lt;br /&gt;&lt;br /&gt;Hard to tell from this error what is wrong, but luckily audit2allow translates this into:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;role staff_r types lpr_t;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Since I run with the staff_r role, I had to add an RBAC rule that would allow staff_r role to reach the lpr_t type.&lt;br /&gt;&lt;br /&gt;My final policy looks like:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;policy_module(mypol, 1.0)&lt;br /&gt;require {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; type mozilla_plugin_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; type lpr_t;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; role staff_r;&lt;br /&gt;}&lt;br /&gt;lpd_domtrans_lpr(mozilla_plugin_t)&lt;br /&gt;role staff_r types lpr_t;&lt;br /&gt;gnome_stream_connect_gkeyringd(lpr_t)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Notice how I am transitioning from mozilla_plugin_t to lpr_t.&amp;nbsp; This does not mean staff_t will transition to lpr_t when running /usr/bin/lpr. &amp;nbsp;&lt;br /&gt;In fact, staff_t executes lpr in the staff_t domain, since the staff_t domain has the ability to connect to the cups and gnome-keyring daemons.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;But when staff_t executes a firefox plugin, the plugin will transition to a locked down domain mozilla_plugin_t.&amp;nbsp; When the mozilla_plugin_t plugin executes /usr/bin/lpr, the lpr command will transition to the lpr_t domain.&lt;br /&gt;&lt;br /&gt;Printing now works well.&amp;nbsp; Now I can remove the permissive flag from mozilla_plugin_t.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# semanage permissive -d mozilla_plugin_t&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I have added all these rules into Fedora 17 policy, it should show up in the next policy update.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;This is why I live in Rawhide, I want to find problems before users do.&lt;/b&gt;</description>
  <comments>http://danwalsh.livejournal.com/55324.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>3</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/55229.html</guid>
  <pubDate>Tue, 20 Mar 2012 13:30:25 GMT</pubDate>
  <title>Solution to /myapache labeling problem from yesterday...</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/55229.html</link>
  <description>Twitter&amp;#39;s @Plaimclock&amp;nbsp; tweeted me @&lt;a href=&quot;https://twitter.com/#!/rhatdan&quot; rel=&quot;nofollow&quot;&gt;rhatdan&lt;/a&gt; yester.&amp;nbsp;&lt;br /&gt;He pointed out that&amp;nbsp; &lt;a href=&quot;http://danwalsh.livejournal.com/54803.html&quot;&gt;yesterdays blog&lt;/a&gt; on SELinux Labeling did not provide a solution to the /myapache problem.&lt;br /&gt;&lt;br /&gt;The solution is to label /myapache and all its children with a label httpd can read.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;You can figure this out by using:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;man httpd_selinux&lt;/span&gt;&lt;br /&gt;...&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; httpd_sys_content_t&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Set files with the httpd_sys_content_t type, if you want to treat the&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; files as httpd sys content.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Paths:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/share/icecast(/.*)?,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/share/htdig(/.*)?,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /etc/htdig(/.*)?,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /var/www/svn/conf(/.*)?,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/share/doc/ghc/html(/.*)?,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/share/mythtv/data(/.*)?,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /var/lib/htdig(/.*)?,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /srv/gallery2(/.*)?,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /srv/([^/]*/)?www(/.*)?,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/share/ntop/html(/.*)?,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/share/mythweb(/.*)?,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /var/lib/cacti/rra(/.*)?,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/share/openca/htdocs(/.*)?,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/share/selinux-pol‐&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; icy[^/]*/html(/.*)?,&amp;nbsp;&amp;nbsp; /usr/share/drupal.*,&amp;nbsp;&amp;nbsp; /var/lib/trac(/.*)?,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /var/www(/.*)?, /var/www/icons(/.*)?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Or&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# ls -lZd /var/www/html&lt;br /&gt;drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www/html&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You could simply put the labels in place using chcon.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;chcon -R -t httpd_sys_content_t /myapache&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The best solution is to tell SELinux about the label change.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# semanage fcontext -a -t httpd_sys_content_t &amp;#39;/myapache(/.*)?&amp;#39;&lt;br /&gt;# restorecon -R -v /myapache&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Done&lt;br /&gt;&lt;br /&gt;Note:&amp;nbsp; If you wanted to allow httpd to write to the directory you would use the httpd_sys_rw_content_t type.&lt;br /&gt;</description>
  <comments>http://danwalsh.livejournal.com/55229.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/54803.html</guid>
  <pubDate>Mon, 19 Mar 2012 16:06:00 GMT</pubDate>
  <title>SELinux Types Revisited.</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/54803.html</link>
  <description>A common mistake people make with SELinux is thinking all types are the same.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I often get bugzilla&amp;#39;s from people who first got a bug saying that httpd_t can not read some directory, say /myapache.&amp;nbsp; The admin then does some limited research and discovers the chcon command.&amp;nbsp; The admin then assumes if he uses the chcon command with the httpd type, it will solve his problem.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# chcon -t httpd_t /myapache&lt;br /&gt;chcon: failed to change context of `/myapache&amp;#39; to `staff_u:object_r:httpd_t:s0&amp;#39;: Permission denied&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What, wait I am unconfined_t, why won&amp;#39;t this be allowed.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# setenforce 0&lt;br /&gt;# chcon -t httpd_t /myapache&lt;br /&gt;#&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Works, I guess I am all set.&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# setenforce 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Apache blows up.&lt;br /&gt;&lt;br /&gt;Now they have AVC messages that indicate they need&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;allow unconfined_t httpd_t:dir relabelto;&lt;br /&gt;allow httpd_t fs_t:filesystem associate;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Since the admin forced the label onto the system, other parts of SELinux start to break. &amp;nbsp;Later locate runs and they get an AVC that requires&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;allow locate_t httpd_t:dir getattr;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What the ...&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The assumption, the administrator mistakenly made, was that all types are created equally.&amp;nbsp; But SELinux groups different types and then controls what &amp;quot;Classes&amp;quot; they can be assigned to.&amp;nbsp; SELinux block you from assigning a type to unsupported objects.&lt;br /&gt;&lt;br /&gt;For example SELinux has types for Files (file_type), Processes(domain), Ports (port_type), Ethernet Interfaces (netif_type), Node names (node_type), filesystems (filesystem_type) ...&lt;br /&gt;&lt;br /&gt;Types are grouped together using the policy attribute notated above within the ().&lt;br /&gt;&lt;br /&gt;SELinux only allows administrators to assign file_type to a filesystem_type object.&amp;nbsp; This access is controlled by the associate access.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# sesearch -A -s file_type -t filesystem_type -p associate&amp;nbsp; | grep file_type&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow file_type fs_t : filesystem associate ;&lt;br /&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you want to list all file_types, execute:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;seinfo -afile_type -x&lt;br /&gt;&amp;nbsp;&amp;nbsp; file_type&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bluetooth_conf_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmirrord_exec_t&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; colord_exec_t&lt;br /&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I have added an setroubleshoot plugin to Fedora 17 to try to help the administrator out.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;SELinux is preventing chcon from relabelto access on the directory myapache.&lt;br /&gt;&lt;br /&gt;*****&amp;nbsp; Plugin associate (99.5 confidence) suggests&amp;nbsp; **************************&lt;br /&gt;&lt;br /&gt;If you want to change the label of myapache to httpd_t, you are not allowed to since it is not a valid file type.&lt;br /&gt;Then you must pick a valid file label.&lt;br /&gt;Do&lt;br /&gt;select a valid file type.&amp;nbsp; List valid file labels by executing:&lt;br /&gt;# seinfo -afile_type -x&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hope this hopes, although I agree this is a difficult concept to understand.</description>
  <comments>http://danwalsh.livejournal.com/54803.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/54707.html</guid>
  <pubDate>Thu, 15 Mar 2012 12:50:56 GMT</pubDate>
  <title>Secure Boot versus Ksplice.</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/54707.html</link>
  <description>I have been attending many talks on Secure Boot.&amp;nbsp; The basic idea behind secure boot is to ensure that the bios/bootloader and kernel have not been hacked.&amp;nbsp; My understanding of how this is done is everything is signed and verified during the bootup.&amp;nbsp; Nothing can run in the kernel that was not signed and verified. &amp;nbsp;&lt;br /&gt;&lt;br /&gt;Then we Oracle pushing Ksplice.&lt;br /&gt;&lt;br /&gt;I can&amp;#39;t help but ask the question?&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Is ksplice a security disaster waiting to happen?&lt;/b&gt;&lt;br /&gt;</description>
  <comments>http://danwalsh.livejournal.com/54707.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>10</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/54343.html</guid>
  <pubDate>Tue, 13 Mar 2012 14:47:35 GMT</pubDate>
  <title>Fedora 17 New Security Feature part VIII - New SELinux Domains in F17</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/54343.html</link>
  <description>Each Fedora we release a bunch of new domains that will run in permissive mode for the release.&amp;nbsp; When the next release is released, the permissive domains are made enforcing.&lt;br /&gt;&lt;br /&gt;In my blog,&lt;a href=&quot;http://danwalsh.livejournal.com/42394.html&quot;&gt;10 things you probably did not know about SELinux.. #4&lt;/a&gt;, I describe how you can interact with permissive domains.&lt;br /&gt;&lt;br /&gt;Any ways these are the permissive domains in Fedora 16 that will now be confined.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fedora 16 Permissive Domains&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;pptp_t quota_nld_t sshd_sandbox_t nova_ajax_t nova_api_t nova_compute_t nova_direct_t nova_network_t nova_objectstore_t nova_scheduler_t nova_vncproxy_t nova_volume_t rabbitmq_epmd_t rabbitmq_beam_t deltacloudd_t iwhd_t mongod_t thin_t chrome_sandbox_nacl_t matahari_sysconfigd_t&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fedora 17 Permissive Domains&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;couchdb_t (/usr/bin/couchdb)&lt;br /&gt;blueman_t (/usr/libexec/blueman-mechanism)&lt;br /&gt;httpd_zoneminder_script_t (/usr/libexec/zoneminder/cgi-bin(/.*)?)&lt;br /&gt;zoneminder_t (/usr/bin/zmpkg.pl)&lt;br /&gt;selinux_munin_plugin_t (/usr/share/munin/plugins/selinux_avcstat)&lt;br /&gt;sge_shepherd_t (/usr/bin/sge_shepherd)&lt;br /&gt;sge_execd_t (/usr/bin/sge_execd)&lt;br /&gt;sge_job_t&lt;br /&gt;matahari_rpcd_t (/usr/bin/sge_execd)&lt;br /&gt;keystone_t (/usr/bin/keystone-all)&lt;br /&gt;pacemaker_t (/usr/sbin/pacemakerd)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Of course I reserve the right to add to this list.&amp;nbsp; our goal is to make sure all init/dbus services run with a type other then initrc_t.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;If you see a process on your machine that is shipped from Fedora running as initrc_t, please open a bugzilla on SELinux policy.</description>
  <comments>http://danwalsh.livejournal.com/54343.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/54092.html</guid>
  <pubDate>Mon, 12 Mar 2012 15:55:56 GMT</pubDate>
  <title>Fedora 17 New Security Feature part VII - thumbnail protection.</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/54092.html</link>
  <description>&lt;p&gt;John Leyden wrote an interesting article &lt;a href=&quot;http://www.theregister.co.uk/2011/02/09/linux_autorun_problems/&quot; rel=&quot;nofollow&quot;&gt;Linux vulnerable to Windows-style autorun exploits&lt;/a&gt;, about how security researches had discovered that Linux is potentially vulnerable to a user sticking a USB device or CDRom into a locked machine.&amp;nbsp; The basic idea was that &amp;quot;Nautilus&amp;quot; would execute thumbnail drive code, to display thumbnails icons in the file browsers based on the content on the removable media, even if the machine was locked.&amp;nbsp; If the thumbnail executables were vulnerabile, a cracker could use the code used to process the thumbnail images to kill the screensaver/lock.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Never mind this, just plugging in a USB stick when you a logged in, could allow a cracker to take over your machine.&lt;br /&gt;&lt;br /&gt;At that time, I wrote policy for all thumbnail drivers to be locked down with SELinux, but I only turned it on for confined users.&lt;br /&gt;I and other users have been running this confinement thoughout Fedora 16.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;In Fedora 17 I have turned this on for the unconfined user.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;We are confining the following applications.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;/usr/bin/evince-thumbnailer&lt;br /&gt;/usr/bin/ffmpegthumbnailer&lt;br /&gt;/usr/bin/gnome-exe-thumbnailer.sh&lt;br /&gt;/usr/bin/gnome-nds-thumbnailer&lt;br /&gt;/usr/bin/gnome-xcf-thumbnailer&lt;br /&gt;/usr/bin/gsf-office-thumbnailer&lt;br /&gt;/usr/bin/raw-thumbnailer&lt;br /&gt;/usr/bin/shotwell-video-thumbnailer&lt;br /&gt;/usr/bin/totem-video-thumbnailer&lt;br /&gt;/usr/bin/whaaw-thumbnailer&lt;br /&gt;/usr/lib(64)?/tumbler-1/tumblerd&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I have seen these applications try to &amp;quot;execstack&amp;quot; when running mplayer executable on an thumbnails, kind of scary.&lt;br /&gt;&lt;br /&gt;If you know of other thumbnail applications that get launched as thumbnails, please tell me.&lt;br /&gt;&lt;/p&gt;</description>
  <comments>http://danwalsh.livejournal.com/54092.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>7</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/53878.html</guid>
  <pubDate>Thu, 08 Mar 2012 16:46:18 GMT</pubDate>
  <title>Fedora 17 New Security Feature part VI - man pages for SELinux user/role domains</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/53878.html</link>
  <description>Ok, maybe this should be Security Feature IV.5 but Roman numerals do not support decimal points.&amp;nbsp; :^)&lt;br /&gt;&lt;br /&gt;After I wrote the tool to &lt;a href=&quot;http://danwalsh.livejournal.com/52156.html&quot;&gt;generate service domains man pages&lt;/a&gt;, Miroslav Grepl thought it would be a good idea to generate similar policy for user domains and roles.&lt;br /&gt;&lt;br /&gt;We hacked up a new script called &lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/genman/segenuserman&quot; rel=&quot;nofollow&quot;&gt;segenuserman&lt;/a&gt;, which generates 13 new SELinux user and Role man pages.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:smaller;&quot;&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;auditadm_selinux.8&amp;nbsp; git_shell_selinux.8&amp;nbsp; logadm_selinux.8 secadm_selinux.8&amp;nbsp;&amp;nbsp;&amp;nbsp; sysadm_selinux.8 user_selinux.8&amp;nbsp;&amp;nbsp;&amp;nbsp; xguest_selinux.8 dbadm_selinux.8 guest_selinux.8&amp;nbsp; nx_server_selinux.8&amp;nbsp; staff_selinux.8 unconfined_selinux.8&amp;nbsp; webadm_selinux.8&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:smaller;&quot;&gt;Note segenuserman also requires &lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/genman/senetwork.py&quot; rel=&quot;nofollow&quot;&gt;senetwork.py&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here is the &lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/genman/staff_selinux.html&quot; rel=&quot;nofollow&quot;&gt;staff_selinux.8&lt;/a&gt; for an SELinux user, and &lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/genman/webadm_selinux.html&quot; rel=&quot;nofollow&quot;&gt;webadm_selinux.8&lt;/a&gt; for an SELinux role.&lt;br /&gt;&lt;br /&gt;I have also updated the SELinux service domain man pages to include booleans,process types, file context paths, better descriptions, network ports.&lt;br /&gt;&lt;br /&gt;Here is an update &lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/genman/zebra_selinux.html&quot; rel=&quot;nofollow&quot;&gt;zebra_selinux.8&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description>
  <comments>http://danwalsh.livejournal.com/53878.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/53603.html</guid>
  <pubDate>Thu, 08 Mar 2012 04:34:27 GMT</pubDate>
  <title>Excuse me son, but your code is leaking !!!</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/53603.html</link>
  <description>I have written over the years about leaked file descriptors, and what a pain they have been to SELinux.&lt;br /&gt;&lt;br /&gt;C on Unix many many years ago was designed to leak by default.&amp;nbsp; A file descriptor is leaked if you open a file descriptor or socket and then do a fork/exec.&amp;nbsp; The new process will automatically get access to the file descriptor unless SELinux blocks it.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;When SELinux blocks the leaked file descriptor you usually end up with a strange looking AVC about the new domain trying to read or write a random file or a socket owned by the parent or even worse an ancestor.&lt;br /&gt;&lt;br /&gt;Talking with Uli Drepper the other day about leaked file descriptors.&amp;nbsp; He reminded me that the gcc/glibc teams had added a flags to open,fopen, socket, accept4 to change the default.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;man open&lt;br /&gt;...&lt;br /&gt;By&amp;nbsp; default,&amp;nbsp; the&amp;nbsp; new&amp;nbsp; file descriptor is set to remain open across an execve(2) (i.e., the&amp;nbsp; FD_CLOEXEC&amp;nbsp; file&amp;nbsp; descriptor&amp;nbsp; flag&amp;nbsp; described&amp;nbsp; in fcntl(2)&amp;nbsp; is&amp;nbsp; initially&amp;nbsp; disabled; the O_CLOEXEC flag, described below, can be used to change this default).&lt;br /&gt;...&lt;br /&gt;O_CLOEXEC (Since Linux 2.6.23)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Enable the close-on-exec&amp;nbsp; flag&amp;nbsp; for&amp;nbsp; the&amp;nbsp; new&amp;nbsp; file&amp;nbsp; descriptor. Specifying&amp;nbsp; this&amp;nbsp; flag&amp;nbsp; permits&amp;nbsp; a&amp;nbsp; program&amp;nbsp; to avoid additional fcntl(2) F_SETFD operations to set the FD_CLOEXEC&amp;nbsp; flag.&amp;nbsp;&amp;nbsp; Additionally,&amp;nbsp; use&amp;nbsp; of&amp;nbsp; this flag is essential in some multithreaded programs since using a separate fcntl(2)&amp;nbsp; F_SETFD&amp;nbsp; operation&amp;nbsp; to set&amp;nbsp; the&amp;nbsp; FD_CLOEXEC&amp;nbsp; flag does not suffice to avoid race conditions where one thread opens a file descriptor at the same&amp;nbsp; time as another thread does a fork(2) plus execve(2).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Sadly this can not be made the default, but as a good programing practice all open/socket,accept and fopen calls should use this flag in order to close the file descriptor by default.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;open(path, O_CLOEXEC | flags)&lt;br /&gt;socket(DOMAIN, SOCK_CLOEXEC | type, PROTOCOL)&lt;br /&gt;accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, SOCK_CLOEXEC | flags);&lt;br /&gt;fopen(path, &amp;quot;re&amp;quot;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you can not open a file descriptor with one of these commands then you can execute&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;fctnl(fd, F_SETFD, FD_CLOEXEC)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;He gcc developers or code analysys tools, you probably should catch when leaks happen, especially if they are not STDIN, STDOUT, STDERR.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Just be neat and stop leaking all over the place.&lt;/b&gt;&lt;br /&gt;</description>
  <comments>http://danwalsh.livejournal.com/53603.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/53378.html</guid>
  <pubDate>Tue, 06 Mar 2012 16:43:32 GMT</pubDate>
  <title>bash completion for setsebool/getsebool added for Fedora 17</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/53378.html</link>
  <description>&lt;span style=&quot;color:#000000;&quot;&gt;policycoreutils-python-2.1.10-26.fc17.x86_64 now has bash completion scripts for semanage and setsebool/getsebool&lt;br /&gt;&lt;br /&gt;/etc/bash_completion.d/semanage-bash-completion.sh&lt;br /&gt;/etc/bash_completion.d/setsebool-bash-completion.sh&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;# getsebool -&amp;lt;tab&amp;gt;&lt;br /&gt;# getsebool -a&lt;br /&gt;&lt;br /&gt;# getsebool samba_&amp;lt;tab&amp;gt;&lt;br /&gt;samba_create_home_dirs&amp;nbsp;&amp;nbsp; samba_export_all_ro&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; samba_share_fusefs&lt;br /&gt;samba_domain_controller&amp;nbsp; samba_export_all_rw&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; samba_share_nfs&lt;br /&gt;samba_enable_home_dirs&amp;nbsp;&amp;nbsp; samba_run_unconfined&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;# setsebool -&amp;lt;tab&amp;gt;&lt;br /&gt;# setsebool -P&amp;lt;tab&amp;gt;&lt;br /&gt;&lt;br /&gt;# setsebool -P samba_&amp;lt;tab&amp;gt;&lt;br /&gt;samba_create_home_dirs&amp;nbsp;&amp;nbsp; samba_export_all_ro&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; samba_share_fusefs&lt;br /&gt;samba_domain_controller&amp;nbsp; samba_export_all_rw&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; samba_share_nfs&lt;br /&gt;samba_enable_home_dirs&amp;nbsp;&amp;nbsp; samba_run_unconfined &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;semanage completion is a little more complicated.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# semanage &amp;lt;tab&amp;gt;&lt;br /&gt;boolean&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcontext&amp;nbsp;&amp;nbsp;&amp;nbsp; login&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; node&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; port&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;dontaudit&amp;nbsp;&amp;nbsp; interface&amp;nbsp;&amp;nbsp; module&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; permissive&amp;nbsp; user&lt;br /&gt;&lt;br /&gt;# semanage fcontext -&amp;lt;tab&amp;gt;&lt;br /&gt;-a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -d&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --deleteall&amp;nbsp; -f&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --help&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --modify&lt;br /&gt;--add&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -e&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --ftype&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --locallist&amp;nbsp; -t&lt;br /&gt;-C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --delete&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --equal&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -h&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -m&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --type&lt;br /&gt;&lt;br /&gt;# semanage fcontext -a -t samba&amp;lt;tab&amp;gt;&lt;br /&gt;samba_etc_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; samba_secrets_t&lt;br /&gt;sambagui_exec_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; samba_share_t&lt;br /&gt;samba_initrc_exec_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; samba_unconfined_script_exec_t&lt;br /&gt;samba_log_t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; samba_unit_file_t&lt;br /&gt;samba_net_exec_t&lt;br /&gt;&lt;br /&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Try it out.&amp;nbsp; If you find problems, patches accepted... :^)</description>
  <comments>http://danwalsh.livejournal.com/53378.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/53182.html</guid>
  <pubDate>Fri, 02 Mar 2012 21:35:09 GMT</pubDate>
  <title>senetwork: new tool for examining SELinux networking policy.</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/53182.html</link>
  <description>A couple of years ago I added some python bindings for setools.&amp;nbsp; I hoped we would start to see new tools arise to analyze SELinux policy.&amp;nbsp; Maybe making SELinux easier to user and understand.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Lately I have gone back to these tools and started playing with them to see what tools I could build.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Last couple of days I have hacked together a little script called &lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/senetwork&quot; rel=&quot;nofollow&quot;&gt;senetwork&lt;/a&gt;.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;The goal was to answering questions like:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What ports can a particular domain connect to?&amp;nbsp; Bind to?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# senetwork ftpd_t&lt;br /&gt;ftpd_t tcp name_connect&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ephemeral_port_t: 32768-61000&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldap_port_t: 389,636,3268&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dns_port_t: 53&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ocsp_port_t: 9080&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; kerberos_port_t: 88,750,4444&lt;br /&gt;ftpd_t tcp name_bind&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ephemeral_port_t: 32768-61000&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ftp_port_t: 21,990&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ftp_data_port_t: 20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; unreserved_port_t: 1024-32767,61001-65535&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; port_t: all ports with out defined types&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What type(s) are associated with a particular port number?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# senetwork 8080&lt;br /&gt;8080: tcp unreserved_port_t 1024-32767&lt;br /&gt;8080: udp unreserved_port_t 1024-32767&lt;br /&gt;8080: tcp http_cache_port_t 8080&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What ports are associated with a particular port_type?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# senetwork ftp_port_t&lt;br /&gt;ftp_port_t: tcp: 21,990&lt;br /&gt;ftp_port_t: udp: 990&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Basically senetwork looks at the argument and figures out whether or not it is a number, port type or domain type&lt;br /&gt;and then prints out the information.&lt;br /&gt;&lt;br /&gt;I plan on packaging up these little scriptlets with setools-console.&lt;br /&gt;</description>
  <comments>http://danwalsh.livejournal.com/53182.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/52958.html</guid>
  <pubDate>Thu, 01 Mar 2012 13:50:07 GMT</pubDate>
  <title>VMWare wants you to turn SELinux off?  Really?</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/52958.html</link>
  <description>i&amp;middot;ro&amp;middot;ny&lt;br /&gt;1.&amp;nbsp; The use of words to convey a meaning that is the opposite of its literal meaning: the irony of her reply, &amp;ldquo;How nice!&amp;rdquo; when I said I had to work all weekend.&lt;br /&gt;2. an outcome of events contrary to what was, or might have been, expected.&lt;br /&gt;&lt;br /&gt;One of the great features of KVM Virtualization is that each virtual machine is wrapped in an SELinux sandbox.&amp;nbsp;&amp;nbsp; All the software used to run a virtual machine on a host is called a hypervisor.&amp;nbsp; When you run virtual machines, you have to worry about hypervisor vulnerabilities, which would allow your guest operating system to attack the host or other virtual machines you have running on the host.&lt;br /&gt;&lt;br /&gt;We strive to make the Linux KVM Hypervisor as secure as possible, but bugs happen.&amp;nbsp; SELinux can control what the virtual machine process can and can not do on the host machine.&amp;nbsp;&amp;nbsp; If you are running virtual machines on you Fedora or Red Hat box, you really should be running SELinux in enforcing mode.&lt;br /&gt;&lt;br /&gt;It has come to my attention that VMWare support is suggesting people turn off SELinux...&amp;nbsp; I guess SELiux is too complicated for the VMWare crack support team to handle.&lt;br /&gt;&lt;br /&gt;At Red Hat we consider security a priority, VMWare I am not so sure.&lt;br /&gt;&lt;br /&gt;If you are having a problem running any VMWare product on a RHEL or Fedora Operating system, contact me dwalsh@redhat.com and I will help you run your virtual machines and leave the security in place...&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://www.popsci.com/science/article/2011-03/april-2011-how-it-works&quot; rel=&quot;nofollow&quot;&gt;&lt;img alt=&quot;Hacking the Cloud&quot; height=&quot;1024&quot; src=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/Presentations/hackthecloud.png&quot; style=&quot;border-width: 0pt; border-style: solid;&quot; width=&quot;768&quot; /&gt;&lt;/a&gt;&lt;br /&gt;April 2011 &amp;quot;How it Works&amp;quot; issue of Popular Science, &amp;nbsp; by Marie Pacella&lt;br /&gt;&lt;br /&gt;</description>
  <comments>http://danwalsh.livejournal.com/52958.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>5</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/52550.html</guid>
  <pubDate>Wed, 29 Feb 2012 14:53:13 GMT</pubDate>
  <title>Fedora 17 New Security Feature part VI - systemd-journal</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/52550.html</link>
  <description>There has been a lot written about the systemd-journal, this link gives a pretty good description of why it is good from a security point of view, although I don&amp;#39;t see this as a full replacement of syslog.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://techspear.com/2011/11/systemd-journal-an-alternate-for-the-syslog/&quot; rel=&quot;nofollow&quot;&gt;http://techspear.com/2011/11/systemd-journal-an-alternate-for-the-syslog/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Since the syslog format is ubiquitous, I don&amp;#39;t see it going away.&amp;nbsp; Also systemd-journal caused a lot of people who were working on &amp;quot;Structured Logging&amp;quot; to get all up in arms over it, since Lennart and Kay did not work with them.&lt;br /&gt;&lt;br /&gt;I still like it.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;systemd has become the central point of launching system apps, so it knows more about what is going on in the system then any other process save the kernel.&lt;br /&gt;&lt;br /&gt;Years ago when the audit system was being build Karl MacMillan of Tresys believed that some of the problems that the audit system was trying to fix could be handled by extending syslog to record all the information about the sending process.&amp;nbsp; ALL of the UIDs associated with a process as well as recording the SELinux Context.&amp;nbsp;&amp;nbsp; Systemd-journald now does this.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Let me give an example of where systemd-journal could be used to increase security.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;SELinux controls processes by only allowing them to do what they were designed to do.&amp;nbsp; Sometimes even less depending on the security goals of the policy writer.&amp;nbsp; This means SELinux would prevent a hacked ntpd process from doing anything other then handle&amp;nbsp; Network Time.&amp;nbsp; SELinux would prevent the hacked ntpd from reading mysql database or credit card data from the users home directory,&amp;nbsp; even if the ntpd process was running as root.&amp;nbsp; However, since the ntpd process sends syslog messages, SELinux would allow the hacked process to continue to send syslog messages.&amp;nbsp; The hacked ntpd could format syslog messages to match other daemons and potentially trick and administrator or even better a tool that reads the syslog file (Intrusion detection tools?) into doing something bad.&amp;nbsp;&amp;nbsp; If all messages were verified with the systemd-journal then the administrator or syslog analysis tool could notice that ntpd_t is sending messages about sshd, and we could realize your ntpd daemon was hacked.&lt;br /&gt;&lt;br /&gt;.cursor=s=f328cc4b2615417189ab76b00c7ae041;i=2;b=4c3d0faf6b774fb7930972c1a4a5f87&lt;br /&gt;.realtime=1329940273078467&lt;br /&gt;...skipping...&lt;br /&gt;SYSLOG_IDENTIFIER=sshd&lt;br /&gt;SYSLOG_PID=2302&lt;br /&gt;MESSAGE=sshd Fake message from sshd.&lt;br /&gt;_PID=2302&lt;br /&gt;_UID=0&lt;br /&gt;_GID=0&lt;br /&gt;_COMM=ntpd&lt;br /&gt;_EXE=/usr/sbin/ntpd&lt;br /&gt;_CMDLINE=/usr/sbin/ntpd -n -u ntp:ntp -g&lt;br /&gt;_SYSTEMD_CGROUP=/system/ntpd.service&lt;br /&gt;_SYSTEMD_UNIT=ntpd.service&lt;br /&gt;_SELINUX_CONTEXT=system_u:system_r:ntpd_t:s0&lt;br /&gt;_SOURCE_REALTIME_TIMESTAMP=1330527027590337&lt;br /&gt;_BOOT_ID=4c3d0faf6b774fb7930972c1a4a5f870&lt;br /&gt;_MACHINE_ID=432d8198a8fc421caf2dca48ccde1cf2&lt;br /&gt;_HOSTNAME=dhcp-189-250.bos.redhat.com&lt;br /&gt;&amp;nbsp;</description>
  <comments>http://danwalsh.livejournal.com/52550.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/52281.html</guid>
  <pubDate>Tue, 28 Feb 2012 17:03:55 GMT</pubDate>
  <title>Fedora 17 New Security Feature part V - sudo can now use sssd for authorization data (sudoers)</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/52281.html</link>
  <description>Currently sudo can be configure to read the /etc/sudoers file locally or to look it up via sudoers content via LDAP.&amp;nbsp; The LDAP server provides a useful feature for organizations&amp;nbsp; which wanted to centralize authorization data.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;But, as in all types of centralized authorization/authentications systems, it does not work well when your machine is disconnected&lt;br /&gt;from the network.&lt;br /&gt;&lt;br /&gt;sssd - System Security Services Daemon to the rescue.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://danwalsh.livejournal.com/42186.html&quot;&gt;sssd was added to Fedora a few releases ago, as I blogged about back in March 2011.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;One of the biggest benefits of sssd is that it allows for disconnected access to cached authorization/authentication data.&amp;nbsp;&lt;br /&gt;&lt;a href=&quot;https://fedoraproject.org/wiki/Features/SSSDSudoIntegration&quot; rel=&quot;nofollow&quot;&gt;A new feature in Fedora 17 adds sssd as a source for sudoers data.&lt;/a&gt;&lt;br /&gt;&lt;p&gt;The benefits of this integration as described on the feature page are:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;offline access - sudoers rules would be stored in a persistent cache, allowing sudo to fetch the rules seamlessly even in cases when the LDAP server is not reachable such as user roaming with a laptop.&lt;/li&gt;&lt;li&gt;unified configuration of LDAP parameters such as the servers used, timeout options and security properties at one places (sssd.conf)&lt;/li&gt;&lt;li&gt;sudo would take advantage of the advanced features SSSD has such as server fail over, server discovery using DNS SRV lookups and more&lt;/li&gt;&lt;li&gt;only one connection to the LDAP server open at a time resulting in less load on the LDAP server and better performance&lt;/li&gt;&lt;/ul&gt;And from an SELinux point of view one less network access for the sudoers application.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;caching of the rules - less load on the LDAP server and better performance on the client side as the client wouldn&amp;#39;t have to go to the server with each request&lt;/li&gt;&lt;li&gt;back end abstraction - data may be stored in NIS or other databases and accessed by the sudo transparently&lt;/li&gt;&lt;/ul&gt;Imagine if sssd and IPA could eventually cache SELinux Roles/Confined Users, maybe sometime in the not too distant future ...&lt;br /&gt;</description>
  <comments>http://danwalsh.livejournal.com/52281.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/52156.html</guid>
  <pubDate>Mon, 27 Feb 2012 16:11:34 GMT</pubDate>
  <title>Fedora 17 New Security Feature part IV - man pages for SELinux service domains</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/52156.html</link>
  <description>A couple of weeks ago, I began to look at the man pages for SELinux policy that we had written for SELinux several years ago.&amp;nbsp;&amp;nbsp;&amp;nbsp; I wanted to update them and maybe add a few new ones.&amp;nbsp;&amp;nbsp;&amp;nbsp; When I looked at the httpd_selinux man page, I noticed it was missing lots of descriptions of booleans and file types associated with the httpd domain.&amp;nbsp; When I started adding the boolean definitions, I quickly became board and realized this would not scale.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I decided to write a tool &lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/genman/genman.py&quot; rel=&quot;nofollow&quot;&gt;genman.py&lt;/a&gt;, that would query the SELinux Policy and write a man page for every executable service domain.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;DOMAIN_selinux.8&lt;br /&gt;&lt;br /&gt;I made a few assumptions that a service domain had an entrypoint ending in &amp;quot;_exec_t&amp;quot;.&amp;nbsp; Which we have pretty much standardized on.&amp;nbsp; Then I truncated the first part of the name off and searched for types and booleans containing this name.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;httpd_exec_t -&amp;gt; httpd for example.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I actually took is a step further and truncated a &amp;quot;d&amp;quot; off if the domain name ended in &amp;quot;d&amp;quot;, since this is common.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;httpd -&amp;gt; http.&lt;br /&gt;&lt;br /&gt;Booleans have a description in policy so this was fairly easy to add to the man pages.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# semanage boolean -l | grep http &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Would give you all the booleans that mention http, for example.&lt;br /&gt;&lt;br /&gt;Since we don&amp;#39;t have a description for each file type associated with a domain, I had to hard code a big it/then table with common definitions,&amp;nbsp; for example.&lt;br /&gt;&lt;br /&gt;def explain(f, k):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if f.endswith(&amp;quot;_var_run_t&amp;quot;):&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return &amp;quot;store the %s files under the /run directory.&amp;quot; % prettyprint(f, &amp;quot;_var_run_t&amp;quot;)&lt;br /&gt;&lt;br /&gt;Then I added a special section for any domains that use public_content_t.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Bottom line the tool was generated over 400 man pages that have been added to the selinux-policy-doc rpm.&lt;br /&gt;&lt;br /&gt;For example&lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/genman/abrt_selinux.html&quot; rel=&quot;nofollow&quot;&gt; abrt man page&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Are these man pages perfect? NO.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;But they are a lot better then nothing.&amp;nbsp; Now if you want to know the types/and or booleans associated with a service, all you need to execute is man SERVICE_selinux.&lt;br /&gt;&lt;br /&gt;If anyone wishes to enhance this, by perhaps adding file context definitions, patches welcomed...&lt;br /&gt;</description>
  <comments>http://danwalsh.livejournal.com/52156.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/51942.html</guid>
  <pubDate>Fri, 24 Feb 2012 17:02:20 GMT</pubDate>
  <title>Fedora 17 New Security Feature part III - systemd starting daemons</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/51942.html</link>
  <description>&lt;p&gt;Ok, this is not really a new feature in Fedora 17.&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;systemd has been starting some daemons in Fedora 16, but more and more daemons and privileged processes are being started by systemd in 17.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:larger;&quot;&gt;&lt;b&gt;Why is this a security feature? &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:smaller;&quot;&gt;Symbols: &lt;span style=&quot;color:#0000ff;&quot;&gt;@&lt;/span&gt; means Execute, &lt;span style=&quot;color:#0000ff;&quot;&gt;-&amp;gt;&lt;/span&gt; indicates transition, &lt;span style=&quot;color:#0000ff;&quot;&gt;===&lt;/span&gt; indicates a client/server communication &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the past daemons would be started in two ways.&amp;nbsp; At boot init (sysV) launches an initrc script and then this script would launch the daemon, or an admin could log in and launch the init script by hand causing the daemon to run.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;From an SELinux point of view this looked like:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;init_t @ initrc_exec_t -&amp;gt; initrc_t @ httpd_exec_t -&amp;gt; httpd_t:&amp;nbsp; &lt;/span&gt;&lt;br /&gt;This&amp;nbsp; apache processes would end up running with the full label of:&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;system_u:system_r:httpd_t:s0 &lt;/span&gt;&lt;br /&gt;If apache created content it would be labeled&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;system_u:object_r:httpd_sys_content_rw_t:s0 &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When an administrator started restarted the process say through &lt;span style=&quot;color:#0000ff;&quot;&gt;service httpd restart&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;unconfined_t @initrc_exec_t -&amp;gt; initrc_t @httpd_exec_t -&amp;gt; httpd_t &lt;/span&gt;&lt;br /&gt;The process would adopt the user portion of the SELinux label that started it&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;unconfined_u:system_r:httpd_t:s0&lt;/span&gt;&lt;br /&gt;Content would be created by this apache would be:&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;unconfined_u:object_r:httpd_sys_content_rw_t:s0 &lt;/span&gt;&lt;br /&gt;SELinux ends up confusing the user since we have to ignore the user componant of the SELinux label. If you wanted to write policy to confine based on user type, you can&amp;#39;t.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;With systemd this improves greatly.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The transitions is very different.&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;init_t @ httpd_exec_t -&amp;gt; httpd_t&lt;br /&gt;system_u:system_r:httpd_t:s0 &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But if you want to restart the Apache daemon as admin you now do.&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;unconfined_t === init_t @ httpd_exec_t -&amp;gt; httpd_t&lt;br /&gt;system_u:system_r:httpd_t:s0&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;With systemd we don&amp;#39;t have the labeling problem and we can tighten up the SELinux policy.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-size:larger;&quot;&gt;&lt;b&gt;Systemd starting daemons affects more than just SELinux.&amp;nbsp; &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Over the years lots of vulnerabilities and administration failures had to be worked around because of admins restarting daemons.&amp;nbsp; Daemons need to be coded to cleanup any leaked information from the admin process influencing the way the Daemon ran.&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to clean $ENV&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need to change working directory&lt;/li&gt;&lt;/ul&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; cd / in order to make sure they don&amp;#39;t blow up because they lack access to the current working directory (service script does for them).&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Need do something with the terminal, close stdin, stdout, stderr after they start.&lt;/li&gt;&lt;/ul&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; In SELinux we are always in a quandary about this, since if we allow the daemon access to the terminal, a hacked daemon could present the admin with passwd:&amp;nbsp; and trick him into revealing the admin password.)&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&amp;nbsp; &amp;nbsp; Changing the controlling terminal&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Change the handling of signals&lt;/li&gt;&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;br /&gt;If a daemon writer screws up on one of these he could make the system vulnerable or end up with unexpected bugs.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Using systemd to start daemons, guarantees the daemon always gets started with&amp;nbsp; the same environment whether they are started at boot or restarted by an administrator.&lt;/b&gt;&lt;/p&gt;</description>
  <comments>http://danwalsh.livejournal.com/51942.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/51459.html</guid>
  <pubDate>Thu, 23 Feb 2012 14:34:28 GMT</pubDate>
  <title>Fedora 17 New Security Feature part II - PrivateTmp</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/51459.html</link>
  <description>One of the reasons I am really excited about Fedora 17 is amount of new Security Features we have added, and not all of them involve SELinux ...&lt;br /&gt;&lt;br /&gt;As&amp;nbsp; I blogged a few weeks ago, we have stopped the ability for one process to look at another processes memory even if they have same UID, with the&lt;a href=&quot;http://danwalsh.livejournal.com/49336.html&quot;&gt; deny_ptrace&lt;/a&gt; feature.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;PrivateTmp&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;But today I want to talk about PrivateTmp.&amp;nbsp;&amp;nbsp;&amp;nbsp; One of my goals over the years has been to stop system services from using /tmp.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://danwalsh.livejournal.com/11467.html&quot;&gt;I blogged about this back in 2007.&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Any time I have found out a daemon was using /tmp, I tried to convince the packager to move the content to /run directory if it was temporary or /var/lib if it was permanent.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Over the years there have been several vulnerabilities&amp;nbsp; (CVEs) about this.&amp;nbsp; For example:&lt;br /&gt;&lt;pre wrap=&quot;&quot;&gt;CVE-2011-2722, which covered a case where hplib actually included code like.

&lt;span style=&quot;color: rgb(0, 0, 255);&quot;&gt;fp = fopen (&amp;quot;/tmp/hpcupsfax.out&amp;quot;, &amp;quot;w&amp;quot;); // &amp;lt;- VULN
system (&amp;quot;chmod 666 /tmp/hpcupsfax.out&amp;quot;); // &amp;lt;- &amp;quot;&lt;/span&gt;

Meaning if you setup a machine running cups daemon, a bad user or a application that a user ran could attack your system.

I have convinced a lot of packages to stop using /tmp, but I can&amp;#39;t get them all and in some cases services like Apache,  need to use /tmp.   Apache runs lots of other packages that might store content in /tmp.

Well systemd has added lots of new security features (more on these later).  

PrivateTmp, which showed up in Fedora 16,  is an option in systemd unit configuration files. 

&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&amp;nbsp;     &amp;gt; man system.unit
       ...
       A unit configuration file encodes information about a service, a socket, a device, a mount point, an automount point, a   
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style=&quot;font-size:small;&quot;&gt;swap file or partition, a start-up target, a file system path or a timer controlled and supervised by systemd(1).
&lt;/span&gt;
&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span style=&quot;font-size:small;&quot;&gt;     &amp;gt; man systemd.exec
&amp;nbsp; &amp;nbsp; &amp;nbsp;NAME
       systemd.exec - systemd execution environment configuration
&amp;nbsp; &amp;nbsp; &amp;nbsp;SYNOPSIS
     &amp;nbsp; systemd.service, systemd.socket, systemd.mount, systemd.swap
&amp;nbsp; &amp;nbsp; &amp;nbsp;DESCRIPTION
       Unit configuration files for services, sockets, mount points and swap devices share a subset of configuration 
       options which define the execution environment of spawned processes.
      ...
       PrivateTmp=
           Takes a boolean argument. If true sets up a new file system namespace for the executed processes and mounts a 
           private /tmp directory inside it, that is not shared by processes outside of the namespace. This is useful to secure 
           access to temporary files of the process, but makes sharing between processes via /tmp impossible. 
           Defaults to false.&lt;/span&gt;&lt;/pre&gt;&lt;pre wrap=&quot;&quot;&gt;PrivateTmp causes systemd to do the following any time it starts a service with this option turned on:

&amp;nbsp;&amp;nbsp; Allocate a private &amp;quot;tmp&amp;quot; directory
   Create a new file system namespace 
   Bind mount this private &amp;quot;tmp&amp;quot; directory within the namespace over /tmp
   Start the service.  

This means that processes running with this flag would see a different and unique /tmp from the one users and other daemons sees or can access.

&lt;b&gt;&lt;span style=&quot;font-size:smaller;&quot;&gt;Note:  We have found bugs using PrivateTmp in Fedora 16, so make sure you test this well before turning it on in Production.&lt;/span&gt;&lt;/b&gt;

For Fedora 17, I opened a &lt;a href=&quot;http://fedoraproject.org/wiki/Features/ServicesPrivateTmp&quot; rel=&quot;nofollow&quot;&gt;feature page&lt;/a&gt; that requested all daemons that were using systemd unit files and /tmp to turn this feature on by default.

Apache and Cups now have PrivateTmp turned on by default in Fedora 17, along will several other daemons.

Giving three options as a Developer of System Service, I still believe that you should not use /tmp, you should use /run or /var/lib.  But if you have to use /tmp and do not communicate with other users then use PrivateTmp.  If you need to communicate with users be careful...
&lt;/pre&gt;</description>
  <comments>http://danwalsh.livejournal.com/51459.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/51435.html</guid>
  <pubDate>Mon, 20 Feb 2012 16:45:00 GMT</pubDate>
  <title>How can I allow a process to listing all processes on a system.</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/51435.html</link>
  <description>SELinux blocks lots of domains from listing all processes on the system.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Lots of useful information can be optained from reading the process info on a machine, so we would like to block this by default.&amp;nbsp; But sometimes users/policy writers really need to allow their domains to be able to list the processes on a system.&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size:small;&quot;&gt;Ole on the Fedora SELinux Users Mail list asked:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#808080;&quot;&gt;I have a problem with SELinux not allowing PHP to list other users&amp;#39; processes with the &amp;quot;ps&amp;quot; command.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color:#808080;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;If I disable SELinux with &amp;quot;setenforce 0&amp;quot; it works immediately.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color:#808080;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Is it possible to allow PHP to do this without disabling SELinux completely?&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;Processes are listed by reading all of the contents of /proc.&amp;nbsp; SELinux linux labels everything in /proc based on the label of the process.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;ps -eZ | grep sshd | head -1&lt;br /&gt;system_u:system_r:sshd_t:s0-s0:c0.c1023 853 ?&amp;nbsp; 00:00:00 sshd&lt;br /&gt;&lt;br /&gt;ls -lZ /proc/853 | head -1&lt;br /&gt;dr-xr-xr-x. root root system_u:system_r:sshd_t:s0-s0:c0.c1023 attr&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you want a confined process to run ps, it needs to list /proc/PID, it needs to read certain files in this directory, needs to read symbolic links in this directory and needs to getattr on the process.&amp;nbsp;&amp;nbsp; When writing policy we have added a macro for this access.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;define(`ps_process_pattern&amp;#39;,`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; allow $1 $2:dir list_dir_perms;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; allow $1 $2:file read_file_perms;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; allow $1 $2:lnk_file read_lnk_file_perms;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; allow $1 $2:process getattr;&lt;br /&gt;&amp;#39;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If we wanted to allow one process type (myuser_t) to read another process /proc data on sshd (sshd_t), we would need to write a line like:&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;ps_process_pattern(myuser_t, sshd_t)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;What if I want to allow a type to list all processes types?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In SELinux policy language we use &lt;b&gt;attributes&lt;/b&gt; are used to group multiple types together.&amp;nbsp;&lt;br /&gt;SELinux calls processes &amp;quot;domains&amp;quot;.&amp;nbsp; When we write policy we always give process types the &lt;b&gt;domain&lt;/b&gt; attribute.&lt;br /&gt;&lt;br /&gt;So if you wanted to allow a process myuser_t to&amp;nbsp; list all the processes on a system, you would write a rule like.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;ps_process_pattern(myuser_t, domain)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Dominic Grift answered Ole question by suggesting he install a local policy module that looked like:&lt;br /&gt;&lt;pre wrap=&quot;&quot;&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;policy_module(mytest, 1.0.0)
gen_require(` 
&amp;nbsp;&amp;nbsp;type httpd_t; 
  attribute domain; 
&amp;#39;)
ps_process_pattern(httpd_t, domain)&lt;/span&gt;

This works great.  Note that the apache daemon runs all php scripts within its process space, to they run as &lt;b&gt;httpd_t&lt;/b&gt;.

Another solution would be to use an interface that we have defined in policy to allow this, &lt;b&gt;domain_read_all_domains_state&lt;/b&gt;.  

The &lt;b&gt;/usr/share/selinux/devel/include/kernel/domain.if&lt;/b&gt; interface file defines several interfaces that can be used to interact with all domains.  An alternative policy module could have been written:

&lt;span style=&quot;color:#0000ff;&quot;&gt;policy_module(mytest, 1.0.0)
gen_require(` 
&amp;nbsp;&amp;nbsp;type httpd_t; 
&amp;#39;)
domain_read_all_domains_state(httpd_t)&lt;/span&gt;

&lt;/pre&gt;</description>
  <comments>http://danwalsh.livejournal.com/51435.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>4</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/50980.html</guid>
  <pubDate>Mon, 13 Feb 2012 20:35:38 GMT</pubDate>
  <title>SELinux problems on Fedora 17.</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/50980.html</link>
  <description>Anyone that has tried Fedora 17 over the last couple of days, might have noticed SELinux going nuts and blocking logins.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;systemd had a bug which was causing transitions to break.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The way the system is supposed to work is during boot systemd reads in the policy file on disk and then loads policy into the kernel.&lt;br /&gt;This causes all processes at that are running to be labeled kernel_t.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;systemd then reads the label on its image file /sbin/systemd (init_exec_t) and the label that it is currently running as (kernel_t), then it asks the kernel what label would the /sbin/systemd process get if kernel_t executed it.&amp;nbsp; The answer would be init_t, and then systemd is supposed to set the current label to init_t.&amp;nbsp;&amp;nbsp; From that point on all processes started by systemd would transition to their proper domains.&lt;br /&gt;&lt;br /&gt;Well just before systemd/Fedora 17 Alpha was about to be released.&amp;nbsp; Systemd changed the location of its executable from /bin/systemd to /usr/lib/systemd/systemd.&amp;nbsp; But they never changed the checking code.&amp;nbsp; We fixed policy to look at the new location and labeled /usr/lib/systemd/systemd correctly, but when systemd checked for the label of /bin/systemd, there was no file and systemd just continued running as kernel_t.&amp;nbsp; Since there are few rules for transitions of kernel_t to any other label, most of the system was labeled as kernel_t.&amp;nbsp; Finally when a user logged in via gdm or login or sshd, they were running as kernel_t and the code transitioned them to abrt_t, one of the few domains kernel_t will transition to.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;systemd-42-1.fc17&lt;/span&gt; fixes this problem, so if you update to this systemd or later, you should be able to run your system in enforcing mode.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Needless to say, we have been flooded with bug reports...</description>
  <comments>http://danwalsh.livejournal.com/50980.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/50790.html</guid>
  <pubDate>Tue, 07 Feb 2012 16:50:33 GMT</pubDate>
  <title>secommunicate is a handy little tool to analyze policy communication</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/50790.html</link>
  <description>&lt;dl&gt;&lt;dd&gt;&lt;div&gt;I wrote about &lt;a href=&quot;http://danwalsh.livejournal.com/46653.html&quot;&gt;setrans&lt;/a&gt; back in October.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;setrans is a tool that you could use to analyze policy to see if how one process domain transitions to another process domain.&lt;br /&gt;&lt;br /&gt;Today I got asked what type should a user assign to a file so that one process type &amp;quot;syslogd_t&amp;quot; could write and another process type &amp;quot;httpd_t&amp;quot; could read.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I answered the question that httpd_log_t would be a good candidate.&amp;nbsp; Then he asked could figure this out?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;My suggestion was he could use these commands.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# sesearch -A -s syslogd_t -c file -p write &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which will search for all types that syslogd_t can write.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# sesearch -A -s httpd_t -c file -p read&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Which will search for types httpd_t can read, then he could look at the intersection of these commands.&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Only that did not work...&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;# sesearch -A -s syslogd_t -c file -p write &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Does not return my suggestion of httpd_log_t.&amp;nbsp; It did however return an attribute &amp;quot;logfile&amp;quot; which includes httpd_log_t.&lt;br /&gt;Attributes are the way to group lots of types together.&amp;nbsp; And the sesearch command does not expand out the attributes.&lt;br /&gt;&lt;br /&gt;I decided to go off an play with python and create &lt;a href=&quot;http://people.fedoraproject.org/~dwalsh/SELinux/secommunicate&quot; rel=&quot;nofollow&quot;&gt;secommunicate&lt;/a&gt;.&amp;nbsp; The goal of this command is to print out a list of types that a source process type can write and a target process type can read.&lt;br /&gt;&lt;br /&gt;This little python script takes a source process type and a target process type and an optional class, defaulting to &amp;quot;file&amp;quot;.&amp;nbsp; It uses the sesearch python bindings to search the selinux policy for:&lt;/div&gt;&lt;ul&gt;&lt;li&gt;What class types can the source type write?&lt;/li&gt;&lt;li&gt;What class types can the target type read?&amp;nbsp;&lt;/li&gt;&lt;li&gt;It expands all attributes into the associated types&lt;/li&gt;&lt;li&gt;Then it generates the intersection of these types, and prints them out.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;./secommunicate syslogd_t httpd_t&lt;br /&gt;puppet_tmp_t&lt;br /&gt;afs_cache_t&lt;br /&gt;dirsrv_var_log_t&lt;br /&gt;nagios_log_t&lt;br /&gt;httpd_log_t&lt;br /&gt;user_cron_spool_t&lt;br /&gt;root_t&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;./secommunicate -c chr_file syslogd_t httpd_t&lt;br /&gt;user_tty_device_t&lt;br /&gt;devtty_t&lt;br /&gt;initrc_devpts_t&lt;br /&gt;null_device_t&lt;br /&gt;zero_device_t&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Seems like it could be a handy tool.&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Not sure how we should package or ship setrans and secommunicate, or what the correct syntax would be, but for those struggling to understand policy these seem to be handy tools.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#0000ff;&quot;&gt;./secommunicate -h&lt;br /&gt;usage: secommunicate [-h] [-c TCLASS] [-s SOURCEACCESS] [-t TARGETACCESS]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; source target&lt;br /&gt;&lt;br /&gt;SELinux Communication Analysys Tool&lt;br /&gt;&lt;br /&gt;positional arguments:&lt;br /&gt;&amp;nbsp; source&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Source type&lt;br /&gt;&amp;nbsp; target&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Source type&lt;br /&gt;&lt;br /&gt;optional arguments:&lt;br /&gt;&amp;nbsp; -h, --help&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; show this help message and exit&lt;br /&gt;&amp;nbsp; -c TCLASS, --class TCLASS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Class to use for communications, Default &amp;#39;file&amp;#39;&lt;br /&gt;&amp;nbsp; -s SOURCEACCESS, --sourceaccess SOURCEACCESS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Comma separate list of permissions for the source type&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to use, Default &amp;#39;open,write&amp;#39;&lt;br /&gt;&amp;nbsp; -t TARGETACCESS, --targetaccess TARGETACCESS&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Comma separated list of permissions for the target&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type to use, Default &amp;#39;open,read&amp;#39;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Note&lt;/b&gt;:&lt;br /&gt;If you wanted to know if a one domain can communicate with another domain via signals, you could just use&lt;br /&gt;&lt;br /&gt;sesearch -A -s syslogd_t -t httpd_t -c process&lt;br /&gt;Found 1 semantic av rules:&lt;br /&gt;&amp;nbsp;&amp;nbsp; allow syslogd_t domain : process getattr ;&lt;/div&gt;&lt;/dd&gt;&lt;/dl&gt;</description>
  <comments>http://danwalsh.livejournal.com/50790.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/50526.html</guid>
  <pubDate>Mon, 06 Feb 2012 22:03:25 GMT</pubDate>
  <title>Dan Walsh on Twitter @rhatdan</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/50526.html</link>
  <description>I guess I never blogged this.&amp;nbsp; But I have been tweeting for a while as rhatdan.&amp;nbsp; (Not so creative name).&lt;br /&gt;&lt;br /&gt;And as always I will almost never tweet something that does not have to do with SELinux or Security....&lt;br /&gt;&lt;br /&gt;Follow me if you like.</description>
  <comments>http://danwalsh.livejournal.com/50526.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/50380.html</guid>
  <pubDate>Mon, 06 Feb 2012 15:24:04 GMT</pubDate>
  <title>Small change to semanage login record creation.</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/50380.html</link>
  <description>For those of you that use confined users, I have recently made a change to semanage that you may or may not notice.&amp;nbsp; This change will be back ported to RHEl6 also.&lt;br /&gt;&lt;br /&gt;In the previous version of semanage, when you created a login user mapping, if you did not specify the level or range of the user, semanage would default the level to s0.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;OLD&lt;/b&gt;&lt;br /&gt;# semanage login -a -s staff_u dwalsh&lt;br /&gt;# semanage login -l | grep dwalsh&lt;br /&gt;dwalsh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; staff_u&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s0&lt;br /&gt;&lt;br /&gt;In the new version of the tool, the semanage command will take the range of the SELinux user, staff_u, and assign it to the login record.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;NEW&lt;/b&gt;&lt;br /&gt;# semanage user -l | grep staff_u&lt;br /&gt;staff_u&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; user&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s0-s0:c0.c1023&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; staff_r sysadm_r system_r unconfined_r&lt;br /&gt;# semanage login -a -s staff_u dwalsh&lt;br /&gt;# semanage login -l | grep dwalsh&lt;br /&gt;dwalsh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; staff_u&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s0-s0:c0.c1023&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I believe this is the correct behavior especially since if you specified a SELinux whose range did not include s0, the tool would blow up.&lt;br /&gt;&lt;br /&gt;# semanage user -l | grep topsecret_u&lt;br /&gt;topsecret_u&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; user&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s15 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; s15-s15:c0.c1023&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; staff_r sysadm_r system_r&lt;br /&gt;# semanage login -a -s topsecret_u dwalsh&lt;br /&gt;Would generate a error saying invalid range.&lt;br /&gt;&lt;br /&gt;Of course if you specify the level/range it will override the SELinux user level.&lt;br /&gt;</description>
  <comments>http://danwalsh.livejournal.com/50380.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>0</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://danwalsh.livejournal.com/50014.html</guid>
  <pubDate>Fri, 03 Feb 2012 17:23:11 GMT</pubDate>
  <title>Why I love Open Source...  II</title>
  <author>dwalsh@redhat.com</author>  <link>http://danwalsh.livejournal.com/50014.html</link>
  <description>When SELinux does a full relabel, it prints a * for each 1000 files that it relabels.&lt;br /&gt;&lt;br /&gt;Some users were complaining about a full relabel and not being able to estimate how much time was left.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I explained to them that I did not know how many files were on the file system, so I could not estimate how much time was left.&amp;nbsp; They explained to me that there was ways to look at the file system and get then number of inodes, and then you could estimate how much time was left.&amp;nbsp; I told them patches accepted, and within a couple of days, I got a patch from John Reiser.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;As of policycoreutils-2.1.10-21.fc17&lt;br /&gt;&lt;br /&gt;If you do a &lt;span style=&quot;color:#0000ff;&quot;&gt;touch /.autorelabel; reboot&lt;/span&gt; or a&lt;span style=&quot;color:#0000ff;&quot;&gt; fixfiles restore&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You will see output like&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# fixfiles&amp;nbsp; restore&lt;br /&gt;10%&lt;br /&gt;&lt;br /&gt;With the counter slowly rising.&lt;br /&gt;&lt;br /&gt;Open source opens the possibility for all of us to contribute and make the whole better.&lt;br /&gt;&lt;br /&gt;Thanks John.</description>
  <comments>http://danwalsh.livejournal.com/50014.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
</channel>
</rss>

