<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://everything2.com/">
    <title>nyte's New Writeups</title>
    <link rel="alternate" type="text/html" href="http://everything2.com/index.pl?node=Everything%20User%20Search&amp;usersearch=nyte" />
    <link rel="self" type="application/atom+xml" href="?node=New%20Writeups%20Atom%20Feed&amp;type=ticker&amp;foruser=nyte" />
    <id>http://everything2.com/?node=New%20Writeups%20Atom%20Feed&amp;foruser=nyte</id>
    <updated>2008-10-12T03:18:58Z</updated>
<entry><title>frame pointer (thing)</title><link rel="alternate" type="text/html" href="http://www.everything2.com:80/user/nyte/writeups/frame+pointer"/><id>http://www.everything2.com:80/user/nyte/writeups/frame+pointer</id><author><name>nyte</name><uri>http://www.everything2.com:80/user/nyte</uri></author><published>2008-10-12T03:18:58Z</published><updated>2008-10-12T03:18:58Z</updated>
<content type="html">&lt;p&gt;The &lt;i&gt;&lt;a href=&quot;/title/stack+frame&quot;&gt;frame&lt;/a&gt; &lt;a href=&quot;/title/pointer&quot;&gt;pointer&lt;/a&gt;&lt;/i&gt; is a &lt;a href=&quot;/title/register&quot;&gt;register&lt;/a&gt; which holds the &lt;a href=&quot;/title/address&quot;&gt;address&lt;/a&gt; of the bottom of the &lt;a href=&quot;/title/stack+frame&quot;&gt;stack frame&lt;/a&gt;.  In the &lt;a href=&quot;/title/x86&quot;&gt;x86&lt;/a&gt; &lt;a href=&quot;/title/ISA&quot;&gt;ISA&lt;/a&gt;, this register is known as &lt;a href=&quot;/title/ebp&quot;&gt;ebp&lt;/a&gt;. The 'b' here stands for 'base', because the frame pointer is also known as the &lt;i&gt;base pointer&lt;/i&gt;.  In the &lt;a href=&quot;/title/Linux&quot;&gt;Linux&lt;/a&gt;/x86 &lt;a href=&quot;/title/ABI&quot;&gt;ABI&lt;/a&gt;, the frame pointer points to the bottom-most &lt;a href=&quot;/title/byte&quot;&gt;byte&lt;/a&gt; of the saved frame pointer of the previous stack frame.  Conceptually, imagine &lt;code&gt;foo()&lt;/code&gt; has called &lt;code&gt;bar()&lt;/code&gt; (keep in mind that the &lt;a href=&quot;/title/stack&quot;&gt;stack&lt;/a&gt; grows &lt;i&gt;downwards&lt;/i&gt;):&lt;pre&gt;
     |           ...             |
     |    rest of the stack      |
     |           ...             |
100: |    saved frame pointer    |
104: |    foo()'s stack frame    |
     |           ...             |
132: | return address from bar() |
136: |  100 &amp;#91;saved fp for foo()&amp;#93; | &amp;lt;-- bar()'s frame pointer points here
140: |    bar()'s stack frame    |
     |           ...             |&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;The frame pointer is useful because unlike the&amp;hellip;</content>
