<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Chris Ball: Tag fedora</title>
    <link>http://blog.printf.net/articles/tag/fedora</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Systemtap for fun and profit</title>
      <description>&lt;p&gt;Kjartan Maraas pointed me at &lt;a href="http://https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=190128"&gt;this Fedora bug&lt;/a&gt; yesterday &amp;mdash; it points out that &lt;code&gt;/proc/$pid/maps&lt;/code&gt; has been broken in Rawhide for a month.  The patch that made &lt;code&gt;linux/fs/proc/task_mmu.c&lt;/code&gt; (which is where map requests are handled) diverge from mainline is &lt;a href="http://www.redhat.com/archives/fedora-cvs-commits/2006-April/msg00487.html"&gt;this one&lt;/a&gt;.  I can't read more about its motivation since the Bugzilla ID is security blocked.&lt;/p&gt;

&lt;p&gt;So, where to start?  &lt;code&gt;mm_for_maps()&lt;/code&gt; is a new function that does a bunch of checks on the relationship between &lt;code&gt;task&lt;/code&gt; and &lt;code&gt;current&lt;/code&gt; before deciding whether to allow the request; I threw some &lt;code&gt;printk()&lt;/code&gt;s in to find out which were failing, and found that we take the &lt;code&gt;!__ptrace_may_attach(task))&lt;/code&gt; path to the &lt;code&gt;out&lt;/code&gt; label in the code below:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if (task-&amp;gt;mm != mm)
    goto out;
if (task-&amp;gt;mm != current-&amp;gt;mm &amp;amp;&amp;amp; !__ptrace_may_attach(task))
    goto out;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;From there, it got hazy.  &lt;code&gt;__ptrace_may_attach()&lt;/code&gt; returns whatever &lt;code&gt;security_ptrace()&lt;/code&gt; does.  This takes us into pluggable LSMs land &amp;mdash; any LSM that gave a &lt;code&gt;struct security_operations&lt;/code&gt; with a pointer to a ptrace function will have a shot at returning an error that would be sent back to &lt;code&gt;security_ptrace()&lt;/code&gt; to stop our request from completing. &lt;/p&gt;

&lt;p&gt;But how do I tell which LSM is complaining, or even which LSMs are &lt;em&gt;loaded&lt;/em&gt;?  After all, they're registered at runtime.  Enter &lt;a href="http://sourceware.org/systemtap/"&gt;systemtap&lt;/a&gt;, as wisely suggested to me by Bill Nottingham (whom I now surely owe beer to).  Systemtap is similar to the Solaris dtrace; it'll let you instrument and track kernel functions and system calls for a running kernel.  It was installed on my Rawhide machine by default, which is always a nice touch.&lt;/p&gt;

&lt;p&gt;So, how to see which ptrace functions were registered?  Enter my first systemtap probe:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;unity:cjb~ % cat list-ptrace.stp
probe kernel.function("*ptrace*") {
    printf("%s\n", probefunc())
}
unity:cjb~ % sudo stap list-ptrace.stp
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;At this point, our stp script is converted into C code and compiled into a kernel module, before being loaded into the running kernel.  After running a &lt;code&gt;cat /proc/&amp;lt;pid&amp;gt;/maps&lt;/code&gt; in another terminal, we see:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;__ptrace_may_attach
cap_ptrace
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;.. which suggests that &lt;code&gt;cap_ptrace&lt;/code&gt; was called by &lt;code&gt;__ptrace_may_attach&lt;/code&gt;, and &lt;em&gt;that's&lt;/em&gt; where our &lt;code&gt;__ptrace_may_attach&lt;/code&gt; might be being turned down.  To be sure that we got to &lt;code&gt;cap_ptrace&lt;/code&gt; via &lt;code&gt;__ptrace_may_attach&lt;/code&gt;, we can ask for a backtrace:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;unity:cjb~ % cat cap-backtrace.stp
probe kernel.function("cap_ptrace") {
    printf("%s -&amp;gt; %s\n", probefunc(), print_backtrace())
}
unity:cjb~ % sudo stap cap-backtrace.stp
cap_ptrace -&amp;gt;
trace for 6345 (cat)
 0xc04c2286 : cap_ptrace+0x7/0x49 []
 0xc042a600 : __ptrace_may_attach+0xac/0xae []
 0xc049350c : mm_for_maps+0x83/0xd8 []
 0xc0492892 : m_start+0x28/0x11d []
 0xc04800d9 : seq_read+0xdb/0x268 []
 0xc0446288 : audit_syscall_entry+0x104/0x12b []
 0xc047fffe : seq_read+0x0/0x268 []
 0xc04648e2 : vfs_read+0x9f/0x13e []
 0xc0464d2e : sys_read+0x3c/0x63 []
 0xc0403d07 : syscall_call+0x7/0xb []
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We're pretty sure that &lt;code&gt;cap_ptrace&lt;/code&gt; was responsible.  Hunting through its source, we see that it has a path to return &lt;code&gt;-EPERM&lt;/code&gt;, which would do it.  So, we recompile the kernel in order to have &lt;code&gt;cap_ptrace&lt;/code&gt; tell us  what return value it's going to use, right?  Well, no.  Straight back to systemtap:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;unity:cjb~ % cat return-codes.stp
probe kernel.function("*ptrace*").return {
    printf("%s -&amp;gt; ", probefunc())
    log(returnstr(1));
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;.return&lt;/code&gt; after the function pattern tells systemtap to trigger when the function is returning, and &lt;code&gt;returnstr(1)&lt;/code&gt; asks for the return value as a decimal.  There's also &lt;code&gt;print_regs()&lt;/code&gt;, if you prefer to see what's in EAX directly.  Over to the other terminal to cat a &lt;code&gt;maps&lt;/code&gt; file again, and:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;unity:cjb~ % sudo stap return-codes.stp
cap_ptrace -&amp;gt; 0
__ptrace_may_attach -&amp;gt; 0
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That's odd.  &lt;code&gt;cap_ptrace&lt;/code&gt; is returning 0, which we can see in its code is meant to mean success, and &lt;code&gt;__ptrace_may_attach&lt;/code&gt; is receiving it back unharmed.  Cue an "ah-hah!" moment as we realise that the conditional:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if (task-&amp;gt;mm != current-&amp;gt;mm &amp;amp;&amp;amp; !__ptrace_may_attach(task))
    goto out;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;.. has the wrong polarity; each of the functions that &lt;code&gt;__ptrace_may_attach&lt;/code&gt; backs onto return zero for "success" (permission to attach), but the logic above is "if we're not trying to get the map of the current process, and &lt;code&gt;__ptrace_may_attach&lt;/code&gt; isn't non-zero, we should fail".  The exclamation mark needs to disappear.&lt;/p&gt;

&lt;p&gt;And so we're done.  My uses of systemtap weren't nearly as complex as those in the &lt;a href="http://sourceware.org/systemtap/tutorial/node9.html"&gt;tutorial&lt;/a&gt;,  but I'm happy that I saved myself the kernel compiles.  I'd somehow managed to miss any hype around systemtap; if you're another systemtap user, please consider blogging your code!&lt;/p&gt;</description>
      <pubDate>Thu, 11 May 2006 01:40:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:88c71590-68a1-42a8-9a08-37f155be34c9</guid>
      <author>Chris Ball</author>
      <link>http://blog.printf.net/articles/2006/05/11/systemtap-for-fun-and-profit</link>
      <category>kernel</category>
      <category>linux</category>
      <category>fedora</category>
      <trackback:ping>http://blog.printf.net/articles/trackback/162</trackback:ping>
    </item>
    <item>
      <title>All about the bling.</title>
      <description>&lt;p&gt;I noticed that the &lt;a href="http://fedoraproject.org/wiki/RenderingProject/aiglx#head-7c28114d7bfca3fd27da422f9bd36de8f8d41703"&gt;AIGLX movies&lt;/a&gt; on the Fedora wiki showed a neat &lt;a href="http://www.gnome.org/~jrb/aiglx/shot02.ogg"&gt;wobbly minimize animation&lt;/a&gt;, and decided to find out where the code was.  It was disabled in metacity CVS &amp;mdash; here's a &lt;a href="http://chris.printf.net/metacity-use-explosion.patch"&gt;patch&lt;/a&gt;
to enable this animation as the default, with the explosion animation still available if you start metacity with &lt;code&gt;USE_EXPLOSION=1&lt;/code&gt;.  Enjoy!&lt;/p&gt;</description>
      <pubDate>Mon, 24 Apr 2006 19:36:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:371aeba1-960a-4aa3-a573-cfbc512ff405</guid>
      <author>Chris Ball</author>
      <link>http://blog.printf.net/articles/2006/04/24/all-about-the-bling</link>
      <category>linux</category>
      <category>fedora</category>
      <trackback:ping>http://blog.printf.net/articles/trackback/76</trackback:ping>
    </item>
    <item>
      <title>Rawhide bug update.</title>
      <description>&lt;p&gt;Busy day.  I'm pleased and impressed that 2/3 of the &lt;a href="http://blog.printf.net/articles/2006/04/21/rawhide"&gt;bugs&lt;/a&gt; I mentioned yesterday are fixed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;S3 sleep works again after applying &lt;a href="http://lkml.org/lkml/2006/4/21/303"&gt;this patch&lt;/a&gt; from Hugh Dickins.  I don't get video or ethernet when I come back, but that's taken care of by unloading my ethernet driver beforehand, and by killing/restarting X on resume.  I should see if using vbetool differently (restorestate, perhaps) helps with that.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A CVS commit to lvm claims to fix the problem I had, and the new package is in the buildqueue.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Nothing new on my &lt;a href="http://www.mail-archive.com/netdev@vger.kernel.org/msg10344.html"&gt;pccardctl eject oops&lt;/a&gt;.  I'm going to try and &lt;code&gt;git bisect&lt;/code&gt; this over the weekend &amp;mdash; it's a nice candidate for bisection, since it was working as recently as 2.6.16 and it's not clear whether this is a locking problem (the PCMCIA code moved from semaphores to mutexes, but the patch looks sensible) or a netdev problem. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Sat, 22 Apr 2006 04:23:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:65c7e03f-d29d-456a-a970-824bd5f4d90f</guid>
      <author>Chris Ball</author>
      <link>http://blog.printf.net/articles/2006/04/22/rawhide-bug-update</link>
      <category>fedora</category>
      <category>kernel</category>
      <category>linux</category>
      <trackback:ping>http://blog.printf.net/articles/trackback/71</trackback:ping>
    </item>
    <item>
      <title>Rawhide!</title>
      <description>&lt;p&gt;Keeping track of details for a few bugs I'm seeing in current Rawhide on the new laptop:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;S3 sleep is broken, possibly libata-wide since &lt;a href="http://katzj.livejournal.com/384341.html"&gt;Jeremy&lt;/a&gt; is hitting the same symptoms as me (no disk access on resume) and he's on AHCI while I'm on &lt;code&gt;sd_mod&lt;/code&gt; and &lt;code&gt;ata_piix&lt;/code&gt;.  The symptoms are syslogd complaining that it can't write out the journal, and lots of repeated:&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;&lt;pre&gt;sd 0:0:0:0: SCSI error: return code = 0x40000
end_request: I/O error, dev sda, sector 18800717&lt;/pre&gt;&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;pccardctl eject&lt;/code&gt; is giving me an oops, which is new to Rawhide; looks like this is upstream, since it's the same oops as in &lt;a href="http://www.mail-archive.com/netdev@vger.kernel.org/msg10344.html"&gt;this lkml post&lt;/a&gt;.
&lt;br&gt;&lt;br&gt;&lt;/li&gt;
&lt;li&gt;The lvm(8) in my kernel-2141 initrd fails to boot, giving:&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;&lt;pre&gt;Volume group for uuid not found: (uuid)
0 logical volume(s) in volume group "group0" now active
mount: could not find filesystem /dev/root&lt;/pre&gt;&lt;/blockquote&gt;

&lt;blockquote&gt;I reverted &lt;code&gt;bin/lvm&lt;/code&gt; in the initrd to the version found in 2136, which has the same version number but a different md5sum &amp;mdash; that booted, so this looks like a new bug in lvm. &lt;/blockquote&gt;</description>
      <pubDate>Fri, 21 Apr 2006 05:10:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:981f37e3-faae-4044-b2d8-e98651566a59</guid>
      <author>Chris Ball</author>
      <link>http://blog.printf.net/articles/2006/04/21/rawhide</link>
      <category>fedora</category>
      <category>linux</category>
      <trackback:ping>http://blog.printf.net/articles/trackback/65</trackback:ping>
    </item>
  </channel>
</rss>
