<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>CUViper &#187; Technology</title>
	<atom:link href="http://blog.cuviper.com/category/technology/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cuviper.com</link>
	<description>Just a blog by Josh Stone</description>
	<lastBuildDate>Fri, 18 Dec 2009 00:49:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.cuviper.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/75eec96fc1a7034b597331dea4058e7d?s=96&#038;d=http://s2.wp.com/i/buttonw-com.png</url>
		<title>CUViper &#187; Technology</title>
		<link>http://blog.cuviper.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.cuviper.com/osd.xml" title="CUViper" />
	<atom:link rel='hub' href='http://blog.cuviper.com/?pushpress=hub'/>
		<item>
		<title>Hacking Linux Filenames</title>
		<link>http://blog.cuviper.com/2009/04/08/hacking-linux-filenames/</link>
		<comments>http://blog.cuviper.com/2009/04/08/hacking-linux-filenames/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 04:13:41 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[filenames]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[SystemTap]]></category>

		<guid isPermaLink="false">http://blog.cuviper.com/?p=103</guid>
		<description><![CDATA[I recently read an LWN article on David A. Wheeler&#8217;s essay, &#8220;Fixing Unix/Linux/POSIX Filenames.&#8221;  The gist is that he thinks the filename rules are too permissive &#8212; we have &#8216;/&#8217; as the path separator, and a raw 0 terminates the path, but anything else is fair game.  On the surface, this has a certain beautiful [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.cuviper.com&blog=641750&post=103&subd=cuviper&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I recently read an <a href="http://lwn.net/Articles/325304/">LWN article</a> on David A. Wheeler&#8217;s essay, &#8220;<a href="http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html">Fixing Unix/Linux/POSIX Filenames</a>.&#8221;  The gist is that he thinks the filename rules are too permissive &#8212; we have &#8216;/&#8217; as the path separator, and a raw 0 terminates the path, but anything else is fair game.  On the surface, this has a certain beautiful simplicity to it.  However, there are characters that have special meaning depending on the context, so almost any code that actually tries to interpret a filename will have to add a lot of complexity to be robust.  The essay delves into many ways that things can go wrong.</p>
<p>Filenames have been this way in for a long time though, and I don&#8217;t expect that this will change officially anytime soon.  Still, my day job now is developing <a href="http://sourceware.org/systemtap/">SystemTap</a>, and this sort of problem is one of many sorts that SystemTap can address.  Here&#8217;s a script to show how a system administrator could patch the kernel with their own addendum to the filename rules:</p>
<pre class="brush: plain;">
#!/usr/bin/stap -g
# badname.stp
# Prevent the creation of files with undesirable names.

# return non-zero if the filename should be blocked
function filter:long (name:string)
{
  return euid() &amp;&amp; isinstr(name, &quot;XXX&quot;)
}

global squash_inode_permission
probe kernel.function(&quot;may_create@fs/namei.c&quot;)
{
  # screen out the conditions which may_create will fail anyway
  if ($child-&gt;d_inode || $dir-&gt;i_flags &amp; 16) next

  # check that the new file meets our naming rules
  if (filter(kernel_string($child-&gt;d_name-&gt;name)))
    squash_inode_permission[tid()] = 1
}
probe kernel.function(&quot;inode_permission@fs/namei.c&quot;).return !,
      kernel.function(&quot;permission@fs/namei.c&quot;).return
{
  if (!$return &amp;&amp; squash_inode_permission[tid()])
    $return = -13 # -EACCES (Permission denied)
  delete squash_inode_permission[tid()]
}
</pre>
<p>The script starts by defining a filter function.  It first check whether the effective user ID is non-zero, so the root user can bypass the filter.  Then, for the prude admins out there, I&#8217;ve chosen to block filenames that contain the string &#8220;XXX&#8221;.  I intentionally kept this part small for this example, but you could easily write a function covering all of the new rules that Wheeler suggests.</p>
<p>After that is a probe on the <code>may_create</code> function, which is what the kernel calls to validate permissions for new files.  We can call our filtering function from here to see if the filename is OK, but since <code>may_create</code> is an inline, we don&#8217;t have a direct way to influence its result.  The last thing <code>may_create</code> does though is copy the result of <code>inode_permission</code> (or <code>permission</code> in earlier kernels), which we can override.  So, we save the filtering decision in a global, and then in a return probe on <code>inode_permission</code>, we can change the successful <code>$return</code> code to our own error value.  Now, any attempt to create a file that doesn&#8217;t pass our rules will get an error of &#8220;Permission denied&#8221;.</p>
<p>This sort of script is really just a band-aid, and it doesn&#8217;t do anything to deal with files that already have &#8220;bad&#8221; names.  Still, I hope this is an interesting example of how easily one can modify kernel behavior with SystemTap.  This script can be a starting point to define and try out your own filename rules, and changes can be reloaded and tested without ever having to reboot.  Once your policy has been decided, you can configure the script to load as soon as the system boots, so you&#8217;re always running with your improved filename rules, even across kernel upgrades.</p>
<p>It&#8217;s powerful stuff, but don&#8217;t let it get to your head&#8230; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuviper.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuviper.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuviper.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuviper.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuviper.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuviper.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuviper.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuviper.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuviper.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuviper.wordpress.com/103/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.cuviper.com&blog=641750&post=103&subd=cuviper&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.cuviper.com/2009/04/08/hacking-linux-filenames/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2a60134645fab0e6e1235ea0f17eda9d?s=96&#38;d=identicon&#38;r=R" medium="image">
			<media:title type="html">cuviper</media:title>
		</media:content>
	</item>
		<item>
		<title>Free Wireless</title>
		<link>http://blog.cuviper.com/2009/02/27/free-wireless/</link>
		<comments>http://blog.cuviper.com/2009/02/27/free-wireless/#comments</comments>
		<pubDate>Sat, 28 Feb 2009 05:54:08 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Intel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[netbook]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://blog.cuviper.com/?p=92</guid>
		<description><![CDATA[I made an upgrade on my netbook today.  Can you spot the difference? If you guessed that it&#8217;s now 100% open-source compatible, you are correct! Even though I ordered the Linux package, Dell cheaped out with a Broadcom wireless card that doesn&#8217;t have very good Linux support.  Broadcom does have drivers available, but you have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.cuviper.com&blog=641750&post=92&subd=cuviper&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<p>I made an upgrade on my netbook today.  Can you spot the difference?</p>
<p><img class="alignnone size-full wp-image-96" title="netbook before" src="http://cuviper.files.wordpress.com/2009/02/wireless-pre1.jpg?w=450&#038;h=331" alt="netbook before" width="450" height="331" /></p>
<p><img class="alignnone size-full wp-image-97" title="netbook after" src="http://cuviper.files.wordpress.com/2009/02/wireless-post1.jpg?w=450&#038;h=329" alt="netbook after" width="450" height="329" /></p>
<p>If you guessed that it&#8217;s now 100% open-source compatible, you are correct!</p>
<p>Even though I ordered the Linux package, Dell cheaped out with a Broadcom wireless card that doesn&#8217;t have very good Linux support.  Broadcom does have drivers available, but you have to download and compile the wrapper yourself.  Downloading a new driver and all of the kernel-devel packages is a little harder when your network is not connected&#8230;</p>
<p>So to replace the Broadcom, I ordered an Intel 3945ABG card, because it is well supported in Linux.  The kernel has the right drivers already included, so Fedora works right out of the box, even booting off of a live cd.  And not only are the drivers open-source, but they even work better.  My connection time shrunk from 20-30 seconds down to about 5 seconds.  I can live with that!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuviper.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuviper.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuviper.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuviper.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuviper.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuviper.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuviper.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuviper.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuviper.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuviper.wordpress.com/92/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.cuviper.com&blog=641750&post=92&subd=cuviper&ref=&feed=1" />]]></content:encoded>
			<wfw:commentRss>http://blog.cuviper.com/2009/02/27/free-wireless/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2a60134645fab0e6e1235ea0f17eda9d?s=96&#38;d=identicon&#38;r=R" medium="image">
			<media:title type="html">cuviper</media:title>
		</media:content>

		<media:content url="http://cuviper.files.wordpress.com/2009/02/wireless-pre1.jpg" medium="image">
			<media:title type="html">netbook before</media:title>
		</media:content>

		<media:content url="http://cuviper.files.wordpress.com/2009/02/wireless-post1.jpg" medium="image">
			<media:title type="html">netbook after</media:title>
		</media:content>
	</item>
	</channel>
</rss>