</entry><entry><title>return-to-libc attack (idea)</title><link rel="alternate" type="text/html" href="http://www.everything2.com:80/user/nyte/writeups/return-to-libc+attack"/><id>http://www.everything2.com:80/user/nyte/writeups/return-to-libc+attack</id><author><name>nyte</name><uri>http://www.everything2.com:80/user/nyte</uri></author><published>2008-10-11T05:21:17Z</published><updated>2008-10-11T05:21:17Z</updated>
<content type="html">The &lt;a href=&quot;/title/buffer+overflow+attack&quot;&gt;buffer overflow attack&lt;/a&gt; has long been one of the most common &lt;a href=&quot;/title/vulnerability&quot;&gt;vulnerabilities&lt;/a&gt; &lt;a href=&quot;/title/exploit&quot;&gt;exploit&lt;/a&gt;ed to gain access to or control of a &lt;a href=&quot;/title/computer+system&quot;&gt;system&lt;/a&gt;.  The standard form, explained very well in &lt;a href=&quot;/title/destrius%2527&quot;&gt;destrius'&lt;/a&gt; writeup at &lt;a href=&quot;/title/buffer+overflow+attack&quot;&gt;that node&lt;/a&gt; (read it first), has the &lt;a href=&quot;/title/attacker&quot;&gt;attacker&lt;/a&gt; submit as input a &lt;a href=&quot;/title/string&quot;&gt;string&lt;/a&gt; consisting of &lt;a href=&quot;/title/machine+code&quot;&gt;machine code&lt;/a&gt; at the beginning and the &lt;a href=&quot;/title/address&quot;&gt;address&lt;/a&gt; at which the machine code is stored at the end, such that this address overwrites the &lt;a href=&quot;/title/return+address&quot;&gt;return address&lt;/a&gt; stored at the top of the stack frame; this way, when the &lt;a href=&quot;/title/function&quot;&gt;function&lt;/a&gt; returns, it actually jumps to the beginning of the buffer, executing the (arbitrary) machine code that the attacker placed there.  Usually this is code to execute a &lt;a href=&quot;/title/shell&quot;&gt;shell&lt;/a&gt;.   Pictorially, where each line represents four bytes, and the function declares &lt;code&gt;char buffer&amp;#91;6&amp;#93;&lt;/code&gt; somewhere:&lt;pre&gt;
pre attack:                                    post attack:
|  argument 2      |                           |  argument 2      |
|  argument 1&lt;/pre&gt;&amp;hellip;</content>
</entry><entry><title>C++: computing Fibonacci numbers at compile time (idea)</title><link rel="alternate" type="text/html" href="http://www.everything2.com:80/user/nyte/writeups/C%252B%252B%253A+computing+Fibonacci+numbers+at+compile+time"/><id>http://www.everything2.com:80/user/nyte/writeups/C%252B%252B%253A+computing+Fibonacci+numbers+at+compile+time</id><author><name>nyte</name><uri>http://www.everything2.com:80/user/nyte</uri></author><published>2008-09-16T13:50:48Z</published><updated>2008-09-16T13:50:48Z</updated>
<content type="html">&lt;p&gt;First, a version of the code that will compile on a modern g++:&lt;/p&gt;
&lt;p&gt;&lt;pre&gt;#include &amp;lt;iostream&amp;gt;
template&amp;lt;int N&amp;gt; struct fib {
  static const int result = fib&amp;lt;N-1&amp;gt;::result + fib&amp;lt;N-2&amp;gt;::result;
};

template&amp;lt;&amp;gt; struct fib&amp;lt;0&amp;gt; {
  static const int result = 0;
};

template&amp;lt;&amp;gt; struct fib&amp;lt;1&amp;gt; {
  static const int result = 1;
};

int main(int ac, char *av&amp;#91;&amp;#93;)
{
  std::cout &amp;lt;&amp;lt; &quot;Fib(10) = &quot; &amp;lt;&amp;lt; fib&amp;lt;10&amp;gt;::result &amp;lt;&amp;lt; std::endl;
  return 0;
}&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;It might be worth exploring why exactly the above program is &lt;a href=&quot;/title/linear&quot;&gt;linear&lt;/a&gt; in &lt;a href=&quot;/title/Big-oh+notation&quot;&gt;compile time&lt;/a&gt; rather than &lt;a href=&quot;/title/exponential&quot;&gt;exponential&lt;/a&gt;.  After all, if the computation is being done at compile time, and the run-time of the &lt;a href=&quot;/title/algorithm&quot;&gt;algorithm&lt;/a&gt; is expected to be exponential, then compiling the program should be exponential, right?  Let's take a look.&lt;/p&gt;
&lt;p&gt;First, let's consider what &lt;code&gt;fib(n)&lt;/code&gt; depends on, in this algorithm.  Obviously, &lt;code&gt;fib(10)&lt;/code&gt; (to continue with the&amp;hellip;</content>
</entry><entry><title>Balmoral (thing)</title><link rel="alternate" type="text/html" href="http://www.everything2.com:80/user/nyte/writeups/Balmoral"/><id>http://www.everything2.com:80/user/nyte/writeups/Balmoral</id><author><name>nyte</name><uri>http://www.everything2.com:80/user/nyte</uri></author><published>2008-08-09T14:10:49Z</published><updated>2008-08-09T14:10:49Z</updated>
<content type="html">&lt;p&gt;The word Balmoral (&quot;Bal&quot;), in &lt;a href=&quot;/title/shoe&quot;&gt;shoe&lt;/a&gt; terminology, refers the way
certain shoes tie up, also known as &lt;a href=&quot;/title/closed+lacing&quot;&gt;closed lacing&lt;/a&gt;.&amp;nbsp; Picture a shoe
(please note that we are specifically talking about &lt;a href=&quot;/title/leather+dress+shoes&quot;&gt;dress shoe&lt;/a&gt;s here) with the toe up.&amp;nbsp; Now superimpose a capital
&quot;T&quot; on top, with the vertical part of the T at the opening between the
&lt;a href=&quot;/title/eyelet&quot;&gt;eyelet&lt;/a&gt;s.&amp;nbsp; In a Balmoral shoe, the horizontal part of the T is where
the flaps for the eyelets (the &quot;quarters&quot;) would be sewn down, with the
&lt;a href=&quot;/title/vamp&quot;&gt;vamp&lt;/a&gt; on top.&amp;nbsp; When properly tied, only the tip of the &lt;a href=&quot;/title/tongue&quot;&gt;tongue&lt;/a&gt; can be
seen on a Balmoral.&amp;nbsp; This is as opposed to a &lt;a href=&quot;/title/Blucher&quot;&gt;Blucher&lt;/a&gt; shoe, which has
&lt;a href=&quot;/title/open+lacing&quot;&gt;open lacing&lt;/a&gt;, wherein the quarters are not sewn down at
the top at all, and can flap open. Because of the way a Bal is sewn,  the part of the shoe around the ball of the foot can only be one
circumference and is not adjustable; therefore, people with narrow or
wide foot can find it more&amp;hellip;</content>
</entry><entry><title>Nesting Models in Software Transactional Memory (idea)</title><link rel="alternate" type="text/html" href="http://www.everything2.com:80/user/nyte/writeups/Nesting+Models+in+Software+Transactional+Memory"/><id>http://www.everything2.com:80/user/nyte/writeups/Nesting+Models+in+Software+Transactional+Memory</id><author><name>nyte</name><uri>http://www.everything2.com:80/user/nyte</uri></author><published>2007-09-14T22:58:19Z</published><updated>2007-09-14T22:58:19Z</updated>
<content type="html">&lt;h3&gt;Background&lt;/h3&gt;
The current dominant paradigm in &lt;a href=&quot;/title/synchronization&quot;&gt;synchronizing&lt;/a&gt; &lt;a href=&quot;/title/multithreading&quot;&gt;multi-threaded programs&lt;/a&gt; is &lt;i&gt;&lt;a href=&quot;/title/lock&quot;&gt;lock&lt;/a&gt;&lt;/i&gt;-based.  One associates a lock with a piece of data, and by convention, any thread that wishes to read or modify this data must acquire this lock.  The lock provides the guarantee of &lt;i&gt;&lt;a href=&quot;/title/mutual+exclusion&quot;&gt;mutual exclusion&lt;/a&gt;&lt;/i&gt;: only one thread may have acquired the lock at any point in time. All other threads that wish to do so must wait.  Lock-based parallel programming comes with a number of &lt;a href=&quot;/title/deadlock&quot;&gt;problems&lt;/a&gt;, &lt;a href=&quot;/title/lock+convoying&quot;&gt;some&lt;/a&gt; of which have been &lt;a href=&quot;/title/priority+inversion&quot;&gt;explored&lt;/a&gt; &lt;a href=&quot;/title/non-blocking+synchronization&quot;&gt;elsewhere&lt;/a&gt;.  With chip designers, for the time being, having given up on increased &lt;a href=&quot;/title/clock+speed&quot;&gt;clock speed&lt;/a&gt; and opted instead for increased &lt;a href=&quot;/title/parallelism&quot;&gt;parallelism&lt;/a&gt;, it has become increasingly important to find a better paradigm for concurrent programming.&lt;p&gt;

&lt;a href=&quot;/title/Lock-freedom+and+Obstruction-freedom+in+Software+Transactional+Memory&quot;&gt;Software Transactional Memory&lt;/a&gt; (STM) is one such alternative&amp;hellip;</content>
</entry><entry><title>Lock-freedom and Obstruction-freedom in Software Transactional Memory (idea)</title><link rel="alternate" type="text/html" href="http://www.everything2.com:80/user/nyte/writeups/Lock-freedom+and+Obstruction-freedom+in+Software+Transactional+Memory"/><id>http://www.everything2.com:80/user/nyte/writeups/Lock-freedom+and+Obstruction-freedom+in+Software+Transactional+Memory</id><author><name>nyte</name><uri>http://www.everything2.com:80/user/nyte</uri></author><published>2007-09-09T17:28:07Z</published><updated>2007-09-09T17:28:07Z</updated>
<content type="html">&lt;h3&gt;Background&lt;/h3&gt;
Dealing effectively with &lt;a href=&quot;/title/multithreading&quot;&gt;multi-threaded programming&lt;/a&gt; is a hot topic these days.  &lt;a href=&quot;/title/Clock+speed&quot;&gt;Clock speed&lt;/a&gt;s have more or less plateaued, but the &lt;a href=&quot;/title/HyperThreading&quot;&gt;number of threads&lt;/a&gt; on a &lt;a href=&quot;/title/CMP&quot;&gt;chip&lt;/a&gt; (and the &lt;a href=&quot;/title/SMP&quot;&gt;number of chips in a machine&lt;/a&gt;) is going up.  &lt;a href=&quot;/title/Lock&quot;&gt;Lock&lt;/a&gt;s are &lt;a href=&quot;/title/deadlock&quot;&gt;hard&lt;/a&gt; and &lt;a href=&quot;/title/lock+convoying&quot;&gt;prone&lt;/a&gt; to &lt;a href=&quot;/title/priority+inversion&quot;&gt;bugs&lt;/a&gt;.  &lt;a href=&quot;/title/Software+transactional+memory&quot;&gt;Software transactional memory&lt;/a&gt; is one possible alternative, and one that is popular in the &lt;a href=&quot;/title/computer+science&quot;&gt;research community&lt;/a&gt;.  The basic idiom of STM is to throw away the locking paradigm entirely, and to replace it with merely declaring a certain section of code &lt;i&gt;&lt;a href=&quot;/title/atomic&quot;&gt;atomic&lt;/a&gt;&lt;/i&gt;.  The &lt;a href=&quot;/title/run-time+system&quot;&gt;run-time system&lt;/a&gt; (1), be it the &lt;a href=&quot;/title/virtual+machine&quot;&gt;virtual machine&lt;/a&gt; in a managed language such as &lt;a href=&quot;/title/Java&quot;&gt;Java&lt;/a&gt;, or merely a library (2) in the case of a language such as &lt;a href=&quot;/title/C%252B%252B&quot;&gt;C++&lt;/a&gt; then guarantees that the actions performed within that section of code are &lt;a href=&quot;/title/isolation&quot;&gt;isolated&lt;/a&gt; from the rest of the program, and any updates to shared memory appear, to the rest of the program, to either happen&amp;hellip;</content>
</entry></feed>
