-fno -fno -fno stack protection

2 days straight now on IRC (##security on irc.freenode.net if you want to say hi) I have had to help someone compiling a program deal with it failing mid-stream. This is especially prevalent on security packages like fuzzers and such. First, what is stack protection?

Buffer Overflow Protection

In software, a stack buffer overflow occurs when a program writes to a memory address on the program’s call stack outside of the intended data structure; usually a fixed length buffer.[1][2] Stack buffer overflow bugs are caused when a program writes more data to a buffer located on the stack than there was actually allocated for that buffer. This almost always results in corruption of adjacent data on the stack, and in cases where the overflow was triggered by mistake, will often cause the program to crash or operate incorrectly. This type of overflow is part of the more general class of programming bugs known as buffer overflows.[1]

<figcaption class="wp-caption-text">Your code without protection…</figcaption></figure>

You can understand why those security guys want it enabled by default. Truth of the matter is it SHOULDN’T be an issue. With the default GCC installs and compiles of Ubuntu/Debian not using it though it causes all kind of problems. If you are here because you are getting, as an example:

ld: libdlrpc.so: hidden symbol `__stack_chk_fail_local’ isn’t defined

pam_sotp.so: undefined symbol: __stack_chk_fail_local

Here is the flow to fix it on your platform:

  1. In your source directory issue a make clean
  2. Rerun the autoconf: ./configure
  3. Edit the generated Makefile: vi Makefile
  4. Look for the CFLAGS= line and add: -fno-stack-protector

Updated: