title: Pseudo-random stack pointer under Linux?
body: <p>I was playing around with some code when I noticed something strange:</p>
  
  <pre><code>[~] main% cat test.cc
  #include &lt;stdio.h&gt;
  
  void f()
  {
      int i;
      fprintf(stderr, "&amp;i = 0x%08X\n", (long)&amp;i);
  }
  
  int main(int argc, char**argv)
  {
      f();
  }
  [~] main% g++ test.cc
  [~] main% ./a.out
  &amp;i = 0xBFA27AB4
  [~] main% ./a.out
  &amp;i = 0xBFAD7E24
  [~] main% ./a.out
  &amp;i = 0xBFCA3464
  [~] main% ./a.out
  &amp;i = 0xBF96C064
  [~] main%
  </code></pre>
  
  <p>The odd thing to me is the variation in the address of the variable i.</p>
  
  <p>My guess is that the kernel supplies different stack start addresses to try to thwart some kind of crack. What's the real reason?</p>