<?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>Thoughts on Linux</title>
  <link>http://eparis.livejournal.com/</link>
  <description>Thoughts on Linux - LiveJournal.com</description>
  <lastBuildDate>Wed, 26 Aug 2009 14:29:33 GMT</lastBuildDate>
  <generator>LiveJournal / LiveJournal.com</generator>
  <lj:journal>eparis</lj:journal>
  <lj:journalid>15442441</lj:journalid>
  <lj:journaltype>personal</lj:journaltype>
  <atom10:link rel='hub' href='http://pubsubhubbub.appspot.com/' />
<item>
  <guid isPermaLink='true'>http://eparis.livejournal.com/891.html</guid>
  <pubDate>Wed, 26 Aug 2009 14:29:33 GMT</pubDate>
  <title>SELinux hardening for mmap_min_addr protections</title>
  <link>http://eparis.livejournal.com/891.html</link>
  <description>So in the last article I talked about how SELinux systems provide stronger protections against mapping low memory regions for remote attacks, but are weaker against attacks from authenticated users running unconfined.&amp;nbsp; The surprise to users that their SELinux enabled system could be weaker to some class of attacks was labeled CVE-2009-2695.&lt;br /&gt;&lt;br /&gt;After a bit of thought I&apos;ve decided the best way to address this is for LSMs to abandon the mmap_min_addr tunable altogether.&amp;nbsp; That tunable lets a root user disable protections.&amp;nbsp; Why would an LSM want a root user to be able to control it&apos;s protections at all?&amp;nbsp; What it protects should be defined entirely by the kernel and the policy.&amp;nbsp; So, what I&apos;ve done is to separate out the mmap_min_addr root vs. non-root check and the LSM check.&amp;nbsp; There is a new hard coded at kernel compile time amount of memory protected by the LSM.&amp;nbsp; This is unrelated to the /proc/sys/vm/mmap_min_addr file.&amp;nbsp; You can set that to 0 and the LSM will still be able to protect low memory.&lt;br /&gt;&lt;br /&gt;So in upstream kernels (2.6.30-rc6ish and later) to map the 0 page you will need both CAP_SYS_RAWIO (root) and the SELinux memprotect/mmap_zero permission instead of only needing one or the other.&amp;nbsp; If you set /proc/sys/vm/mmap_min_addr to 0 you will still need the SELinux mamprotect/mmap_zero permission.&lt;br /&gt;&lt;br /&gt;Hurray until the next time someone finds a way to map the 0 page and a null pointer bug in the kernel (lots of the latter as of late)&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;a href=&quot;http://git.kernel.org/linus/9c0d90103c7e0eb6e638e5b649e9f6d8d9c1b4b3&quot; rel=&quot;nofollow&quot;&gt;http://git.kernel.org/linus/9c0d90103c7e0eb6e638e5b649e9f6d8d9c1b4b3&lt;/a&gt;
&lt;a href=&quot;http://git.kernel.org/linus/8cf948e744e0218af604c32edecde10006dc8e9e&quot; rel=&quot;nofollow&quot;&gt;http://git.kernel.org/linus/8cf948e744e0218af604c32edecde10006dc8e9e&lt;/a&gt;
&lt;a href=&quot;http://git.kernel.org/linus/788084aba2ab7348257597496befcbccabdc98a3&quot; rel=&quot;nofollow&quot;&gt;http://git.kernel.org/linus/788084aba2ab7348257597496befcbccabdc98a3&lt;/a&gt;
&lt;a href=&quot;http://git.kernel.org/linus/1d9959734a1949ea4f2427bd2d8b21ede6b2441c&quot; rel=&quot;nofollow&quot;&gt;http://git.kernel.org/linus/1d9959734a1949ea4f2427bd2d8b21ede6b2441c&lt;/a&gt;&lt;/pre&gt;</description>
  <comments>http://eparis.livejournal.com/891.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>http://eparis.livejournal.com/606.html</guid>
  <pubDate>Tue, 21 Jul 2009 17:00:24 GMT</pubDate>
  <title>mmap_min_addr on SELinux and non-SELinux systems</title>
  <link>http://eparis.livejournal.com/606.html</link>
  <description>There has been a lot of conversation about the difference in how the mmap_min_addr proteciton is applied on SELinux vs. non-SELinux systems and how these differences made it easier to exploit a recent kernel BUG on SELinux systems.&amp;nbsp; A number of people have claimed the SELinux made the system weaker.&amp;nbsp; It did, but in other ways it was still stronger.&amp;nbsp; I&apos;m working to get the best of both worlds, but it isn&apos;t fair to claim a universal across the board weakening.&lt;br /&gt;&lt;br /&gt;We, the SELinux team, made a decision to not require CAP_SYS_RAWIO (non techies can think of this as root, or uid=0) for mapping the 0 page.&amp;nbsp; Instead we have an SELinux policy specific permission for this operation, mmap_zero. We made the choice to not require one to be root because WINE needs to do this operation and (sadly) there are a number of users out there who run windows applications inside WINE.&lt;br /&gt;&lt;br /&gt;Recently a kernel exploit was posted which works by mapping the 0 page, putting crafty info on that page, tickling a bug in the kernel, and winning (It is brilliant, as usual from Brad.)&amp;nbsp;&amp;nbsp; To get that 0 page mapped on a non-SELinux system he had to find a busted suid application (he found pulseaudio) and get that to map the page for him.&amp;nbsp; Since SELinux systems don&apos;t require root, he didn&apos;t need to find a busted suid application, he just had to map the 0 page and tickle the kernel bug.&lt;br /&gt;&lt;br /&gt;Now the claim comes out that SELinux systems are less secure than non-SELinux systems.&amp;nbsp; It&apos;s true, SELinux systems are weaker against authenticated logged in local users in this case.&amp;nbsp; But it&apos;s stronger against remote attacks.&amp;nbsp; What?&amp;nbsp; Yes, I agree completely that I need to strengthen the system against attacks from a malicious local user, but we do a much better job in this case if an attacker was trying to attack remotely.&lt;br /&gt;&lt;br /&gt;On a non-SELinux system if the attacker was able to subvert any network facing daemon they won.&amp;nbsp; They just tickled do the same thing.&amp;nbsp; Take over daemon remotely, use pulseaudio to map the page, tickle the kernel bug, win.&amp;nbsp; But what happens on an SELinux system?&amp;nbsp; It doesn&apos;t work!&amp;nbsp; Take over the network facing daemon, try the pulseaudio trick, crap, didn&apos;t get the page.&amp;nbsp; Try to map the zero page directly.&amp;nbsp; Crap it didn&apos;t work.&amp;nbsp; Now what?&amp;nbsp; You win, they lose.&amp;nbsp; SELinux is stronger than non-SELinux.&lt;br /&gt;&lt;br /&gt;This is because SELinux confines network facing daemons and doesn&apos;t give them permissions to map the 0 page.&amp;nbsp; It&apos;s not about root or non-root.&amp;nbsp; It&apos;s not about suid or non-suid.&amp;nbsp; It&apos;s about the SELinux domain not allowing the daemon to map the 0 page.&amp;nbsp; Yes, as an unconfined user you can map the page (and I&apos;m looking at ways to fix that) but if your system is subverted remotely, you are likely much better protected with SELinux than without.</description>
  <comments>http://eparis.livejournal.com/606.html</comments>
  <lj:security>public</lj:security>
  <lj:reply-count>11</lj:reply-count>
</item>
</channel>
</rss>

