<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Examining the Linux VDSO</title>
	<atom:link href="http://anomit.com/2010/04/18/examining-the-linux-vdso/feed/" rel="self" type="application/rss+xml" />
	<link>http://anomit.com/2010/04/18/examining-the-linux-vdso/</link>
	<description></description>
	<lastBuildDate>Wed, 01 Sep 2010 14:04:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ezra Gilbert</title>
		<link>http://anomit.com/2010/04/18/examining-the-linux-vdso/comment-page-1/#comment-3629</link>
		<dc:creator>Ezra Gilbert</dc:creator>
		<pubDate>Wed, 01 Sep 2010 14:04:18 +0000</pubDate>
		<guid isPermaLink="false">http://anomit.com/?p=200#comment-3629</guid>
		<description>The code in the last comment did not come out very well.  Here is a link to a fork of anomit&#039;s gist above that works with python 2.4.3: http://gist.github.com/560719</description>
		<content:encoded><![CDATA[<p>The code in the last comment did not come out very well.  Here is a link to a fork of anomit&#8217;s gist above that works with python 2.4.3: <a href="http://gist.github.com/560719" rel="nofollow">http://gist.github.com/560719</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ezra Gilbert</title>
		<link>http://anomit.com/2010/04/18/examining-the-linux-vdso/comment-page-1/#comment-3628</link>
		<dc:creator>Ezra Gilbert</dc:creator>
		<pubDate>Wed, 01 Sep 2010 13:57:45 +0000</pubDate>
		<guid isPermaLink="false">http://anomit.com/?p=200#comment-3628</guid>
		<description>Here is a version of the python script that works with python 2.4.3 (maybe 2.4.x).  I basically removed the un-supported &quot;with&quot; statements and replaced os.SEEK_SET with 0 (per http://docs.python.org/library/os.html)

Also, I think the reason Suresh&#039;s 1-line script does not work is because the address read for vdso is for process &#039;cat&#039; and it is not a valid address when process &#039;dd&#039; tries to read from /proc/self/mem.  For it to work, the same process that reads the vdso address from /proc/self/maps needs to read linux-gate.so from /proc/self/mem.

-Ezra

[python]
#!/usr/bin/python

&quot;&quot;&quot;
http://anomit.com/2010/04/18/examining-the-linux-vdso/
http://gist.github.com/369785

This script writes the VDSO to the file linux-gate.dso.1 .
Use `objdump -d linux-gate.dso.1` to examine it.
You might also want to play around more with the other objdump options and
the readelf tool :)

LICENSE: MIT License ( http://www.opensource.org/licenses/mit-license.php )
&quot;&quot;&quot;
#from __future__ import with_statement
import os
import re

## regex pattern for finding out the memory address range from the output line
pattern = re.compile(r&#039;[\w\d]+-[\w\d]+&#039;)
file = open(&#039;/proc/self/maps&#039;, &#039;r&#039;)
for line in file:
    line = line.rstrip()
    if &#039;[vdso]&#039; in line:
        addr_range = pattern.findall(line)[0]
        start_addr, end_addr = [int(addr, 16)
                                for addr in addr_range.split(&#039;-&#039;)]
        break

fd = os.open(&#039;/proc/self/mem&#039;, os.O_RDONLY)
os.lseek(fd, start_addr, 0)
buf = os.read(fd, (end_addr-start_addr))

file = open(&#039;linux-gate.dso.1&#039;, &#039;w&#039;)
file.write(buf)
file.close()
os.close(fd)
[/python]</description>
		<content:encoded><![CDATA[<p>Here is a version of the python script that works with python 2.4.3 (maybe 2.4.x).  I basically removed the un-supported &#8220;with&#8221; statements and replaced os.SEEK_SET with 0 (per <a href="http://docs.python.org/library/os.html)" rel="nofollow">http://docs.python.org/library/os.html)</a></p>
<p>Also, I think the reason Suresh&#8217;s 1-line script does not work is because the address read for vdso is for process &#8216;cat&#8217; and it is not a valid address when process &#8216;dd&#8217; tries to read from /proc/self/mem.  For it to work, the same process that reads the vdso address from /proc/self/maps needs to read linux-gate.so from /proc/self/mem.</p>
<p>-Ezra</p>
<pre class="brush: python;">
#!/usr/bin/python

&quot;&quot;&quot;
<a href="http://anomit.com/2010/04/18/examining-the-linux-vdso/" rel="nofollow">http://anomit.com/2010/04/18/examining-the-linux-vdso/</a>
<a href="http://gist.github.com/369785" rel="nofollow">http://gist.github.com/369785</a>

This script writes the VDSO to the file linux-gate.dso.1 .
Use `objdump -d linux-gate.dso.1` to examine it.
You might also want to play around more with the other objdump options and
the readelf tool <img src='http://anomit.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> 

LICENSE: MIT License ( <a href="http://www.opensource.org/licenses/mit-license.php" rel="nofollow">http://www.opensource.org/licenses/mit-license.php</a> )
&quot;&quot;&quot;
#from __future__ import with_statement
import os
import re

## regex pattern for finding out the memory address range from the output line
pattern = re.compile(r'[\w\d]+-[\w\d]+')
file = open('/proc/self/maps', 'r')
for line in file:
    line = line.rstrip()
    if '[vdso]' in line:
        addr_range = pattern.findall(line)[0]
        start_addr, end_addr = [int(addr, 16)
                                for addr in addr_range.split('-')]
        break

fd = os.open('/proc/self/mem', os.O_RDONLY)
os.lseek(fd, start_addr, 0)
buf = os.read(fd, (end_addr-start_addr))

file = open('linux-gate.dso.1', 'w')
file.write(buf)
file.close()
os.close(fd)
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: anomit</title>
		<link>http://anomit.com/2010/04/18/examining-the-linux-vdso/comment-page-1/#comment-3627</link>
		<dc:creator>anomit</dc:creator>
		<pubDate>Wed, 01 Sep 2010 13:09:01 +0000</pubDate>
		<guid isPermaLink="false">http://anomit.com/?p=200#comment-3627</guid>
		<description>Ezra, you need Python version 2.5 and above to support the context manager concept used by the `with&#039; statement. More here: http://docs.python.org/release/2.5.2/lib/typecontextmanager.html

Sorry for that. You can create just a simple file object using the normal open() and work with it :).</description>
		<content:encoded><![CDATA[<p>Ezra, you need Python version 2.5 and above to support the context manager concept used by the `with&#8217; statement. More here: <a href="http://docs.python.org/release/2.5.2/lib/typecontextmanager.html" rel="nofollow">http://docs.python.org/release/2.5.2/lib/typecontextmanager.html</a></p>
<p>Sorry for that. You can create just a simple file object using the normal open() and work with it <img src='http://anomit.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ezra Gilbert</title>
		<link>http://anomit.com/2010/04/18/examining-the-linux-vdso/comment-page-1/#comment-3626</link>
		<dc:creator>Ezra Gilbert</dc:creator>
		<pubDate>Wed, 01 Sep 2010 13:05:20 +0000</pubDate>
		<guid isPermaLink="false">http://anomit.com/?p=200#comment-3626</guid>
		<description>Suresh,

Your dd 1-liner gives me the following error:

dd if=/proc/self/mem of=vdso skip=$((0x`cat /proc/self/maps &#124; grep vdso &#124; cut -d&#039;-&#039; -f1`/0x1000)) count=1 bs=$((0x1000))
dd: reading `/proc/self/mem&#039;: Input/output error
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0.000162585 seconds, 0.0 kB/s

Do I need to do something to make /proc/self/mem readable?  I am on 2.6.18 kernel.

Thanks.</description>
		<content:encoded><![CDATA[<p>Suresh,</p>
<p>Your dd 1-liner gives me the following error:</p>
<p>dd if=/proc/self/mem of=vdso skip=$((0x`cat /proc/self/maps | grep vdso | cut -d&#8217;-&#8217; -f1`/0&#215;1000)) count=1 bs=$((0&#215;1000))<br />
dd: reading `/proc/self/mem&#8217;: Input/output error<br />
0+0 records in<br />
0+0 records out<br />
0 bytes (0 B) copied, 0.000162585 seconds, 0.0 kB/s</p>
<p>Do I need to do something to make /proc/self/mem readable?  I am on 2.6.18 kernel.</p>
<p>Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ezra Gilbert</title>
		<link>http://anomit.com/2010/04/18/examining-the-linux-vdso/comment-page-1/#comment-3625</link>
		<dc:creator>Ezra Gilbert</dc:creator>
		<pubDate>Wed, 01 Sep 2010 13:03:28 +0000</pubDate>
		<guid isPermaLink="false">http://anomit.com/?p=200#comment-3625</guid>
		<description>Thanks for posting this article.  I read the original posting and was stuck on these very same issues.  But when I try to run your script I get error:

[root@asm-99 ~]# ./vdso.py
  File &quot;./vdso.py&quot;, line 20
    with open(&#039;/proc/self/maps&#039;, &#039;r&#039;) as file:
            ^
SyntaxError: invalid syntax

Do I need a particular version of python ?  I am using 2.4.3.

Thanks</description>
		<content:encoded><![CDATA[<p>Thanks for posting this article.  I read the original posting and was stuck on these very same issues.  But when I try to run your script I get error:</p>
<p>[root@asm-99 ~]# ./vdso.py<br />
  File &#8220;./vdso.py&#8221;, line 20<br />
    with open(&#8216;/proc/self/maps&#8217;, &#8216;r&#8217;) as file:<br />
            ^<br />
SyntaxError: invalid syntax</p>
<p>Do I need a particular version of python ?  I am using 2.4.3.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Suresh Kumar</title>
		<link>http://anomit.com/2010/04/18/examining-the-linux-vdso/comment-page-1/#comment-3465</link>
		<dc:creator>Suresh Kumar</dc:creator>
		<pubDate>Wed, 21 Jul 2010 12:12:10 +0000</pubDate>
		<guid isPermaLink="false">http://anomit.com/?p=200#comment-3465</guid>
		<description>Updated

Seem to have missed objdump

&lt;code&gt;
dd if=/proc/self/mem of=- skip=$((0x`cat /proc/self/maps &#124; grep vdso &#124; cut -d&#039;-&#039; -f1`/0x1000)) count=1 bs=$((0x1000)) &#124; objdump -d --start-address=0xffffe000 - &lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Updated</p>
<p>Seem to have missed objdump</p>
<p><code><br />
dd if=/proc/self/mem of=- skip=$((0x`cat /proc/self/maps | grep vdso | cut -d'-' -f1`/0x1000)) count=1 bs=$((0x1000)) | objdump -d --start-address=0xffffe000 - </code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Suresh Kumar</title>
		<link>http://anomit.com/2010/04/18/examining-the-linux-vdso/comment-page-1/#comment-3464</link>
		<dc:creator>Suresh Kumar</dc:creator>
		<pubDate>Wed, 21 Jul 2010 12:09:11 +0000</pubDate>
		<guid isPermaLink="false">http://anomit.com/?p=200#comment-3464</guid>
		<description>hmm, why not 
&lt;code&gt; dd if=/proc/self/mem of=vdso skip=$((0x`cat /proc/self/maps &#124; grep vdso &#124; cut -d&#039;-&#039; -f1`/0x1000)) count=1 bs=$((0x1000)) &lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>hmm, why not<br />
<code> dd if=/proc/self/mem of=vdso skip=$((0x`cat /proc/self/maps | grep vdso | cut -d'-' -f1`/0x1000)) count=1 bs=$((0x1000)) </code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stupid tricks at the userspace/kernelspace boundary, part 1 &#171; syskblogd</title>
		<link>http://anomit.com/2010/04/18/examining-the-linux-vdso/comment-page-1/#comment-3453</link>
		<dc:creator>Stupid tricks at the userspace/kernelspace boundary, part 1 &#171; syskblogd</dc:creator>
		<pubDate>Mon, 19 Jul 2010 09:41:36 +0000</pubDate>
		<guid isPermaLink="false">http://anomit.com/?p=200#comment-3453</guid>
		<description>[...] this blog post from Johan Petersson for another treatment of the first 3/5 of this, and this blog post from Anomit Ghosh for a Python version of [...]</description>
		<content:encoded><![CDATA[<p>[...] this blog post from Johan Petersson for another treatment of the first 3/5 of this, and this blog post from Anomit Ghosh for a Python version of [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yago Mouriño Mendaña</title>
		<link>http://anomit.com/2010/04/18/examining-the-linux-vdso/comment-page-1/#comment-3162</link>
		<dc:creator>Yago Mouriño Mendaña</dc:creator>
		<pubDate>Mon, 17 May 2010 20:23:21 +0000</pubDate>
		<guid isPermaLink="false">http://anomit.com/?p=200#comment-3162</guid>
		<description>Great post. I&#039;ve been looking for something like that for weeks. Thank you.</description>
		<content:encoded><![CDATA[<p>Great post. I&#8217;ve been looking for something like that for weeks. Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tweets that mention Truth, Computing and Fail » Examining the Linux VDSO -- Topsy.com</title>
		<link>http://anomit.com/2010/04/18/examining-the-linux-vdso/comment-page-1/#comment-3000</link>
		<dc:creator>Tweets that mention Truth, Computing and Fail » Examining the Linux VDSO -- Topsy.com</dc:creator>
		<pubDate>Sun, 18 Apr 2010 01:08:08 +0000</pubDate>
		<guid isPermaLink="false">http://anomit.com/?p=200#comment-3000</guid>
		<description>[...] This post was mentioned on Twitter by Anomit Ghosh, PlanetManipal. PlanetManipal said: Examining the Linux VDSO: I have been recently looking into the sysenter/sysexit way of implementing system calls ... http://bit.ly/dBrTcP [...]</description>
		<content:encoded><![CDATA[<p>[...] This post was mentioned on Twitter by Anomit Ghosh, PlanetManipal. PlanetManipal said: Examining the Linux VDSO: I have been recently looking into the sysenter/sysexit way of implementing system calls &#8230; <a href="http://bit.ly/dBrTcP" rel="nofollow">http://bit.ly/dBrTcP</a> [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
